Update the test case to ensure the encoding options work
This commit is contained in:
parent
df28feb99c
commit
e303b7aed6
|
@ -208,7 +208,8 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
|||
BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue];
|
||||
if (encodeFirstFrame || frames.count == 0) {
|
||||
// for static single PNG images
|
||||
CGImageDestinationAddImage(imageDestination, image.CGImage, (__bridge CFDictionaryRef)properties);
|
||||
CGImageRef imageRef = frames.firstObject.image.CGImage ?: image.CGImage;
|
||||
CGImageDestinationAddImage(imageDestination, imageRef, (__bridge CFDictionaryRef)properties);
|
||||
} else {
|
||||
// for animated APNG images
|
||||
NSUInteger loopCount = image.sd_imageLoopCount;
|
||||
|
|
|
@ -293,7 +293,8 @@
|
|||
BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue];
|
||||
if (encodeFirstFrame || frames.count == 0) {
|
||||
// for static single GIF images
|
||||
CGImageDestinationAddImage(imageDestination, image.CGImage, (__bridge CFDictionaryRef)properties);
|
||||
CGImageRef imageRef = frames.firstObject.image.CGImage ?: image.CGImage;
|
||||
CGImageDestinationAddImage(imageDestination, imageRef, (__bridge CFDictionaryRef)properties);
|
||||
} else {
|
||||
// for animated GIF images
|
||||
NSUInteger loopCount = image.sd_imageLoopCount;
|
||||
|
|
|
@ -39,6 +39,12 @@
|
|||
// Test image encode PNG
|
||||
data = [image sd_imageDataAsFormat:SDImageFormatPNG];
|
||||
expect(data).notTo.beNil();
|
||||
// Test image encode JPEG with compressionQuality
|
||||
NSData *jpegData1 = [image sd_imageDataAsFormat:SDImageFormatJPEG compressionQuality:1];
|
||||
NSData *jpegData2 = [image sd_imageDataAsFormat:SDImageFormatJPEG compressionQuality:0.5];
|
||||
expect(jpegData1).notTo.beNil();
|
||||
expect(jpegData2).notTo.beNil();
|
||||
expect(jpegData1.length).notTo.equal(jpegData2.length);
|
||||
}
|
||||
|
||||
- (void)test03UIImageGIFCategory {
|
||||
|
@ -49,6 +55,7 @@
|
|||
NSData *data = [NSData dataWithContentsOfFile:[self testGIFPath]];
|
||||
image = [UIImage sd_imageWithGIFData:data];
|
||||
expect(image).notTo.beNil();
|
||||
expect(image.sd_isAnimated).beTruthy();
|
||||
}
|
||||
|
||||
#pragma mark - Helper
|
||||
|
|
Loading…
Reference in New Issue