Skip to content

Commit

Permalink
Merge pull request zxing-cpp#790 from kurzdigital/ios_release_color_s…
Browse files Browse the repository at this point in the history
…pace

Release color space after use in iOS wrapper
  • Loading branch information
axxel authored May 29, 2024
2 parents 91cf5ba + 78c535f commit 986f785
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,19 @@ - (instancetype)initWithOptions:(ZXIReaderOptions*)options{

- (NSArray<ZXIResult *> *)readCGImage:(nonnull CGImageRef)image
error:(NSError *__autoreleasing _Nullable *)error {
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray);
CGFloat cols = CGImageGetWidth(image);
CGFloat rows = CGImageGetHeight(image);
NSMutableData *data = [NSMutableData dataWithLength: cols * rows];


CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray);
CGContextRef contextRef = CGBitmapContextCreate(data.mutableBytes,// Pointer to backing data
cols, // Width of bitmap
rows, // Height of bitmap
8, // Bits per component
cols, // Bytes per row
colorSpace, // Colorspace
kCGBitmapByteOrderDefault); // Bitmap info flags
CGColorSpaceRelease(colorSpace);
CGContextDrawImage(contextRef, CGRectMake(0, 0, cols, rows), image);
CGContextRelease(contextRef);

Expand Down

0 comments on commit 986f785

Please sign in to comment.