ImageUtil Namespace Reference
Detailed Description
description of ImageUtil
|
Functions |
| bool | loadFile (const std::string &file, char *&buf, size_t &size) |
| | loads a file into memory, returns true if successful
|
|
void | releaseFile (char *buf, size_t size) |
| | releases memory from a previous call to loadFile, triggering munmap() or 'delete' as appropriate
|
| bool | decodeJPEG (char *inbuf, size_t inbufSize, size_t &width, size_t &height, size_t &channels, char *&outbuf, size_t &outbufSize, const std::string &filename="") |
| | decodes a JPEG image already in memory, returns true if successful
|
| bool | decodePNG (char *inbuf, size_t inbufSize, size_t &width, size_t &height, size_t &channels, char *&outbuf, size_t &outbufSize) |
| | decodes a PNG image already in memory, returns true if successful
|
| bool | decodeImage (char *inbuf, size_t inbufSize, size_t &width, size_t &height, size_t &channels, char *&outbuf, size_t &outbufSize) |
| | decodes an image already in memory -- if it looks like a PNG decodePNG() will be called, otherwise decodeJPEG(); returns true if successful
|
| bool | loadJPEG (const std::string &file, size_t &width, size_t &height, size_t &channels, char *&outbuf, size_t &outbufSize) |
| | decodes a JPEG from disk, returns true if successful
|
| bool | loadPNG (const std::string &file, size_t &width, size_t &height, size_t &channels, char *&outbuf, size_t &outbufSize) |
| | decodes a PNG from disk, returns true if successful
|
| bool | loadImage (const std::string &file, size_t &width, size_t &height, size_t &channels, char *&outbuf, size_t &outbufSize) |
| | decodes an image from file on disk -- if it looks like a PNG decodePNG() will be called, otherwise decodeJPEG(); returns true if successful
|
| size_t | encodeJPEG (char *inbuf, size_t inbufSize, size_t width, size_t height, size_t inbufChannels, char *&outbuf, size_t &outbufSize, size_t outbufChannels, int quality) |
| | encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
|
| size_t | encodeJPEG (char *inbuf, size_t inbufSize, size_t width, size_t height, size_t inbufChannels, char *&outbuf, size_t &outbufSize, size_t outbufChannels, int quality, jpeg_compress_struct &cinfo) |
| | encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
|
| size_t | encodeJPEG (char *inbuf, size_t inbufSize, size_t width, size_t height, size_t inbufChannels, char *&outbuf, size_t &outbufSize, size_t outbufChannels, int quality, unsigned int yskip, unsigned int uvskip, jpeg_compress_struct &cinfo) |
| | encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
|
| size_t | encodePNG (char *inbuf, size_t inbufSize, size_t width, size_t height, size_t inbufChannels, char *&outbuf, size_t &outbufSize, size_t outbufChannels) |
| | encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
|
Function Documentation
| bool ImageUtil::loadFile |
( |
const std::string & |
file, |
|
|
char *& |
buf, |
|
|
size_t & |
size | |
|
) |
| | |
loads a file into memory, returns true if successful
uses mmap unless LOADFILE_NO_MMAP is defined, in which case it uses 'new' and fread()
Definition at line 65 of file ImageUtil.cc.
Referenced by loadImage(), loadJPEG(), and loadPNG().
| bool ImageUtil::decodeJPEG |
( |
char * |
inbuf, |
|
|
size_t |
inbufSize, |
|
|
size_t & |
width, |
|
|
size_t & |
height, |
|
|
size_t & |
channels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize, |
|
|
const std::string & |
filename = "" | |
|
) |
| | |
decodes a JPEG image already in memory, returns true if successful
- Parameters:
-
| inbuf | input memory buffer containing compressed image |
| inbufSize | the size of inbuf allocation |
| width | the image width |
| height | the image height |
| channels | the number of color channels |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
| filename | optional parameter, used if warnings are raised |
If outbuf is pre-allocated and outbufSize is less than width*height*channels, the function will return false. (This is a handy way to read the image header only -- pass ((char*)NULL)-1 as outbuf and 0 for outbufSize, the function will return false after reading the header and filling in width, height, and channels) The image will be written in row order, with channels interleaved.
Definition at line 123 of file ImageUtil.cc.
Referenced by decodeImage(), and loadJPEG().
| bool ImageUtil::decodePNG |
( |
char * |
inbuf, |
|
|
size_t |
inbufSize, |
|
|
size_t & |
width, |
|
|
size_t & |
height, |
|
|
size_t & |
channels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize | |
|
) |
| | |
decodes a PNG image already in memory, returns true if successful
- Parameters:
-
| inbuf | input memory buffer containing compressed image |
| inbufSize | the size of inbuf allocation |
| width | the image width |
| height | the image height |
| channels | the number of color channels |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
If outbuf is pre-allocated and outbufSize is less than width*height*channels, the function will return false. (This is a handy way to read the image header only -- pass ((char*)NULL)-1 as outbuf and 0 for outbufSize, the function will return false after reading the header and filling in width, height, and channels) The image will be written in row order, with channels interleaved.
Definition at line 187 of file ImageUtil.cc.
Referenced by decodeImage(), and loadPNG().
| bool ImageUtil::decodeImage |
( |
char * |
inbuf, |
|
|
size_t |
inbufSize, |
|
|
size_t & |
width, |
|
|
size_t & |
height, |
|
|
size_t & |
channels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize | |
|
) |
| | |
decodes an image already in memory -- if it looks like a PNG decodePNG() will be called, otherwise decodeJPEG(); returns true if successful
- Parameters:
-
| inbuf | input memory buffer containing compressed image |
| inbufSize | the size of inbuf allocation |
| width | the image width |
| height | the image height |
| channels | the number of color channels |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
If outbuf is pre-allocated and outbufSize is less than width*height*channels, the function will return false. (This is a handy way to read the image header only -- pass ((char*)NULL)-1 as outbuf and 0 for outbufSize, the function will return false after reading the header and filling in width, height, and channels) The image will be written in row order, with channels interleaved.
Definition at line 272 of file ImageUtil.cc.
Referenced by loadImage().
| bool ImageUtil::loadJPEG |
( |
const std::string & |
file, |
|
|
size_t & |
width, |
|
|
size_t & |
height, |
|
|
size_t & |
channels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize | |
|
) |
| | |
decodes a JPEG from disk, returns true if successful
- Parameters:
-
| file | path to file to load |
| width | the image width |
| height | the image height |
| channels | the number of color channels |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
If outbuf is pre-allocated and outbufSize is less than width*height*channels, the function will return false. The image will be written in row order, with channels interleaved.
Definition at line 282 of file ImageUtil.cc.
| bool ImageUtil::loadPNG |
( |
const std::string & |
file, |
|
|
size_t & |
width, |
|
|
size_t & |
height, |
|
|
size_t & |
channels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize | |
|
) |
| | |
decodes a PNG from disk, returns true if successful
- Parameters:
-
| file | path to file to load |
| width | the image width |
| height | the image height |
| channels | the number of color channels |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
If outbuf is pre-allocated and outbufSize is less than width*height*channels, the function will return false. The image will be written in row order, with channels interleaved.
Definition at line 291 of file ImageUtil.cc.
| bool ImageUtil::loadImage |
( |
const std::string & |
file, |
|
|
size_t & |
width, |
|
|
size_t & |
height, |
|
|
size_t & |
channels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize | |
|
) |
| | |
decodes an image from file on disk -- if it looks like a PNG decodePNG() will be called, otherwise decodeJPEG(); returns true if successful
- Parameters:
-
| file | path to file to load |
| width | the image width |
| height | the image height |
| channels | the number of color channels |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
If outbuf is pre-allocated and outbufSize is less than width*height*channels, the function will return false. The image will be written in row order, with channels interleaved.
Definition at line 300 of file ImageUtil.cc.
| size_t ImageUtil::encodeJPEG |
( |
char * |
inbuf, |
|
|
size_t |
inbufSize, |
|
|
size_t |
width, |
|
|
size_t |
height, |
|
|
size_t |
inbufChannels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize, |
|
|
size_t |
outbufChannels, |
|
|
int |
quality | |
|
) |
| | |
encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
- Parameters:
-
| inbuf | input memory buffer containing the image |
| inbufSize | the size of inbuf allocation |
| width | the image width |
| height | the image height |
| inbufChannels | the number of color channels in the source image; either 1 (grayscale), or 3 (color) |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
| outbufChannels | the number of color channels desired in the destination image (only downsample from color to grayscale) |
| quality | how well to reproduce the image, 0-100 |
If outbuf is NULL, one of size  will be allocated for you. (just a heuristic size... note that this won't all be used, and can't entirely guarantee it'll be enough!)
If inbufChannels is 3, outbufChannels can be either 3 or 1. If 1, the first channel of inbuf is used. (pre-increment inbuf to use a different channel...) If inbufChannels is 1, outbufChannels must also be 1.
Definition at line 312 of file ImageUtil.cc.
Referenced by JPEGGenerator::calcImage(), and encodeJPEG().
| size_t ImageUtil::encodeJPEG |
( |
char * |
inbuf, |
|
|
size_t |
inbufSize, |
|
|
size_t |
width, |
|
|
size_t |
height, |
|
|
size_t |
inbufChannels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize, |
|
|
size_t |
outbufChannels, |
|
|
int |
quality, |
|
|
jpeg_compress_struct & |
cinfo | |
|
) |
| | |
encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
- Parameters:
-
| inbuf | input memory buffer containing the image |
| inbufSize | the size of inbuf allocation |
| width | the image width |
| height | the image height |
| inbufChannels | the number of color channels in the source image; either 1 (grayscale), or 3 (color) |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
| outbufChannels | the number of color channels desired in the destination image (only downsample from color to grayscale) |
| quality | how well to reproduce the image, 0-100 |
| cinfo | allows you to use a pre-allocated jpeg structure instead of having the function recreate it each time |
If outbuf is NULL, one of size  will be allocated for you. (just a heuristic size... note that this won't all be used, and can't entirely guarantee it'll be enough!)
If inbufChannels is 3, outbufChannels can be either 3 or 1. If 1, the first channel of inbuf is used. (pre-increment inbuf to use a different channel...) If inbufChannels is 1, outbufChannels must also be 1.
Definition at line 323 of file ImageUtil.cc.
| size_t ImageUtil::encodeJPEG |
( |
char * |
inbuf, |
|
|
size_t |
inbufSize, |
|
|
size_t |
width, |
|
|
size_t |
height, |
|
|
size_t |
inbufChannels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize, |
|
|
size_t |
outbufChannels, |
|
|
int |
quality, |
|
|
unsigned int |
yskip, |
|
|
unsigned int |
uvskip, |
|
|
jpeg_compress_struct & |
cinfo | |
|
) |
| | |
encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
- Parameters:
-
| inbuf | input memory buffer containing the image |
| inbufSize | the size of inbuf allocation |
| width | the image width |
| height | the image height |
| inbufChannels | the number of color channels in the source image; either 1 (grayscale), or 3 (color) |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
| outbufChannels | the number of color channels desired in the destination image (only downsample from color to grayscale) |
| quality | how well to reproduce the image, 0-100 |
| yskip | increment for the y channel |
| uvskip | increment for the u and v channels |
| cinfo | allows you to use a pre-allocated jpeg structure instead of having the function recreate it each time |
If outbuf is NULL, one of size  will be allocated for you. (just a heuristic size... note that this won't all be used, and can't entirely guarantee it'll be enough!)
If inbufChannels is 3, outbufChannels can be either 3 or 1. If 1, the first channel of inbuf is used. (pre-increment inbuf to use a different channel...) If inbufChannels is 1, outbufChannels must also be 1.
Definition at line 326 of file ImageUtil.cc.
| size_t ImageUtil::encodePNG |
( |
char * |
inbuf, |
|
|
size_t |
inbufSize, |
|
|
size_t |
width, |
|
|
size_t |
height, |
|
|
size_t |
inbufChannels, |
|
|
char *& |
outbuf, |
|
|
size_t & |
outbufSize, |
|
|
size_t |
outbufChannels | |
|
) |
| | |
encodes a JPEG from a pixel buffer into another memory buffer, returns number of bytes used, 0 if error
- Parameters:
-
| inbuf | input memory buffer containing the image |
| inbufSize | the size of inbuf allocation |
| width | the image width |
| height | the image height |
| inbufChannels | the number of color channels in the source image; either 1 (grayscale), or 3 (color); must match outbufChannels |
| outbuf | on input, a buffer to use for decompression; if NULL, a new buffer will be allocated and assigned |
| outbufSize | if outbuf is non-NULL, this should indicate the size of outbuf |
| outbufChannels | the number of color channels desired in the destination image; must match inbufChannels |
If outbuf is NULL, one of size  will be allocated for you. (just a heuristic size... note that this won't all be used, and can't entirely guarantee it'll be enough!)
Currently doesn't support changes in channels, so inbufChannels must match outbufChannels
Definition at line 424 of file ImageUtil.cc.
Referenced by PNGGenerator::calcImage().
|