【发布时间】:2014-11-20 06:30:45
【问题描述】:
我有以下代码使用带有数据的数组创建位图*
//Here create the Bitmap to the know height, width and format
Bitmap bmp = new Bitmap( 5,7,PixelFormat.Format1bppIndexed);
//Create a BitmapData and Lock all pixels to be written
BitmapData bmpData = bmp.LockBits(
new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.WriteOnly, bmp.PixelFormat);
//Copy the data from the byte array into BitmapData.Scan0
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
//Unlock the pixels
bmp.UnlockBits(bmpData);
bmp.Save("BitMapIcon.bmp",ImageFormat.Bmp);
我的输入数组(数据):
byte[5] data = {0xff,0xff,0xff,0xff,0xff}
问题:
- 用于位图输入的数据数组* 是否只有每个像素的值(在此 格式是 0 和 1 ) ?
- 为什么要传递一些 0xff 值的数组 像素不是黑色的?
- 宽度大小可以小于 1 字节吗?
【问题讨论】:
-
按照惯例,黑色总是 0x00 或等效值。