'프로그램 사용/libjpeg'에 해당되는 글 12건

  1. 2009.05.18 libjpeg 사용예제 2
  2. 2009.05.15 libjpeg 사용시 color depth 4
프로그램 사용/libjpeg2009. 5. 18. 00:54
int w = cinfo.image_width;
int h = cinfo.image_height;
int d = cinfo.jpeg_color_space;
int out_h = cinfo.output_height;

printf("width:%d height:%d depth:%d out_height:%d\n", w, h ,d, out_h);

unsigned char *data = new unsigned char[w * h * d];
while (cinfo.output_scanline < cinfo.output_height)
{
	jpeg_read_scanlines(&cinfo, &data, 1);
	data += d * cinfo.output_width;
}

jpeg_read_header() 한뒤
jpeg_read_scanline()까지는 알았지만, 문서를 대충 읽다 보니..
도무니 어떻게 메모리를 할당해야 할지 감이 안 잡혔는데..
이 문서를 보니 어떻게 하면 될꺼 같다라는 감이 조금은 온다..
내일 해보고 결과를 적도록 해야겠다.
위에서 대로 전체 할당하고 jpeg_read_scanlines로 읽어 오니 잘된다!

[링크 : http://www.korone.net/bbs/board.php?bo_table=etc_misc&wr_id=168]
Posted by 구차니
프로그램 사용/libjpeg2009. 5. 15. 20:40
Subject: [21] What if I need more than 8-bit precision?

Baseline JPEG stores images with 8 bits per color sample, in other words

24 bits per pixel for RGB images
,
8 bits/pixel for grayscale,
32 bits/pixel for CMYK, etc.

There is an extension that stores 12 bits/sample for applications that need higher accuracy.
Medical images, for example, are often 12-bit grayscale.  The 12-bit extension is not very widely supported,
however.  One package that does support it is the free IJG source code (see part 2, item 15).

For lossless JPEG, the standard permits any data precision between 2 and 16 bits per sample,
but high-precision lossless JPEG is even less widely supported than high-precision lossy JPEG.
The Stanford PVRG codec (see part 2, item 15) reportedly supports up to 16 bits/sample for lossless JPEG.

[링크 : http://www.faqs.org/faqs/jpeg-faq/part1/]




struct jpeg_decompress_struct {
  JDIMENSION image_width;    /* nominal image width (from SOF marker) */
  JDIMENSION image_height;    /* nominal image height */
  int num_components;        /* # of color components in JPEG image */
  J_COLOR_SPACE out_color_space; /* colorspace for output */
  UINT16 X_density;        /* Horizontal pixel density */
  UINT16 Y_density;        /* Vertical pixel density */
};

typedef enum {
    JCS_UNKNOWN,        /* error/unspecified */
    JCS_GRAYSCALE,        /* monochrome */
    JCS_RGB,        /* red/green/blue */
    JCS_YCbCr,        /* Y/Cb/Cr (also known as YUV) */
    JCS_CMYK,        /* C/M/Y/K */
    JCS_YCCK        /* Y/Cb/Cr/K */
} J_COLOR_SPACE;

순서는 조금 뒤바뀌지만, 윈도우에서 출력되는 데이터는 위의 6개로 거의 표기가 가능하다.
Posted by 구차니