2008-09-19 30 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值,並且我讀取的像素被識別爲透明。