将图像复制到粘贴板将jpeg转码为png

我正在开发一个iPhone应用程序来嵌入/提取jpeg文件中的数据。我想让用户能够将生成的图像复制到剪贴板,但是我正在使用的代码将生成的jpeg转换为png,当它被复制到剪贴板时。 我正在使用下面的代码,有什么我可以做的,以确保它是一点一滴地复制和粘贴的jpeg?
// copy to clipboard
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.image = [UIImage imageNamed:@"output.jpg"];
提前致谢!     
已邀请:
我终于想出了这一个。
// 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];
    
NSPasteboard *pboard  = [NSPasteboard generalPasteboard];
[pboard declareTypes: [NSMutableArray arrayWithObject:
                       NSTIFFPboardType] owner: nil];
[pboard setData:[imgView.image TIFFRepresentation] forType:NSTIFFPboardType];

NSData *data = [[NSPasteboard generalPasteboard] dataForType:NSPasteboardTypeTIFF];
    if (data) {
           // Do your stuff here 
    }
完全正常工作的代码,我使用相同的代码 祝好运 !!!!     

要回复问题请先登录注册