Gdiplus 64 位颜色
我正在创建一个 64 位位图并使用 Graphics 对象包装它以在其上绘制。 问题是 Gdiplus 颜色类只有 32 位(每个组件只有字节,即最大 255),那么如何使用 gdiplus 绘制 64 位图像? 例如
Bitmap bmp(100, 100, PixelFormat64bppARGB);
Graphics g(&bmp);
//how do I draw a red line now, if i use Color(255,0,0) it comes as almost dark black red
I am creating a 64bit bitmap and wrapping it using Graphics object to draw over it.
Problem is Gdiplus Color class is only 32bit(each component is byte only i.e.max 255) so how can I draw over a 64bit image using gdiplus?
e.g.
Bitmap bmp(100, 100, PixelFormat64bppARGB);
Graphics g(&bmp);
//how do I draw a red line now, if i use Color(255,0,0) it comes as almost dark black red
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来Gdiplus不支持任何64位操作。 仍然能够使用 Gdiplus 方法的一种简单方法是将图像分割为两个 32 位图像并分别对它们进行操作。
您可以将 ARGB 通道拆分为 AARR 和 GGBB,或者使用两个具有较低和较高 ARGB 位的 32 位图像。
这两种变体都需要您编写包装函数或将每个调用分成两部分,如下所示:
请注意,我在这里使用了 Color(A,R,G,B) 顺序,但我不确定。 根据 MSDN 文档,这必须是改为颜色(R,G,B,A)。 如果您不需要 alpha 通道,您应该更喜欢 highlow 变体,因为您仍然应该能够使用 Color(R,G,B) 。
要显示或保存结果,您需要合并 2 个缓冲区。
It seems Gdiplus doesn't support any 64-bit operations. An somehow easy way to still be able to use Gdiplus methods would be to split the image in two 32-bit images and operate on them seperately.
You could either split the ARGB channels into AARR and GGBB or use two 32-bit images with the lower and higher ARGB bits.
Both variants would need that you either write wrapping functions or split each call into two parts like this:
Note that I used Color(A,R,G,B) order here and I'm not sure about it. According to the MSDN documentation, this must be changed to Color(R,G,B,A) instead. If you won't need the alpha channel, you should prefer the highlow variant as you should still be able to use Color(R,G,B) with it.
To display or save the results, you'll need to merge the 2 buffers.
您不能根据 MSDN - 图像像素格式常量:
You can't according to MSDN - Image Pixel Format Constants:
您可以使用此位图构造函数来设置像素格式:
编辑:您将无法使用 Color 类(我认为),因为它仅支持 32 位颜色。 不过,您可以在位图上调用 LockBits 并手动循环遍历它。
You can use this Bitmap contructor to set the pixel format:
EDIT: You won't be able to use the Color class (I think) as it only supports 32 bit colors. You can however call LockBits on the Bitmap and loop through it manually.