将图像转换为像素格式-c#
我对下面的代码有问题。我能够将图像转换成我想要的像素格式。但问题是,当我为我的picturebox使用位图时,它只是黑色的将图像转换为像素格式-c#,c#,image,format,pixel,C#,Image,Format,Pixel,我对下面的代码有问题。我能够将图像转换成我想要的像素格式。但问题是,当我为我的picturebox使用位图时,它只是黑色的 sourceImage = new Bitmap(sourceImage.Width, sourceImage.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); pictureBoxCurrency.Image = sourceImage; 您已经创建了新位图,但需要将图像从原始位图绘制(传输)到新位
sourceImage = new Bitmap(sourceImage.Width, sourceImage.Height,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
pictureBoxCurrency.Image = sourceImage;
您已经创建了新位图,但需要将图像从原始位图绘制(传输)到新位图
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;