libjpeg 和 libpng 中的这些属性是什么?
What are this properties in libjpeg and in libpng?
我实际上是在使用 libjpeg 来读取和保存 JPEG 图像。
那么首先像素大小 (info.output_components;
) 的可能性是多少?
颜色 space (info.out_color_space;
) 的可能性有哪些?
JPEG 图像可以有 alpha 通道吗?
我也在用libpng。
那么首先位深度是多少 (png_get_bit_depth(png, info);
) ?
什么是颜色类型(png_get_color_type(png, info);
)?
谢谢!
So first what are the possibilities of pixel size (info.output_components;) ?
来自doc
output_components
is 1 (a colormap index) when quantizing colors; otherwise it
equals out_color_components
. It is the number of JSAMPLE values that will be
emitted per pixel in the output arrays.
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.
What are the possibilities of color space (info.out_color_space;
) ?
来自source
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 */
And can a JPEG image have an alpha channel ?
从上面的源代码可以看出,libjpeg-turbo 确实支持 jpeg 的 alpha 通道。
So first what is the bit depth (png_get_bit_depth(png, info);
) ?
简单地说,就是用来表示图像中每个像素的位数。位深度越高,每个像素可以包含的颜色越多。
来自PNG Spec:
Color type is a single-byte integer that describes the interpretation of the image data. Color type codes represent sums of the following values: 1 (palette used), 2 (color used), and 4 (alpha channel used). Valid values are 0, 2, 3, 4, and 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.
我实际上是在使用 libjpeg 来读取和保存 JPEG 图像。
那么首先像素大小 (info.output_components;
) 的可能性是多少?
颜色 space (info.out_color_space;
) 的可能性有哪些?
JPEG 图像可以有 alpha 通道吗?
我也在用libpng。
那么首先位深度是多少 (png_get_bit_depth(png, info);
) ?
什么是颜色类型(png_get_color_type(png, info);
)?
谢谢!
So first what are the possibilities of pixel size (info.output_components;) ?
来自doc
output_components
is 1 (a colormap index) when quantizing colors; otherwise it equalsout_color_components
. It is the number of JSAMPLE values that will be emitted per pixel in the output arrays.
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.
What are the possibilities of color space (
info.out_color_space;
) ?
来自source
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 */
And can a JPEG image have an alpha channel ?
从上面的源代码可以看出,libjpeg-turbo 确实支持 jpeg 的 alpha 通道。
So first what is the bit depth (
png_get_bit_depth(png, info);
) ?
简单地说,就是用来表示图像中每个像素的位数。位深度越高,每个像素可以包含的颜色越多。
来自PNG Spec:
Color type is a single-byte integer that describes the interpretation of the image data. Color type codes represent sums of the following values: 1 (palette used), 2 (color used), and 4 (alpha channel used). Valid values are 0, 2, 3, 4, and 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.