开发者

converting images to pixel formats - c#

开发者 https://www.devze.com 2023-04-01 14:38 出处:网络
I have a problem with the code below. I was able to convert the image into the pixel format I want. But the problem is that when I use the bitmap for my picturebox, its just black.

I have a problem with the code below. I was able to convert the image into the pixel format I want. But the problem is that when I use the bitmap for my picturebox, its just black.

sourceImage = new Bitmap(sourceImage.Width, sourceImage.Height,
System.Drawing.Imaging.PixelFormat.Format24bppRgb开发者_开发百科);

pictureBoxCurrency.Image = sourceImage;


You have created the new bitmap, but you need to paint the image (transfer) from the original one to the new one.

Bitmap newBitmap = new Bitmap(sourceImage.Size.Width, sourceImage.Size.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(newBitmap);
g.DrawImage(sourceImage, new Point(0, 0));
g.Dispose();

pictureBoxCurrency.Image = sourceImage;
0

精彩评论

暂无评论...
验证码 换一张
取 消