2014-01-08 30 views
-1

我写为显示Y1(亮度)这个代码在图片框显示:图像不是在图片框

R = new byte [width, height];// R,G,B not empty contain data 

G = new byte [width, height]; 

B = new byte [width, height]; 

Y1 = new double[width, height]; 

Bitmap bmp4 = new Bitmap(width, height); 
Int32 zz; 

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]); 

    zz = Convert.ToInt32(Y1[x, y]); 

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

当我执行此代码图片框空不显示图像,为什么? 这个代码在C#和图像的类型是位图

+1

重复的[this](http://stackoverflow.com/questions/20974290/display-double-array-in-picturebox?rq=1)和[this](http://stackoverflow.com/questions/ 20978085/convert-each-location-from-array-of-double-rq = 1)并且可能[this](http://stackoverflow.com/questions/20974290/display-double-array-in- picturebox?rq = 1) – venerik

+0

@ venerik-虽然它的复制,但在那些问题没有答案..所以这个问题是正确的... ... –

回答

0

我还没有完全有时间看这个,但问题似乎是你将字节转换为颜色(设置每个像素为Color.Red ,例如,工作正常)。

当然,我也假设你正在你的代码之后调用此:

picturebox.Image = bmp4; 

Color.FromArgb预计INT32还含有阿尔法数据,我怀疑是你的问题所在。