Output Function

User defined output function to write decompressed pixels to the output device.

int out_func (
  JDEC* jdec,    /* Pointer to the decompression object */
  void* bitmap,  /* Bitmap to be output */
  JRECT* rect    /* Rectangle to output */
);

Parameters

jdec
Decompression object of this session.
bitmap
Decompressed image to be output.
rect
Specifies output rectangle where in the image. Type is defined in tjpgd.h

Return Values

Normally returns 1. It lets TJpgDec to continue the decompressing process. If a 0 is returned, jd_decomp function aborts with JDR_INTR. This is useful to interrupt the decompression process.

Description

This function is the data output interface of the TJpgDec module. The corresponding decompression session can be identified by the session identifier jdec->device passed to the 5th argument of jd_prepare function.

The bitmap is sent to the frame buffer or display device in this function. The first pixel in the bitmap is the left-top of the rectangle, the second one is next right and last pixel is the bottom-right of the rectangle. Because the JPEG image is compressed and streamed in unit of MCU (Minimum Coded Unit), TJpgDec outputs the image in MCU by MCU. The size of MCU depends on the sampling factor of JPEG compression, typically in 8x8, 16x8 or 16x16, but the rectangles on right end and bottom end of the image will be cropped.

The output pixel format is defined by JD_FORMAT option in the tjpgdcnf.h as shown below.

JD_FORMATPixel Format
0 (RGB888)uint8_t bitmap[] = {R1, G1, B1, R2, G2, B2, ....
1 (RGB565)uint16_t bitmap[] = {rrrrrggggggbbbbb, ....
2 (Grayscale)uint8_t bitmap[] = {Y1, Y2, Y3, ....

Return