Well, it looks like I'm creating a PDFDocument where pixelWidth is wrong in the images I created. Therefore, the question arises: how to get the correct image resolution?
I start with raster data from the scanner. I'm doing it:
CGDataProviderRef provider= CGDataProviderCreateWithData(NULL (UInt8*)data, bytesPerRow * length, NULL);
CGImageRef cgImg = CGImageCreate (
width,
length,
bitsPerComponent,
bitsPerPixel,
bytesPerRow,
colorspace,
bitmapinfo,
provider,
NULL,
true,
kCGRenderingIntentDefault
);
NSData* imgData = [NSMutableData data];
CGImageDestinationRef dest = CGImageDestinationCreateWithData
(imgData, kUTTypeTIFF, 1, NULL);
CGImageDestinationAddImage(dest, cgImg, NULL);
CGImageDestinationFinalize(dest);
NSImage* img = [[NSImage alloc] initWithData: imgData];
there seems to be nowhere else to include the actual width / height in inches or points, as well as the actual resolution that I DO know at this moment ... how was I supposed to do this?
source
share