如何在Color.FromArgb方法中使用16位红色,16位绿色,16位蓝色和16位Alpha值 [英] how to use 16-bit Red, 16-bit Green, 16-bit Blue and 16-bit Alpha values in Color.FromArgb method

查看:650
本文介绍了如何在Color.FromArgb方法中使用16位红色,16位绿色,16位蓝色和16位Alpha值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个值,分别为16位:红色,绿色,蓝色和alpha。我正在尝试在Color.FromArgb方法中使用这些值来创建新颜色。但是我得到一个异常,因为Red值应该介于0到255之间。但是我需要为每个红色,绿色,蓝色和alpha颜色创建一个16位值的位图图像..请尽快帮助我

I''m having 4 values of 16bit each: red, green, blue and alpha respectively. I''m trying to use these values in Color.FromArgb method to create a new color. But I''m getting an exception as Red value should be between 0 to 255. but i need to create a bitmap image with 16bit value for each of red, green, blue and alpha colors.. please help me as soon as possible

推荐答案

每位的实际信息取决于 PixelFormat http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx [ ^ ] 。







正如Philippe Mori在评论中正确指出的, Color 类型不能用于解决这个问题,它只用于每个颜色组件使用8位的像素格式。



[结束编辑]



您可以立即填写像素存储器y像素格式使用 System.Drawing.LockBits

http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx [ ^ ]。



此外,这是性能最佳的。 WPF也有类似的方法。



-SA
The actual information per bit depends on the PixelFormat: http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx[^].



As Philippe Mori correctly pointed out in his comment, Color type cannot be used to solve this problem, it is designed to serve only the pixel formats using 8 bits per color component.

[END EDIT]

You can immediately fill in the pixel memory for any pixel format by using System.Drawing.LockBits:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[^].

Also, this is the best for performance. WPF also has similar approach.

—SA


这篇关于如何在Color.FromArgb方法中使用16位红色,16位绿色,16位蓝色和16位Alpha值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆