问题描述
我知道,.NET框架自带的图像转换类(System.Drawing.Image.Save法)。
I know that the .NET Framework comes with an image conversion class (the System.Drawing.Image.Save method).
但我需要一个转换24比特(R8G8B8)位图图像为16位(X1R5G5B5),我真的得到了对这种转换不知道,并在BMP标头中的24到16位的变化是行不通的(因为我们需要转换整个图像数据)。
But I need to convert a 24-bit (R8G8B8) bitmap image to a 16-bit (X1R5G5B5) and I really got no idea on this kind of conversion, and a 24-to-16-bit change in the bmp header wouldn't work (since we need to convert the entire image data).
此外,我想知道如果我能在图像抖动等控制。
Also I would like to know if I can control over the image Dither, etc.
想法?
任何形式的帮助,将不胜感激。
Ideas?Any kind of help would be appreciated.
推荐答案
该Format16bppRgb1555像素格式的声明,但GDI +实际上并不支持它。没有有史以来使用的像素格式主流视频驱动程序或图像编解码器。东西的GDI +设计师猜到的可能的已经发生了,他们的时间机器是不够准确。否则,从上System.Drawing中工作的程序员一个相当草率的复制/粘贴。
The Format16bppRgb1555 pixel format is declared but GDI+ doesn't actually support it. There is no main-stream video driver or image codec that ever used that pixel format. Something that the GDI+ designers guessed could have happened, their time machine wasn't accurate enough. Otherwise a pretty sloppy copy/paste from the programmer that worked on System.Drawing.
RGB555是可用的硬件和编解码器最匹配的:
Rgb555 is the closest match for available hardware and codecs:
public static Bitmap ConvertTo16bpp(Image img) {
var bmp = new Bitmap(img.Width, img.Height,
System.Drawing.Imaging.PixelFormat.Format16bppRgb555);
using (var gr = Graphics.FromImage(bmp))
gr.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height));
return bmp;
}
这篇关于转换24位BMP到16位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!