2008-09-19 23 views

回答

20

Bitmap类从System.Drawing.dll程序组件:

Bitmap bitmap = new Bitmap(@"C:\image.png"); 
Color clr = bitmap.GetPixel(0, 0); 
1

那么,位图类可以读取PNG文件并访问像素。它可以看到透明的像素? PNG支持透明,而BMP不支持。但是,它仍然有效。

Bitmap bitmap = new Bitmap("icn_loading_animated3a.png"); 
pictureBox1.Image = bitmap; 
Color pixel5by10 = bitmap.GetPixel(5, 10); 

上面的代码读取我的小图片,然后读取透明像素。颜色类别具有RGBA值,并且我读取的像素被识别为透明。