开发者

converting images to pixel formats - c#

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜