我在NSImage和NSBitmapImageRep之间切换(因为只有NSBitmapImageRep允许我按像素查找和替换颜色,但只有NSImages可以在NSImageView/NSImageCell的setImage中使用)。我知道如何将NSImage转换为NSBitmapImageRep (使用D9),但不能进行相反的操作,因为D10是只读的。那么,如何将D11转换为D12
带着希望,
radzo73
发布于 2021-05-28 22:20:47
要从修改后的NSBitmapImageRep中获取NSImage,我只需调用一个方法:
NSImage *image = [[NSImage alloc] initWithSize:someSize];
[...]
NSBitmapImageRep *rawImage = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]];
[code that gets and sets pixels]
[image initWithCGImage:[rawImage CGImage] size:image.size]; // overwrite original NSImage with modified onehttps://stackoverflow.com/questions/63674431
复制相似问题