I'm working on an iPhone app to embed/extract data in jpeg files. I want to give the user the ability to copy the resulting image to the clipboard, but the code I'm using coverts the resulting jpeg into a png when it gets copied to the clipboard.
I'm using the code below, is there anything I can do to ensure it is a bit by bit copy and paste of the jpeg?
// copy to clipboard
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.image = [UIImage imageNamed:@"output.jpg"];
Thanks in advance!
I finally figured this one out.
// copy to clipboard
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSData *data = [NSData dataWithContentsOfFile:filePath];
[pasteboard setData:data forPasteboardType:@"public.jpeg"];
...
// copy from clipboard
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSData *data = [pasteboard dataForPasteboardType:@"public.jpeg"];
NSString *copyPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.jpg"];
[data writeToFile:copyPath atomically:YES];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With