2
我有兩個CGImageRef,imgRef1和imgRef2。 我想創建一個具有這些CGImageRefs的兩個表示的NSImage(用於創建NSCursor)。爲此,我使用了BitMapRepresentation的initWithCGImage方法,然後將這些表示方法添加到NSImage中。但這不起作用。NSImage在Retina顯示器中添加代表問題
然後我試圖從imageRef1和imgRef2創建NSImage,然後使用TiffRepresentation從這些NSImage生成NSData,然後添加這些表示以最終獲得NSImage。但是這也是在視網膜顯示器中給出低分辨率圖像。 這是示例代碼:(任何幫助將不勝感激)
float aHotSpotX =(float)nHotSpotX; float aHotSpotY =(float)nHotSpotY;
NSSize nsSz;
nsSz.width = CGImageGetWidth(nLowImageRef);
nsSz.height = CGImageGetHeight(nLowImageRef);
NSImage* image = [[NSImage alloc] initWithSize:nsSz];
// Could have directly used NSBitmapImage initWithCGImage but some issues with that. Will revisit
NSImage *lImage = CreateNSImageFromCGImage(nLowImageRef);
NSData *lowData = [lImage TIFFRepresentation];
NSBitmapImageRep *lowRep = [NSBitmapImageRep imageRepWithData:lowData];
[image addRepresentation:lowRep];
NSImage *hImage = CreateNSImageFromCGImage(nHiImageRef);
NSData *hiData = [hImage TIFFRepresentation];
NSBitmapImageRep *hiRep = [NSBitmapImageRep imageRepWithData:hiData];
[image addRepresentation:hiRep];
NSCursor* aCursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(aHotSpotX, aHotSpotY)];
[image release];