生成具有低比特深度的图像文件? [英] Generate image file with low bit depths?

查看:196
本文介绍了生成具有低比特深度的图像文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BPP =每像素位,所以32bpp的手段8/8/8/8的R / G / B / A。

bpp = bits per pixel, so 32bpp means 8/8/8/8 for R/G/B/A.

像.NET有一个枚举为这些System.Drawing.Imaging.PixelFormat。

Like .NET has an enum for these "System.Drawing.Imaging.PixelFormat".

现在,一旦我有一个位图图片与我的图形对象,如何将我把它保存到一个文件/什么格式,我会使用?

Now once I have a Bitmap or Image object with my graphics, how would I save it to a file / what format would I use?

什么图像文件格式(JPEG / GIF / PNG)支持低比特深度16bpp的一样或8bpp的(而不是通常的32bpp的24 bpp的或)

What image file format (JPEG/GIF/PNG) supports low bit-depths like 16bpp or 8bpp (instead of the usual 32bpp or 24bpp)

推荐答案

试试这个:

ImageCodecInfo pngCodec = ImageCodecInfo.GetImageEncoders().Where(codec => codec.FormatID.Equals(ImageFormat.Png.Guid)).FirstOrDefault();
if (pngCodec != null)
{
    EncoderParameters parameters = new EncoderParameters();
    parameters.Param[0] = new EncoderParameter(Encoder.ColorDepth, 8);
    myImage.Save(myStream, pngCodec, parameters);
}

这篇关于生成具有低比特深度的图像文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆