好的,看来我正在创建一个 PDFDocument,其中我创建的图像中的 pixelWidth 不正确。所以问题就变成了:如何在图像中获得正确的分辨率?
我从扫描仪的位图数据开始。我正在这样做:
CGDataProviderRef provider= CGDataProviderCreateWithData(NULL (UInt8*)data, bytesPerRow * length, NULL);
CGImageRef cgImg = CGImageCreate (
width,
length,
bitsPerComponent,
bitsPerPixel,
bytesPerRow,
colorspace,
bitmapinfo, // ? CGBitmapInfo bitmapInfo,
provider, //? CGDataProviderRef provider,
NULL, //const CGFloat decode[],
true, //bool shouldInterpolate,
kCGRenderingIntentDefault // CGColorRenderingIntent intent
);
/* CGColorSpaceRelease(colorspace); */
NSData* imgData = [NSMutableData data];
CGImageDestinationRef dest = CGImageDestinationCreateWithData
(imgData, kUTTypeTIFF, 1, NULL);
CGImageDestinationAddImage(dest, cgImg, NULL);
CGImageDestinationFinalize(dest);
NSImage* img = [[NSImage alloc] initWithData: imgData];
那里似乎没有任何地方包含以英寸或点为单位的实际宽度/高度,也没有实际分辨率,我现在知道......我应该怎么做?