我实际上是在使用libjpeg读取和保存JPEG图像。
那么首先是像素大小(info.output_components;
)的可能性是什么?
颜色空间(info.out_color_space;
)有什么可能性?
JPEG图像可以具有alpha通道吗?
我也在使用libpng。
那么首先是什么位深度(png_get_bit_depth(png, info);
)?
什么是颜色类型(png_get_color_type(png, info);
)?
谢谢!
答案 0 :(得分:1)
那么首先像素尺寸(info.output_components;)有什么可能性?
从doc
output_components
在对颜色进行量化时为1(颜色图索引);否则 等于out_color_components
。将是JSAMPLE值的数量 输出数组中每个像素发射的光。
int out_color_components; /* # of color components in out_color_space */
int output_components; /* # of color components returned */
/* output_components is 1 (a colormap index) when quantizing colors;
* otherwise it equals out_color_components.
色彩空间(
info.out_color_space;
)有什么可能性?
JCS_UNKNOWN, /* error/unspecified */
JCS_GRAYSCALE, /* monochrome */
JCS_RGB, /* red/green/blue as specified by the RGB_RED,
RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros */
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
JCS_CMYK, /* C/M/Y/K */
JCS_YCCK, /* Y/Cb/Cr/K */
JCS_EXT_RGB, /* red/green/blue */
JCS_EXT_RGBX, /* red/green/blue/x */
JCS_EXT_BGR, /* blue/green/red */
JCS_EXT_BGRX, /* blue/green/red/x */
JCS_EXT_XBGR, /* x/blue/green/red */
JCS_EXT_XRGB, /* x/red/green/blue */
/* When out_color_space it set to JCS_EXT_RGBX, JCS_EXT_BGRX, JCS_EXT_XBGR,
or JCS_EXT_XRGB during decompression, the X byte is undefined, and in
order to ensure the best performance, libjpeg-turbo can set that byte to
whatever value it wishes. Use the following colorspace constants to
ensure that the X byte is set to 0xFF, so that it can be interpreted as an
opaque alpha channel. */
JCS_EXT_RGBA, /* red/green/blue/alpha */
JCS_EXT_BGRA, /* blue/green/red/alpha */
JCS_EXT_ABGR, /* alpha/blue/green/red */
JCS_EXT_ARGB, /* alpha/red/green/blue */
JCS_RGB565 /* 5-bit red/6-bit green/5-bit blue */
JPEG图像可以具有Alpha通道吗?
从上面的源代码中可以看到,libjpeg-turbo确实支持jpeg的alpha通道。
那么首先是什么位深度(
png_get_bit_depth(png, info);
)?
简而言之,用于表示图像中每个像素的位数。位深度越高,每个像素可以包含的颜色越多。
来自PNG Spec:
颜色类型是一个单字节整数,用于描述图像数据的解释。颜色类型代码表示以下值的总和:1(使用调色板),2(使用颜色)和4(使用alpha通道)。有效值为0、2、3、4和6。
Color Allowed Interpretation Type Bit Depths 0 1,2,4,8,16 Each pixel is a grayscale sample. 2 8,16 Each pixel is an R,G,B triple. 3 1,2,4,8 Each pixel is a palette index; a PLTE chunk must appear. 4 8,16 Each pixel is a grayscale sample, followed by an alpha sample. 6 8,16 Each pixel is an R,G,B triple, followed by an alpha sample.