int tsmJPEGCompressTile ( unsigned char *tileBuffer, unsigned char *jpegBuffer, TileTspec *tile, int quality_level ) JPEG compress a raw tile in memory
JPEG compress a raw tile in memory.This function will accept two pointers to tile buffers that have already been allocated (e.g. with tsmMakeTileBuffer). The tileBuffer contains a raw bitmap, whilst the jpegBuffer will be filled by this function and will contain the JPEG compressed version of the raw data. The function returns the size of the JPEG compressed data that was written to jpegBuffer (in bytes).
A few things to note about this function:
- The raw data will undergo an implicit colour space conversion into the YCbCr space. This is required for compatibility with the JFIF de-facto standard.
- The origin of the JPEG compressed data will be the top-left corner of the tile, rather than the bottom-left corner as used by TV. Again this is required for conformance with JFIF.
- The JPEG compressed data is not a complete JFIF stream, i.e. it does not have the M_SOI and M_APP0 markers at the start.
N.B. this function outputs exactly the same JPEG files (size, data, tables, etc.) as the libtiff library routines. However this routine is slightly more efficient because it compresses the data in reverse order for you so you don't have to vertically flip the input buffer before compressing.