'RGBTRIPLE'에 해당되는 글 1건

  1. 2009.05.19 libjpeg - jmorecfg.h
프로그램 사용/libjpeg2009. 5. 19. 00:40
/*
 * Ordering of RGB data in scanlines passed to or from the application.
 * If your application wants to deal with data in the order B,G,R, just
 * change these macros.  You can also deal with formats such as R,G,B,X
 * (one extra byte per pixel) by changing RGB_PIXELSIZE.  Note that changing
 * the offsets will also change the order in which colormap data is organized.
 * RESTRICTIONS:
 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
 * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
 *    useful if you are using JPEG color spaces other than YCbCr or grayscale.
 * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
 *    is not 3 (they don't understand about dummy color components!).  So you
 *    can't use color quantization if you change that value.
 */
#define RGB_RED		0	/* Offset of Red in an RGB scanline element */
#define RGB_GREEN	1	/* Offset of Green */
#define RGB_BLUE	2	/* Offset of Blue */
#define RGB_PIXELSIZE	3	/* JSAMPLEs per RGB scanline element */

libjpeg를 일반적인 표준 Bitmap 파일에 적용하기 위해서는 (혹은 Blit 함수에)
RGBQUADRGBTRIPLE과 동일한 구조로 나오는 것이 좋다.

typedef struct tagRGBQUAD { 
  BYTE rgbBlue;
  BYTE rgbGreen;
  BYTE rgbRed;
  BYTE rgbReserved;
} RGBQUAD;

typedef struct tagRGBTRIPLE { 
  BYTE rgbtBlue; 
  BYTE rgbtGreen; 
  BYTE rgbtRed;
} RGBTRIPLE;

이런 이유로 설정값을 바꾸지 않고 그냥 libjpeg를 사용하게 되면,
변환후에 RGB를 일일이 순서를 바꾸어 주어야 한다.

제약사항으로는
sample application인 djpeg cjpeg 는 적용이 되지 않고(어짜피 BGR로 표준 bitmap 포맷으로 나온다..)
YCbCr(YUV) <-> RGB 변환에만 적용이 된다는 것(JPEG가 YUV 아닌게 있던가?)
color quantizer는 RGBTIPLE(24bit)만 적용되지 RGBQUAD(32bit)는 적용되지 않는다.

솔찍히 먼소리인지 모르겠고.. 실질적으로 YUV->RGB 변환만 한다면 무시해도 될 듯하다.
Posted by 구차니