Skip to content
This repository was archived by the owner on Mar 14, 2020. It is now read-only.

Commit 5c14797

Browse files
committed
Corrections to previous commits
1 parent ca3d169 commit 5c14797

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Classes/ImageFilter.m

+17-14
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ - (UIImage*) applyFilter:(FilterCallback)filter context:(void*)context
8383
CFDataRef m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage));
8484
int length = CFDataGetLength(m_DataRef);
8585
CFMutableDataRef m_DataRefEdit = CFDataCreateMutableCopy(NULL,length,m_DataRef);
86+
CFRelease(m_DataRef);
8687
UInt8 * m_PixelBuf = (UInt8 *) CFDataGetMutableBytePtr(m_DataRefEdit);
87-
CFRelease(m_DataRefEdit);
8888

8989
for (int i=0; i<length; i+=4)
9090
{
@@ -107,7 +107,7 @@ - (UIImage*) applyFilter:(FilterCallback)filter context:(void*)context
107107
scale:self.scale
108108
orientation:self.imageOrientation];
109109
CGImageRelease(imageRef);
110-
CFRelease(m_DataRef);
110+
CFRelease(m_DataRefEdit);
111111
return finalImage;
112112

113113
}
@@ -425,11 +425,14 @@ - (UIImage*) applyBlendFilter:(FilterBlendCallback)filter other:(UIImage*)other
425425
CFDataRef m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage));
426426
int length = CFDataGetLength(m_DataRef);
427427
CFMutableDataRef m_DataRefEdit = CFDataCreateMutableCopy(NULL,length,m_DataRef);
428+
CFRelease(m_DataRef);
428429
UInt8 * m_PixelBuf = (UInt8 *) CFDataGetMutableBytePtr(m_DataRefEdit);
429-
CFRelease(m_DataRefEdit);
430430

431431
CGImageRef otherImage = other.CGImage;
432432
CFDataRef m_OtherDataRef = CGDataProviderCopyData(CGImageGetDataProvider(otherImage));
433+
int otherLength = CFDataGetLength(m_OtherDataRef);
434+
CFMutableDataRef m_OtherDataRefEdit = CFDataCreateMutableCopy(NULL,otherLength,m_OtherDataRef);
435+
CFRelease(m_OtherDataRef);
433436
UInt8 * m_OtherPixelBuf = (UInt8 *) CFDataGetBytePtr(m_OtherDataRef);
434437

435438
int h = self.size.height;
@@ -460,8 +463,8 @@ - (UIImage*) applyBlendFilter:(FilterBlendCallback)filter other:(UIImage*)other
460463
CGContextRelease(ctx);
461464
UIImage *finalImage = [UIImage imageWithCGImage:imageRef];
462465
CGImageRelease(imageRef);
463-
CFRelease(m_DataRef);
464-
CFRelease(m_OtherDataRef);
466+
CFRelease(m_DataRefEdit);
467+
CFRelease(m_OtherDataRefEdit);
465468
return finalImage;
466469

467470
}
@@ -774,13 +777,13 @@ - (UIImage*) applyConvolve:(NSArray*)kernel
774777

775778
int length = CFDataGetLength(m_DataRef);
776779
CFMutableDataRef m_DataRefEdit = CFDataCreateMutableCopy(NULL,length,m_DataRef);
780+
CFRelease(m_DataRef);
777781
UInt8 * m_PixelBuf = (UInt8 *) CFDataGetMutableBytePtr(m_DataRefEdit);
778-
CFRelease(m_DataRefEdit);
779782

780783
int outputLength = CFDataGetLength(m_OutDataRef);
781784
CFMutableDataRef m_OutDataRefEdit = CFDataCreateMutableCopy(NULL,outputLength,m_DataRef);
785+
CFRelease(m_OutDataRef);
782786
UInt8 * m_OutPixelBuf = (UInt8 *) CFDataGetMutableBytePtr(m_OutDataRefEdit);
783-
CFRelease(m_OutDataRefEdit);
784787

785788
int h = CGImageGetHeight(inImage);
786789
int w = CGImageGetWidth(inImage);
@@ -827,8 +830,8 @@ - (UIImage*) applyConvolve:(NSArray*)kernel
827830
CGContextRelease(ctx);
828831
UIImage *finalImage = [UIImage imageWithCGImage:imageRef];
829832
CGImageRelease(imageRef);
830-
CFRelease(m_DataRef);
831-
CFRelease(m_OutDataRef);
833+
CFRelease(m_DataRefEdit);
834+
CFRelease(m_OutDataRefEdit);
832835
return finalImage;
833836

834837
}
@@ -964,8 +967,8 @@ - (UIImage*) vignette
964967
CFDataRef m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage));
965968
int length = CFDataGetLength(m_DataRef);
966969
CFMutableDataRef m_DataRefEdit = CFDataCreateMutableCopy(NULL,length,m_DataRef);
970+
CFRelease(m_DataRef);
967971
UInt8 * m_PixelBuf = (UInt8 *) CFDataGetMutableBytePtr(m_DataRefEdit);
968-
CFRelease(m_DataRefEdit);
969972
memset(m_PixelBuf,0,length);
970973

971974
CGContextRef ctx = CGBitmapContextCreate(m_PixelBuf,
@@ -990,8 +993,8 @@ - (UIImage*) vignette
990993
CGContextRelease(ctx);
991994
UIImage *finalImage = [UIImage imageWithCGImage:imageRef];
992995
CGImageRelease(imageRef);
993-
CFRelease(m_DataRef);
994-
996+
CFRelease(m_DataRefEdit);
997+
995998
UIImage *mask = [finalImage gaussianBlur:10];
996999
UIImage *blurredSelf = [self gaussianBlur:2];
9971000
UIImage *maskedSelf = [self mask:mask];
@@ -1004,8 +1007,8 @@ - (UIImage*) darkVignette
10041007
CFDataRef m_DataRef = CGDataProviderCopyData(CGImageGetDataProvider(inImage));
10051008
int length = CFDataGetLength(m_DataRef);
10061009
CFMutableDataRef m_DataRefEdit = CFDataCreateMutableCopy(NULL,length,m_DataRef);
1010+
CFRelease(m_DataRef);
10071011
UInt8 * m_PixelBuf = (UInt8 *) CFDataGetMutableBytePtr(m_DataRefEdit);
1008-
CFRelease(m_DataRefEdit);
10091012
memset(m_PixelBuf,0,length);
10101013

10111014
CGContextRef ctx = CGBitmapContextCreate(m_PixelBuf,
@@ -1048,7 +1051,7 @@ - (UIImage*) darkVignette
10481051
CGContextRelease(ctx);
10491052
UIImage *blackSquare = [UIImage imageWithCGImage:imageRef];
10501053
CGImageRelease(imageRef);
1051-
CFRelease(m_DataRef);
1054+
CFRelease(m_DataRefEdit);
10521055
UIImage *maskedSquare = [blackSquare mask:mask];
10531056
return [self overlay:[maskedSquare opacity:1.0]];
10541057
}

0 commit comments

Comments
 (0)