Is it possible to make a NSBitmapImageRep with 24 bpp and no alpha channel?

独自空忆成欢 提交于 2019-11-29 11:41:02

Nope. The formats that Quartz supports are listed here, and like the error message you got said, 24-bit without alpha is not one of them. Since AppKit's drawing APIs are built on top of Quartz, that list applies to AppKit, too.

The best you can do is fill your context with a solid color, such as [NSColor blackColor], before you draw whatever you want to draw. You'll still have an alpha channel in the context, but no actual transparency.

To Clarify, NSBitmapImageRep does supports 24 Bits/pixel. However, NSGraphicsContext does not support this format. Apparently an alpha channel is always required by the Quartz drawing system.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!