I use an object to convert NSViews to NSImages like this
Then these can be converted to various file types like this:
Also you can convert an image to PDF like this:
and to a CIImage like this
NSBitmapImageFileType is an enumerated type with the following constants:
NSBitmapImageFileTypeTIFF
NSBitmapImageFileTypeBMP
NSBitmapImageFileTypeGIF
NSBitmapImageFileTypeJPEG
NSBitmapImageFileTypePNG
NSBitmapImageFileTypeJPEG2000
Are any other image file types defined in Mac OS?
Code:
- (NSImage *) imageForView: (NSView *)aView{
NSImage *image = [[[NSImage alloc] initWithData: [self PDFForView: aView]] autorelease];
return image;
}
Code:
- (NSData*) representationForFileType: (NSImage*) image fileType: (NSBitmapImageFileType) fileType
{
NSData *temp = [image TIFFRepresentation];
NSBitmapImageRep *bitmap = [NSBitmapImageRep imageRepWithData: temp];
NSData *imgData = [bitmap representationUsingType: fileType properties: @{}];
return imgData;
}
Code:
dataForPboardType:image fileType: NSPasteboardTypePDF];
Code:
CIImage * cimg = [CIImage imageWithData: [image TIFFRepresentation]];
NSBitmapImageFileTypeTIFF
NSBitmapImageFileTypeBMP
NSBitmapImageFileTypeGIF
NSBitmapImageFileTypeJPEG
NSBitmapImageFileTypePNG
NSBitmapImageFileTypeJPEG2000
Are any other image file types defined in Mac OS?