Haru Free PDF Library
Images

Functions

HPDF_Image HPDF_LoadPngImageFromMem (HPDF_Doc pdf, const HPDF_BYTE *buf, HPDF_UINT size)
 Load PNG image from buffer. More...
 
HPDF_Image HPDF_LoadPngImageFromFile (HPDF_Doc pdf, const char *filename)
 Load external PNG image file. More...
 
HPDF_Image HPDF_LoadPngImageFromFile2 (HPDF_Doc pdf, const char *filename)
 Load external PNG image file. More...
 
HPDF_Image HPDF_LoadJpegImageFromFile (HPDF_Doc pdf, const char *filename)
 Load external JPEG image file. More...
 
HPDF_Image HPDF_LoadJpegImageFromMem (HPDF_Doc pdf, const HPDF_BYTE *buf, HPDF_UINT size)
 Load JPEG image from buffer. More...
 
HPDF_Image HPDF_LoadRawImageFromFile (HPDF_Doc pdf, const char *filename, HPDF_UINT width, HPDF_UINT height, HPDF_ColorSpace color_space)
 Load raw format image. More...
 
HPDF_Image HPDF_LoadRawImageFromMem (HPDF_Doc pdf, const HPDF_BYTE *buf, HPDF_UINT width, HPDF_UINT height, HPDF_ColorSpace color_space, HPDF_UINT bits_per_component)
 Load raw format image. More...
 
HPDF_Point HPDF_Image_GetSize (HPDF_Image image)
 Get size of the image of an image object. More...
 
HPDF_STATUS HPDF_Image_GetSize2 (HPDF_Image image, HPDF_Point *size)
 Get size of the image of an image object to parameter. More...
 
HPDF_UINT HPDF_Image_GetWidth (HPDF_Image image)
 Get image width of an image object. More...
 
HPDF_UINT HPDF_Image_GetHeight (HPDF_Image image)
 Get image height of an image object. More...
 
HPDF_UINT HPDF_Image_GetBitsPerComponent (HPDF_Image image)
 Get bit count used to describe each color component. More...
 
const char * HPDF_Image_GetColorSpace (HPDF_Image image)
 Get image color space name. More...
 
HPDF_STATUS HPDF_Image_SetColorMask (HPDF_Image image, HPDF_UINT rmin, HPDF_UINT rmax, HPDF_UINT gmin, HPDF_UINT gmax, HPDF_UINT bmin, HPDF_UINT bmax)
 Sets transparent color of the image by the RGB range values. More...
 
HPDF_STATUS HPDF_Image_SetMaskImage (HPDF_Image image, HPDF_Image mask_image)
 Set image mask. More...
 

Detailed Description

Routines for image loading and measuring

Function Documentation

◆ HPDF_Image_GetBitsPerComponent()

HPDF_UINT HPDF_Image_GetBitsPerComponent ( HPDF_Image  image)

Get bit count used to describe each color component.

Parameters
imageImage object handle.
Returns
Bit count on success, otherwise it returns 0.
Examples
make_rawimage.c.

◆ HPDF_Image_GetColorSpace()

const char* HPDF_Image_GetColorSpace ( HPDF_Image  image)

Get image color space name.

Parameters
imageImage object handle.
Returns
Color space name on success, otherwise it returns NULL.
See also
Color spaces
Examples
make_rawimage.c.

◆ HPDF_Image_GetHeight()

HPDF_UINT HPDF_Image_GetHeight ( HPDF_Image  image)

Get image height of an image object.

Parameters
imageImage object handle.
Returns
Image height on success, otherwise it returns 0.
Examples
image_demo.c, jpeg_demo.c, make_rawimage.c, and png_demo.c.

◆ HPDF_Image_GetSize()

HPDF_Point HPDF_Image_GetSize ( HPDF_Image  image)

Get size of the image of an image object.

Parameters
imageImage object handle.
Returns
HPDF_Point structure which includes image size, otherwise it returns HPDF_Point{0, 0}.

◆ HPDF_Image_GetSize2()

HPDF_STATUS HPDF_Image_GetSize2 ( HPDF_Image  image,
HPDF_Point size 
)

Get size of the image of an image object to parameter.

In contrast with HPDF_Image_GetWidth() this function returns HPDF_OK on success and writes size value to size parameter.

Parameters
imageImage object handle.
sizeVariable to return size of image to.
Returns
HPDF_OK on success, otherwise returns error code and calls error handler.
Error codes

◆ HPDF_Image_GetWidth()

HPDF_UINT HPDF_Image_GetWidth ( HPDF_Image  image)

Get image width of an image object.

Parameters
imageImage object handle.
Returns
Image width on success, otherwise it returns 0.
Examples
image_demo.c, jpeg_demo.c, make_rawimage.c, and png_demo.c.

◆ HPDF_Image_SetColorMask()

HPDF_STATUS HPDF_Image_SetColorMask ( HPDF_Image  image,
HPDF_UINT  rmin,
HPDF_UINT  rmax,
HPDF_UINT  gmin,
HPDF_UINT  gmax,
HPDF_UINT  bmin,
HPDF_UINT  bmax 
)

Sets transparent color of the image by the RGB range values.

The color within the range is displayed as a transparent color. The image must have RGB color space.

Parameters
imageImage object handle.
rmin,rmaxLower and upper limits of red color. Must be in a range 0 and 255.
gmin,gmaxLower and upper limits of green color. Must be in a range 0 and 255.
bmin,bmaxLower and upper limits of blue color. Must be in a range 0 and 255.
Returns
HPDF_OK on success, otherwise returns error code and calls error handler.
Error codes
Examples
image_demo.c.

◆ HPDF_Image_SetMaskImage()

HPDF_STATUS HPDF_Image_SetMaskImage ( HPDF_Image  image,
HPDF_Image  mask_image 
)

Set image mask.

Parameters
imageImage object handle.
mask_imageSpecify image object handle which is used as image mask. This image must be 1-bit gray-scale color image.
Returns
HPDF_OK on success, otherwise returns error code and calls error handler.
Error codes
Examples
image_demo.c.

◆ HPDF_LoadJpegImageFromFile()

HPDF_Image HPDF_LoadJpegImageFromFile ( HPDF_Doc  pdf,
const char *  filename 
)

Load external JPEG image file.

Parameters
pdfDocument object handle.
filenamePath to JPEG image file.
Returns
Image object handle on success, otherwise, it returns NULL and calls error handler.
Error codes
See also
HPDF_LoadJpegImageFromMem()
Examples
jpeg_demo.c.

◆ HPDF_LoadJpegImageFromMem()

HPDF_Image HPDF_LoadJpegImageFromMem ( HPDF_Doc  pdf,
const HPDF_BYTE buf,
HPDF_UINT  size 
)

Load JPEG image from buffer.

Parameters
pdfDocument object handle.
bufPointer to the image data.
sizeSize of the data in buffer.
Returns
Image object handle on success, otherwise, it returns NULL and calls error handler.
Error codes
See also
HPDF_LoadJpegImageFromFile()

◆ HPDF_LoadPngImageFromFile()

HPDF_Image HPDF_LoadPngImageFromFile ( HPDF_Doc  pdf,
const char *  filename 
)

Load external PNG image file.

Parameters
pdfDocument object handle.
filenamePath to PNG image file.
Returns
Image object handle on success, otherwise, it returns NULL and calls error handler.
Error codes
Examples
image_demo.c, make_rawimage.c, and png_demo.c.

◆ HPDF_LoadPngImageFromFile2()

HPDF_Image HPDF_LoadPngImageFromFile2 ( HPDF_Doc  pdf,
const char *  filename 
)

Load external PNG image file.

Unlike HPDF_LoadPngImageFromFile(), HPDF_LoadPngImageFromFile2() does not load all the data immediately (only size and color properties are loaded). The main data are loaded just before the image object is written to PDF, and then loaded data is deleted.

Parameters
pdfDocument object handle.
filenamePath to PNG image file.
Returns
Image object handle on success, otherwise, it returns NULL and calls error handler.
Error codes

◆ HPDF_LoadPngImageFromMem()

HPDF_Image HPDF_LoadPngImageFromMem ( HPDF_Doc  pdf,
const HPDF_BYTE buf,
HPDF_UINT  size 
)

Load PNG image from buffer.

Parameters
pdfDocument object handle.
bufPointer to the image data.
sizeSize of the data in buffer.
Returns
Image object handle on success, otherwise, it returns NULL and calls error handler.
Error codes

◆ HPDF_LoadRawImageFromFile()

HPDF_Image HPDF_LoadRawImageFromFile ( HPDF_Doc  pdf,
const char *  filename,
HPDF_UINT  width,
HPDF_UINT  height,
HPDF_ColorSpace  color_space 
)

Load raw format image.

This function loads image data from file without any conversion, it is usually faster than the other functions.

Parameters
pdfDocument object handle.
filenamePath to image file
widthWidth of image file
heightHeight of image file
color_spaceOne of HPDF_CS_DEVICE_GRAY, HPDF_CS_DEVICE_RGB or HPDF_CS_DEVICE_CMYK values.
Returns
Image object handle on success, otherwise, it returns NULL and call error handler.
Error codes
See also
Color spaces, HPDF_LoadRawImageFromMem()
Examples
raw_image_demo.c.

◆ HPDF_LoadRawImageFromMem()

HPDF_Image HPDF_LoadRawImageFromMem ( HPDF_Doc  pdf,
const HPDF_BYTE buf,
HPDF_UINT  width,
HPDF_UINT  height,
HPDF_ColorSpace  color_space,
HPDF_UINT  bits_per_component 
)

Load raw format image.

This function loads image data from buffer without any conversion, it is usually faster than the other functions.

Parameters
pdfDocument object handle.
bufPointer to image data
widthWidth of image file
heightHeight of image file
color_spaceOne of HPDF_CS_DEVICE_GRAY, HPDF_CS_DEVICE_RGB or HPDF_CS_DEVICE_CMYK values.
bits_per_componentBit size of each color component. Valid values are 1, 2, 4 and 8.
Returns
Image object handle on success, otherwise, it returns NULL and call error handler.
Error codes
See also
Color spaces, HPDF_LoadRawImageFromFile()
Examples
raw_image_demo.c.