见下面的函数,注意的是图像的宽度应该是4的整数倍。
void dataToBitmap(double[] data, out Bitmap bitmap,int width,int height)
{
byte[] bmpData=new byte[width*height*3];
for (int i = 0; i < width * height * 3; i++)
{
bmpData[i] =(byte)( data[i] * 255);
}
unsafe
{
fixed (byte* pBmpData = bmpData)
{
bitmap = new Bitmap(width, height, width * 3, System.Drawing.Imaging.PixelFormat.Format24bppRgb, (IntPtr)pBmpData);// bitmapData.Scan0);
}
}
}
C#之BitmapData应用2 由数据转换为Bitmap图像
最新推荐文章于 2025-05-31 21:34:00 发布