0

有什么简单的方法吗?我正在尝试使用抖动将 PixelFormat 从 24 位图像转换为 16 位 RGB555(用于便携式设备)。我已经测试了很多方法:

他们都工作不佳。 http://msdn.microsoft.com/en-us/library/windows/desktop/ms536306(v=vs.85).aspx

我找到了一个 GDI+ 包装器,但缺少此功能。

谢谢!

4

1 回答 1

-1

您可以在构造函数中使用 Bitmap 类转换图像,传递转换格式的参数,它将使用您提到的 PixelFormat 渲染图像。

一些代码:

    public static Bitmap ConvertTo16bpp(Image img) {
    //you can also use Image.FromFile(fileName);//fileName can be absolute path of the image.
    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;
   }

建议

如果您有一些简单的要求,您可能不需要 AForge.NET(一个出色的图像处理库),您可以选择一个简单的解决方案,但这是您的决定。

链接

于 2014-01-10T07:18:48.867 回答