我有一個可以讓用戶導出JPEG圖像的Cocoa Mac圖像編輯應用程序。我目前使用如下代碼到這些圖像導出爲JPEG文件:如何在Cocoa應用程序中設置導出的JPEG圖像的每英寸像素數?
//this is user specified
NSInteger resolution;
NSImage* savedImage = [[NSImage alloc] initWithSize:NSMakeSize(600, 600)];
[savedImage lockFocus];
//draw here
[savedImage unlockFocus];
NSBitmapImageRep* savedImageBitmapRep = [NSBitmapImageRep imageRepWithData:[savedImage TIFFRepresentationUsingCompression:NSTIFFCompressionNone factor:1.0]];
NSDictionary* properties = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:1.0], NSImageCompressionFactor, nil];
//holds the jpeg file
NSData * imageData = nil;
imageData = [savedImageBitmapRep representationUsingType:NSJPEGFileType properties:properties];
不過,我想用戶能夠爲每英寸的像素爲這個JPEG圖像(像您可以在Photoshop中的導出選項)。在上面的代碼中,我需要修改什麼來調整導出的JPEG的值?
偉大的回答,你能不能也建議我怎麼指定顏色配置文件?例如adobe rgb/srgb等。 – AmaltasCoder 2012-02-11 12:05:26