NSBitmapImageRep を指定されたサイズにサイズ変更することを目的とした、次の目的の C 関数があります。
現在、サイズが 2048x1536 の画像を操作して 300x225 にサイズ変更しようとすると、この関数はサイズ 600x450 の NSBitmapImageRep を返し続けます。
- (NSBitmapImageRep*) resizeImageRep: (NSBitmapImageRep*) anOriginalImageRep toTargetSize: (NSSize) aTargetSize
{
NSImage* theTempImageRep = [[[NSImage alloc] initWithSize: aTargetSize ] autorelease];
[ theTempImageRep lockFocus ];
[NSGraphicsContext currentContext].imageInterpolation = NSImageInterpolationHigh;
NSRect theTargetRect = NSMakeRect(0.0, 0.0, aTargetSize.width, aTargetSize.height);
[ anOriginalImageRep drawInRect: theTargetRect];
NSBitmapImageRep* theResizedImageRep = [[[NSBitmapImageRep alloc] initWithFocusedViewRect: theTargetRect ] autorelease];
[ theTempImageRep unlockFocus];
return theResizedImageRep;
}
それをデバッグすると、theTargetRect が適切なサイズであることがわかりますが、initWithFocusedRec への呼び出しは 600x450 ピクセル (高さ x 幅) のビットマップを返します
なぜこれが起こっているのか、私は完全に途方に暮れています。誰にも洞察力がありますか?