C# PictureBox怎么显示BitMapSource数据图片??????

2025-03-04 11:55:50
推荐回答(3个)
回答1:

不知道BitMapSource是什么类型,只能给一些可能有帮助的提示
Bitmap bm = new Bitmap();
pictureBox1.Image = Image.FromHbitmap(bm.GetHbitmap());

回答2:

// Define parameters used to create the BitmapSource.
PixelFormat pf = PixelFormats.Bgr32;
int width = 200;
int height = 200;
int rawStride = (width * pf.BitsPerPixel + 7) / 8;
byte[] rawImage = new byte[rawStride * height];

// Initialize the image with data.
Random value = new Random();
value.NextBytes(rawImage);

// Create a BitmapSource.
BitmapSource bitmap = BitmapSource.Create(width, height,
96, 96, pf, null,
rawImage, rawStride);

// Create an image element;
Image myImage = new Image();
myImage.Width = 200;
// Set image source.
myImage.Source = bitmap;

回答3:

http://msdn.microsoft.com/zh-cn/library/vstudio/system.windows.media.imaging.bitmapsource(v=vs.110).aspx