epeg.c File Reference
Epeg JPEG Thumbnailer library. More...
Functions | |
EAPI Epeg_Image * | epeg_file_open (const char *file) |
Open a JPEG image by filename. | |
EAPI EAPI Epeg_Image * | epeg_memory_open (unsigned char *data, int size) |
Open a JPEG image stored in memory. | |
EAPI void | epeg_size_get (Epeg_Image *im, int *w, int *h) |
Return the original JPEG pixel size. | |
EAPI void | epeg_colorspace_get (Epeg_Image *im, int *space) |
Return the original JPEG pixel color space. | |
EAPI void | epeg_decode_size_set (Epeg_Image *im, int w, int h) |
Set the size of the image to decode in pixels. | |
EAPI void | epeg_decode_colorspace_set (Epeg_Image *im, Epeg_Colorspace colorspace) |
Set the colorspace in which to decode the image. | |
EAPI const void * | epeg_pixels_get (Epeg_Image *im, int x, int y, int w, int h) |
Get a segment of decoded pixels from an image. | |
EAPI const void * | epeg_pixels_get_as_RGB8 (Epeg_Image *im, int x, int y, int w, int h) |
Get a segment of decoded pixels from an image. | |
EAPI void | epeg_pixels_free (Epeg_Image *im, const void *data) |
Free requested pixel block from an image. | |
EAPI const char * | epeg_comment_get (Epeg_Image *im) |
Get the image comment field as a string. | |
EAPI void | epeg_thumbnail_comments_get (Epeg_Image *im, Epeg_Thumbnail_Info *info) |
Get thumbnail comments of loaded image. | |
EAPI void | epeg_comment_set (Epeg_Image *im, const char *comment) |
Set the comment field of the image for saving. | |
EAPI void | epeg_quality_set (Epeg_Image *im, int quality) |
Set the encoding quality of the saved image. | |
EAPI void | epeg_thumbnail_comments_enable (Epeg_Image *im, int onoff) |
Enable thumbnail comments in saved image. | |
EAPI void | epeg_file_output_set (Epeg_Image *im, const char *file) |
Set the output file path for the image when saved. | |
EAPI void | epeg_memory_output_set (Epeg_Image *im, unsigned char **data, int *size) |
Set the output file to be a block of allocated memory. | |
EAPI int | epeg_encode (Epeg_Image *im) |
This saves the image to its specified destination. | |
EAPI int | epeg_trim (Epeg_Image *im) |
FIXME: Document this. | |
EAPI void | epeg_close (Epeg_Image *im) |
Close an image handle. |
Detailed Description
Epeg JPEG Thumbnailer library.These routines are used for the Epeg library.
Function Documentation
EAPI void epeg_close | ( | Epeg_Image * | im | ) |
Close an image handle.
- Parameters:
-
im A handle to an opened Epeg image.
Referenced by epeg_file_open().
EAPI void epeg_colorspace_get | ( | Epeg_Image * | im, | |
int * | space | |||
) |
Return the original JPEG pixel color space.
- Parameters:
-
im A handle to an opened Epeg image. space A pointer to the color space value to be filled in.
EAPI const char* epeg_comment_get | ( | Epeg_Image * | im | ) |
Get the image comment field as a string.
- Parameters:
-
im A handle to an opened Epeg image.
- Returns:
- A pointer to the loaded image comments.
im
, if there is a comment, or NULL if no comment is saved with the image. Consider the string returned to be read-only.
EAPI void epeg_comment_set | ( | Epeg_Image * | im, | |
const char * | comment | |||
) |
Set the comment field of the image for saving.
- Parameters:
-
im A handle to an opened Epeg image. comment The comment to set.
comment
is NULL the output file will have no comment field.The default comment will be any comment loaded from the input file.
EAPI void epeg_decode_colorspace_set | ( | Epeg_Image * | im, | |
Epeg_Colorspace | colorspace | |||
) |
Set the colorspace in which to decode the image.
- Parameters:
-
im A handle to an opened Epeg image. colorspace The colorspace to decode the image in.
EAPI void epeg_decode_size_set | ( | Epeg_Image * | im, | |
int | w, | |||
int | h | |||
) |
Set the size of the image to decode in pixels.
- Parameters:
-
im A handle to an opened Epeg image. w The width of the image to decode at, in pixels. h The height of the image to decode at, in pixels.
EAPI int epeg_encode | ( | Epeg_Image * | im | ) |
This saves the image to its specified destination.
- Parameters:
-
im A handle to an opened Epeg image.
im
to its destination specified by epeg_file_output_set() or epeg_memory_output_set(). The image will be encoded at the deoded pixel size, using the quality, comment and thumbnail comment settings set on the image.retval 1 - error scale 2 - error encode 3 - error decode 4 - error decode ( setjmp )
EAPI Epeg_Image* epeg_file_open | ( | const char * | file | ) |
Open a JPEG image by filename.
- Parameters:
-
file The file path to open.
- Returns:
- A handle to the opened JPEG file, with the header decoded.
file
parameter, and attempts to decode it as a jpeg file. If this failes, NULL is returned. Otherwise a valid handle to an open JPEG file is returned that can be used by other Epeg calls.
The file
must be a pointer to a valid C string, NUL (0 byte) terminated thats is a relative or absolute file path. If not results are not determined.
See also: epeg_memory_open(), epeg_close()
References epeg_close().
EAPI void epeg_file_output_set | ( | Epeg_Image * | im, | |
const char * | file | |||
) |
Set the output file path for the image when saved.
- Parameters:
-
im A handle to an opened Epeg image. file The path to the output file.
file
must be a NUL terminated C string conatining the path to the file to be saved to. If it is NULL, the image will not be saved to a file when calling epeg_encode().
EAPI EAPI Epeg_Image* epeg_memory_open | ( | unsigned char * | data, | |
int | size | |||
) |
Open a JPEG image stored in memory.
- Parameters:
-
data A pointer to the memory containing the JPEG data. size The size of the memory segment containing the JPEG.
- Returns:
- A handle to the opened JPEG, with the header decoded.
data
, and that is size
bytes in size. If successful a valid handle is returned, or on failure NULL is returned.See also: epeg_file_open(), epeg_close()
EAPI void epeg_memory_output_set | ( | Epeg_Image * | im, | |
unsigned char ** | data, | |||
int * | size | |||
) |
Set the output file to be a block of allocated memory.
- Parameters:
-
im A handle to an opened Epeg image. data A pointer to a pointer to a memory block. size A pointer to a counter of the size of the memory block.
data
and the integer pointed to by size
will contain the pointer to the memory block and its size in bytes, respecitvely. The memory block can be freed with the free() function call. If the save fails the pointer to the memory block will be unaffected, as will the size.
EAPI void epeg_pixels_free | ( | Epeg_Image * | im, | |
const void * | data | |||
) |
Free requested pixel block from an image.
- Parameters:
-
im A handle to an opened Epeg image. data The pointer to the image pixels.
im
. data
must be a valid (non NULL) pointer to a pixel block taken from the image im
by epeg_pixels_get() and mustbe called before the image is closed by epeg_close().
EAPI const void* epeg_pixels_get | ( | Epeg_Image * | im, | |
int | x, | |||
int | y, | |||
int | w, | |||
int | h | |||
) |
Get a segment of decoded pixels from an image.
- Parameters:
-
im A handle to an opened Epeg image. x Rectangle X. y Rectangle Y. w Rectangle width. h Rectangle height.
- Returns:
- Pointer to the top left of the requested pixel block.
x
, y
w
X y
. The pixel block is packed with no row padding, and it organsied from top-left to bottom right, row by row. You must free the pixel block using epeg_pixels_free() before you close the image handle, and assume the pixels to be read-only memory.On success the pointer is returned, on failure, NULL is returned. Failure may be because the rectangle is out of the bounds of the image, memory allocations failed or the image data cannot be decoded.
EAPI const void* epeg_pixels_get_as_RGB8 | ( | Epeg_Image * | im, | |
int | x, | |||
int | y, | |||
int | w, | |||
int | h | |||
) |
Get a segment of decoded pixels from an image.
- Parameters:
-
im A handle to an opened Epeg image. x Rectangle X. y Rectangle Y. w Rectangle width. h Rectangle height.
- Returns:
- Pointer to the top left of the requested pixel block.
x
, y
w
X y
. The pixel block is packed with no row padding, and it organsied from top-left to bottom right, row by row. You must free the pixel block using epeg_pixels_free() before you close the image handle, and assume the pixels to be read-only memory.On success the pointer is returned, on failure, NULL is returned. Failure may be because the rectangle is out of the bounds of the image, memory allocations failed or the image data cannot be decoded.
EAPI void epeg_quality_set | ( | Epeg_Image * | im, | |
int | quality | |||
) |
Set the encoding quality of the saved image.
- Parameters:
-
im A handle to an opened Epeg image. quality The quality of encoding from 0 to 100.
The default quality is 75.
EAPI void epeg_size_get | ( | Epeg_Image * | im, | |
int * | w, | |||
int * | h | |||
) |
Return the original JPEG pixel size.
- Parameters:
-
im A handle to an opened Epeg image. w A pointer to the width value in pixels to be filled in. h A pointer to the height value in pixels to be filled in.
EAPI void epeg_thumbnail_comments_enable | ( | Epeg_Image * | im, | |
int | onoff | |||
) |
Enable thumbnail comments in saved image.
- Parameters:
-
im A handle to an opened Epeg image. onoff A boolean on and off enabling flag.
onoff
is 1, the output file will have thumbnail comments added to it, and if it is 0, it will not. The default is 0.
EAPI void epeg_thumbnail_comments_get | ( | Epeg_Image * | im, | |
Epeg_Thumbnail_Info * | info | |||
) |
Get thumbnail comments of loaded image.
- Parameters:
-
im A handle to an opened Epeg image. info Pointer to a thumbnail info struct to be filled in.
info
struct on return.
EAPI int epeg_trim | ( | Epeg_Image * | im | ) |
FIXME: Document this.
- Parameters:
-
im A handle to an opened Epeg image.