显示图片框双阵列 [英] Display double array in picturebox

查看:163
本文介绍了显示图片框双阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在C#中显示该阵列的两倍图片框

I need to display this array of double in picture box in C#

double[,] Y1 = new double[width, height];//not empty array contain brightness from RGB
 R = new byte [width, height];
 G = new byte [width, height];
 B = new byte [width, height];

Bitmap bmp4 = new Bitmap(width, height);    


for (int x = 0; x < width; x++)
{
    for (int y = 0; y < height; y++)
    {
        Y1[x, y] = (0.39 * R[x,y]) + (0.59 * G[x,y]) + (0.12 * B[x,y]);
        Int32 zz = Convert.ToInt32(Y1[x, y]);

        bmp4.SetPixel(x, y, zz);
    }
}    

pictureBox6.Image=bmp4;

我用这个code显示,但无法正常工作是有显示阵列其他方法
双(亮度)在图片框(bmp文件)

I use this code for display but not work is there other method for display array of double(Brightness) in picture box (bmp file)

推荐答案

您不能直接从整数转换为彩色。使用 Col​​or.FromArgb()允许你指定颜色的整数值。

You can't cast directly from integer to color. Using Color.FromArgb() allows you to specify an integer value for color.

FromArgb()需要一个32位的整数,其中每个字节重新presents Alpha,红,绿,蓝(ARGB因此)中的一个。请记住,如果你想与一半以上的不透明度(阿尔法)值的像素,您通过整数将需要为负值。

FromArgb() takes a 32 bit integer where each byte represents one of Alpha, Red, Green, Blue (hence Argb). Keep in mind that if you want any pixel with more than half opacity (Alpha) value, your passed integer will need to be a negative value.

如果你没有在你的Y1阵列的负值,你将要申请做 FromArgb()转换时以下。

If you don't have any negative values in your Y1 array, you will want to apply the following when doing the FromArgb() conversion.

颜色[X,Y] = Color.FromArgb(ZZ |(255&LT;&LT; 24))

希望有所帮助。

这篇关于显示图片框双阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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