일단 해보니..
struct jpeg_decompress_struct 에
quantize_colors 항목을 TRUE로 설정해주면
colormap 에 팔레트가 생성이되고,
actual_number_of_colors 에는 실제 사용한 색상수 출력이 된다고 하는데..
팔레트가 어떻게 되는지 libjpeg.doc에 제대로 나와있지 않다..
아래의 링크를 조금은 유심히 보고 수정요망
After this call, the final output image dimensions, including any requested
scaling, are available in the JPEG object; so is the selected colormap, if
colormapped output has been requested. Useful fields include
output_width image width and height, as scaled
output_height
out_color_components # of color components in out_color_space
output_components # of color components returned per pixel
colormap the selected colormap, if any
actual_number_of_colors number of entries in colormap
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.
Typically you will need to allocate data buffers to hold the incoming image.
You will need output_width * output_components JSAMPLEs per scanline in your
output buffer, and a total of output_height scanlines will be returned.
Note: if you are using the JPEG library's internal memory manager to allocate
data buffers (as djpeg does), then the manager's protocol requires that you
request large buffers *before* calling jpeg_start_decompress(). This is a
little tricky since the output_XXX fields are not normally valid then. You
can make them valid by calling jpeg_calc_output_dimensions() after setting the
relevant parameters (scaling, output color space, and quantization flag).
...
The decompression parameters that determine the basic properties of the
returned image are:
J_COLOR_SPACE out_color_space
Output color space. jpeg_read_header() sets an appropriate default
based on jpeg_color_space; typically it will be RGB or grayscale.
The application can change this field to request output in a different
colorspace. For example, set it to JCS_GRAYSCALE to get grayscale
output from a color file. (This is useful for previewing: grayscale
output is faster than full color since the color components need not
be processed.) Note that not all possible color space transforms are
currently implemented; you may need to extend jdcolor.c if you want an
unusual conversion.
...
boolean quantize_colors
If set TRUE, colormapped output will be delivered. Default is FALSE,
meaning that full-color output will be delivered.
...
When quantize_colors is TRUE, the target color map is described by the next
two fields. colormap is set to NULL by jpeg_read_header(). The application
can supply a color map by setting colormap non-NULL and setting
actual_number_of_colors to the map size. Otherwise, jpeg_start_decompress()
selects a suitable color map and sets these two fields itself.
[Implementation restriction: at present, an externally supplied colormap is
only accepted for 3-component output color spaces.]
JSAMPARRAY colormap
The color map, represented as a 2-D pixel array of out_color_components rows and actual_number_of_colors columns. Ignored if not quantizing.
CAUTION: if the JPEG library creates its own colormap, the storage
pointed to by this field is released by jpeg_finish_decompress().
Copy the colormap somewhere else first, if you want to save it.
int actual_number_of_colors
The number of colors in the color map.
...
int out_color_components Number of color components in out_color_space.
int output_components Number of color components returned.
[출처 : libjpeg.doc]
|
[링크 :
http://svn.neurostechnology.com/filedetails.php]
[링크 :
http://www.koders.com/c/fid95CCE6190079AB3FDDE3C71309BA75EB5BA943FC.aspx]