dtorres / olimageview Goto Github PK
View Code? Open in Web Editor NEWAnimated GIFs implemented the right way
License: MIT License
Animated GIFs implemented the right way
License: MIT License
The current implementation of UIImage caches the instances created by this method. And GIFs are really expensive to create.
So, why not?
Been seeing this warning for several months now
OLImageView/OLImage.m:306:26: warning: unused function 'OLCreateDecodedCGImageFromCGImage' [-Wunused-function]
I don't see the method in OLImage.m anymore so I can only assume it's been fixed. Can we get a new version of the pod to reflect this change? Thanks.
Right now, all the frames are obtained asynchronously in one thread, thus making the load of each frame synchronous.
The idea is to load each frame on a different thread and become truly asynchronous.
I haven't developed anything yet, It would be nice to read some opinions about it.
Or maybe leave as it is.
http://ww1.sinaimg.cn/bmiddle/62037b5ajw1e4w08i5g6og20c808ku0x.gif,this gif not big,but have 705 pics。when i play it internal memory overflow
Currently if a OLImage is set to a UIImageView, no image is shown.
It would be interesting to at least show the first frame.
The requirement is to mix a gif with a video,it need to compose the composited video frames with the Core Animation layer. but when i use it in swift, the OLImageView.layer just display the first frame of the gif then stop,But when i use it with objc ,it works very well. The objc code probably like this:
- (AVVideoCompositionCoreAnimationTool *)generateGifAnimationTool:(NSString *)gifPath{
CALayer *parentLayer = [CALayer layer];
CALayer *videoLayer = [CALayer layer];
parentLayer.frame = CGRectMake(0, 0, 720, 720);
videoLayer.frame = CGRectMake(0, 0, 720, 720);
[parentLayer addSublayer:videoLayer];
[parentLayer addSublayer:[self genrateGifLayer:gifPath]];
return [AVVideoCompositionCoreAnimationTool
videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];
}
- (CALayer *)genrateGifLayer:(NSString *)gifPath{
OLImageView *oliimage = [OLImageView new];
NSData *GIFDATA = [NSData dataWithContentsOfFile:gifPath];
oliimage.image = [OLImage imageWithData:GIFDATA];
CGFloat width = oliimage.image.size.width;
CGFloat height = oliimage.image.size.height;
CALayer *overlayLayer1 = oliimage.layer;
overlayLayer1.frame = CGRectMake(0, 0, width, height);
[overlayLayer1 setDuration:4.0];
[overlayLayer1 setBeginTime:0.0];
return overlayLayer1;
}
Is there anything wrong with it? tks!
So, if we strive for the perfect animated GIF implementation - this should also evaluate kCGImagePropertyGIFLoopCount :)
I have a imageView is playing a.gif ,when it end I want to play b.gif ,but it isnot working ,how can I do ?
In iOS7 the memory goes up crazily.
[self setResponseOLImage:[OLImage imageWithData:self.responseData];
This line in AFImageRequestOperation+OLImage makes AFImageRequestOperation obj strong references OLImage obj, and because in UIImageView+AFNetworking, there's such code:
self.af_imageRequestOperation = requestOperation;
which will cause your OLImage obj strong references AFImageRequestOperation obj, thus retain cycle occurs.
I use OLImage in the viewB's drawRect method. I use a normal ViewA to push ViewB, and pop ViewB repeatedly. After about 20 times, my app crashed after received several memory warnings.
I use instrument to monitor the memory usage, and you can see the result below.
My code to load gif is like:
@property (weak, nonatomic) IBOutlet OLImageView *gifImageView;
if (!self.gifImageView.image) {
self.gifImageView.image = [OLImage imageNamed:@"好.gif"];
[self.gifImageView setUserInteractionEnabled:YES];
[self.gifImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]];
}
I'm use ARC, I think the gif data should be released by iOS when ViewB popped. Or at least when my app received memory warnings.
Am I doing something wrong?
In the categories folder, there exists an AFImageRequestOperation+OLImage category.
I think it's a great idea, and has the potential to add a lot of value to this library.
However, I am not sure how to implement this, as it seems unclear due to the lack of documentation.
Can better instructions on the use of AFImageRequestOperation+OLImage be added to the Readme documentation.
Thank you.
I'm downloading sometimes large GIF files (800px images) with some complicated animations (i.e. large amounts of data) and they often times crash the app and cause the to crawl. Is there any way to improve that?
The CocoaPod for OLImageView is pinned to the tag 1.1.0.
The AFNetwork category back in the 1.1.0 days was generated a linker warning that was since fixed.
Could we make a release so that pod users stop getting that warning? Could even just be a 1.1.1 that would be a branch off 1.1.0 just with the category fix cherry picked.
Thanks :)
OLImageView works fine as a subview of normal UIView. But when I put it in a view, and then put the view to the parentLayer of animationTool, use AVAssetExportSession to export the gif to the video, the video's gif animation is very slow. any idea? Thanks!
Have been struggling on this all day, I made a small project on this issue, https://github.com/BillHu/GIFVideoTest
line 39: FLT_EPSILON
//it says use of undeclared "FLT_EPSILON" variable
Is this because the iPhone 5S has a 64 bit processor?
Do you know a solution to this?
Please release this one w/ FLT_EPSILON, since our CI breaks too often :)
i add gif(with many frames) into the UITableViewCell, and when the cell got highlighted,
the gif image disappears.
will you pay attention to that?
I can't reproduce this crash. FYI, I'm using release version 1.5.
SIGTRAP
0
0 CoreFoundation 0x00000001824b1cec _forwarding
1 CoreFoundation 0x00000001823b6c1c CF_forwarding_prep_0 + 80
2 CoreFoundation 0x000000018238d378 CFRelease + 516
3 CoreFoundation 0x00000001823ad218 CFArraySetValueAtIndex + 480
4 ImageIO 0x0000000183666c44 makeImagePlus
5 ImageIO 0x0000000183666248 CGImageSourceCreateImageAtIndex + 176
6 WeiboFun 0x0000000100282328 -OLImageSourceArray _objectAtIndex:
7 WeiboFun 0x00000001002821c8 -OLImageSourceArray objectAtIndex:
8 WeiboFun 0x0000000100205948 -OLImageView displayLayer:
9 QuartzCore 0x00000001865caf74 CA::Layer::display()
10 QuartzCore 0x00000001865ac75c CA::Layer::display_if_needed(CA::Transaction)
11 QuartzCore 0x00000001865ac414 CA::Layer::layout_and_display_if_needed(CA::Transaction)
12 QuartzCore 0x00000001865abc08 CA::Context::commit_transaction(CA::Transaction*)
13 QuartzCore 0x00000001865ab98c CA::Transaction::commit()
14 QuartzCore 0x00000001866011d8 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long)
15 IOKit 0x00000001835f98d0 IODispatchCalloutFromCFMessage + 376
16 CoreFoundation 0x0000000182450ce0 ___CFMachPortPerform
17 CoreFoundation 0x00000001824658fc _CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION
18 CoreFoundation 0x000000018246585c ___CFRunLoopDoSource1
19 CoreFoundation 0x00000001824637dc ___CFRunLoopRun
20 CoreFoundation 0x00000001823911f4 CFRunLoopRunSpecific + 392
21 GraphicsServices 0x000000018b51f5a4 GSEventRunModal + 164
22 UIKit 0x0000000186cc2784 UIApplicationMain + 1484
23 WeiboFun 0x00000001000b0144 main (main.m:14)
24 libdyld.dylib 0x0000000193262a08 _start
Hi, can you suggest a method to use this awesome image in a uitableview ?
Thanks
When using this library, which is very useful, I have found one problem.
The GIFs freeze while I scroll through a page.
How do I stop them from freezing while scrolling?
Thanks.
If OLImage initWithData is used with data that doesn't contain an animated gif, it starts an infinite recursion loop.
This issue was introduced in commit 9dfe840, and is caused by UIImage calling [self initWithData:data] within its initWithData:scale: method when the scale is 1.
when image in self.animatedImage still a NSNull object, cause crash! May change to :
Using f82b54d, I get the compile error from the subject. I think the property accessor syntax (.nativeScale) is causing it. Probably just using message syntax or performSelector would work.
Is it possible to turn this off?
Error:
'imageResponseSerializer' not found on object of type 'UIImageView *'
// ...
I haven't looked into the reason yet but dealloc isn't called in either of these classes. There's some quirk where something is holding a retain somewhere because my (fairly large) gifs are building up in memory.
Uncompressed GIF frames are very, very large. Even when only caching 10 at a time, memory usage can spike 50-100 MB when just one or two GIFs are playing. This kind of memory pressure is just untenable for our app (and most). Is there a reason caching is even needed?
We're using a fork that completely removes caching, simply delivering CGImage frames directly to the layer, releasing immediately after. This approach lowers memory requirements to a single frame, and improves performance dramatically. In the demo app, memory use is cut in half.
I'd be happy to submit a PR to address this if you're open to such a major change? It would also provide a chance to simplify things and clean up some of the internals.
With contentMode UIViewContentModeCenter…
Aimv = [[OLImageView alloc] initWithImage:[OLImage imageNamed:@"google-io.gif"]];
Aimv.contentMode = UIViewContentModeCenter;
…the image is rendered much larger than if using a UIImageView.
It seems that the scale of the image is not being accounted for. Any idea how I can work around this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.