我想从 Metro Apps 中的像素字节数组创建位图。较早的以下功能用于相同的用途:
//Here create the Bitmap to the know height, width and format
Bitmap bmp = new Bitmap( 352, 288, PixelFormat.Format24bppRgb);
//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);
//Return the bitmap
return bmp;
但现在 Windows 8 中不存在 BitmapData 类。请建议任何替代方式。
谢谢,潘卡伊