tiff from NSImage, at 300 dpi
tiff from NSImage, at 300 dpi
- Subject: tiff from NSImage, at 300 dpi
- From: Todd Heberlein <email@hidden>
- Date: Mon, 8 Dec 2003 18:43:30 -0800
I am trying to take a PDF vector object (designed for 72 dpi), redraw
it into an NSImage for 300 dpi, and then export it as either a TIFF or
PNG.
The good news is that the rendering works and I get high definition bit
maps. For example, the original PDF image had a point size of 533 x
283 (@ 72 dpi), and my bitmap is 2221 x 1180 pixels. The bad news is
that the bitmap is 72 dpi, and I cannot figure out how to change it to
300 dpi.
I create my own bitmap, set its pixels to the larger size, and set its
size to the smaller size. But this does not seem to affect the
resolution in the tiff file. I also have tried using setPixelsHigh and
Wide on the NSBitmapImageRep, but no affect.
Any ideas?
Todd
orig_size is set to PDF's origin 533 x 722
big_size scales the orig_size by 300/72.
// Create NSImage and NSBitmapImageRep
big_image = [[NSImage alloc] initWithSize: big_size];
bitmap=[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:big_size.width // the big 2221 pixels
pixelsHigh:big_size.height // the big 1180 pixels
bitsPerSample:1
samplesPerPixel:1
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSCalibratedWhiteColorSpace
bytesPerRow:0
bitsPerPixel:0];
[bitmap setSize: orig_size]; // the small 533 x 283
[big_image addRepresentation:bitmap];
[big_image setCacheMode:NSImageCacheNever];
// Build view
tmp_view = [[Pdf2PngView alloc] initWithFrame: view_rect];
[tmp_view setImage: pdf_data];
// Have the view draw using the big_image
[big_image lockFocus];
[tmp_view drawRect: view_rect];
[big_image unlockFocus];
// Get bitmap representation
data2 = [big_image TIFFRepresentation];
[data2 writeToFile: [sheet filename] atomically: YES];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.