Skip to content

Commit

Permalink
fix: iOS stickers lose their transparent background
Browse files Browse the repository at this point in the history
  • Loading branch information
L3o-pold committed Sep 16, 2024
1 parent de9d22d commit 7adec18
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions ios/UIPasteboard+GetImageInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ @implementation UIPasteboard (GetImageInfo)
NSString *uri = self.string;
NSData *fileData = item[type];

if ([type isEqual:@"public.jpeg"] || [type isEqual:@"public.heic"] || [type isEqual:@"public.png"]) {
if ([type isEqual:@"public.jpeg"] || [type isEqual:@"public.png"]) {
fileData = [self getDataForImageItem:item[type] type:type];
} else if ([type isEqual:@"com.compuserve.gif"]) {
} else if ([type isEqual:@"com.compuserve.gif"] || [type isEqual:@"public.heic"]) {
fileData = [self dataForPasteboardType:type];
}

Expand Down Expand Up @@ -75,19 +75,13 @@ @implementation UIPasteboard (GetImageInfo)
}
}


return fileInfos;
}

-(NSData *) getDataForImageItem:(NSData *)imageData type:(NSString *)type {
UIImage *image;
if ([type isEqual:@"public.heic"]) {
CFDataRef cfdata = CFDataCreate(NULL, [imageData bytes], [imageData length]);
CGImageSourceRef source = CGImageSourceCreateWithData(cfdata, nil);
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, 0, nil);
image = [[UIImage alloc] initWithCGImage:imageRef];
} else {
image = (UIImage *)imageData;
}
image = (UIImage *)imageData;
size_t width = CGImageGetWidth(image.CGImage);
size_t height = CGImageGetHeight(image.CGImage);
if (width > 6048 || height > 4032) {
Expand Down

0 comments on commit 7adec18

Please sign in to comment.