Perfectly Clear SDK Documentation  9.0.1.315
PFCImageFile Class Reference

PFCImageFile Class to encapsulate file handling. More...

#include <PFCImageFile.h>

Public Types

enum  PFC_FILETYPE
 Type for compressing/decomrpessing a buffer. More...
 

Public Member Functions

 PFCImageFile ()
 Constructs empty PFCImageFile, to be filled with LoadImageFile() More...
 
 PFCImageFile (int width, int height, const PFCImageFile &model)
 Constructs PFCImageFile with allocation for image of given size and format. More...
 
 PFCImageFile (int width, int height, int bytes_per_pixel, int stride)
 Constructs PFCImageFile with allocation for image of given size. More...
 
PFC_FILE_LOAD_STATUS LoadImageFile (const char *filename, bool bConvertToSRGB, const char *iccFolderPath)
 Load JPEG, PNG or RAW from file on disk. More...
 
PFC_FILE_LOAD_STATUS LoadImageFile (const char *filename, PFC_FILETYPE type, bool bConvertToSRGB, const char *iccFolderPath)
 Load JPEG, PNG or RAW from file on disk. More...
 
PFC_FILE_LOAD_STATUS ExpandImageBuffer (char *data, long size, PFC_FILETYPE type, bool bConvertToSRGB, const char *iccFolderPath)
 Expands the image file data provided in a buffer. More...
 
int CompressImageBuffer (unsigned char **destination, PFC_FILETYPE type, int quality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata)
 Compresses the image to the given type and writes compressed data to destination buffer. More...
 
bool SaveImageFile (const char *filename, int quality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata)
 Write image data to file - specify file type with filename extension. More...
 
bool SaveImageFile (const char *filename, PFC_FILETYPE type, int quality, bool bConvertToOriginalColorSpace, bool bEmbedOriginalMetadata)
 Write image data to file - specify file type with PFC_FILETYPE. More...
 

Data Fields

unsigned char * raw_image
 
int width
 
int height
 
int bytes_per_pixel
 
int stride
 
bool sourceSRGB
 

Detailed Description

PFCImageFile Class to encapsulate file handling.

This is an optional class you can use to read and write JPEG, PNG and WebP files, manage EXIF metadata and perform color space conversion (to / from sRGB). At this time, only RGB formatted images are supported. Basic usage:

PFCImageFile originalImageFile;
bool bConvertToSRGB = true;
const char* pathToSupportFilesFolder = NULL;
PFC_FILE_LOAD_STATUS st = originalImageFile.LoadImageFile(inname, bConvertToSRGB, pathToSupportFilesFolder);

Then, load PFCIMAGE with this data:

im.width = originalImageFile.width;
im.height = originalImageFile.height;
im.stride = originalImageFile.stride;
im.data = originalImageFile.raw_image;

Correct the image:

Then write image back to disk:

bool bConvertToOriginalColorSpace = true;
bool bPreserveOriginalMetadata = true;
originalImageFile.SaveImageFile(outname, 90, bConvertToOriginalColorSpace, bPreserveOriginalMetadata);

Definition at line 59 of file PFCImageFile.h.

Member Function Documentation

◆ CompressImageBuffer()

int CompressImageBuffer ( unsigned char **  destination,
PFC_FILETYPE  type,
int  quality,
bool  bConvertToOriginalColorSpace,
bool  bEmbedOriginalMetadata 
)

Compresses the image to the given type and writes compressed data to destination buffer.

Parameters
destination[out] - pointer to the compressed buffer. Create this buffer through malloc, and disposed through free().
type[in] - filetype of the file to create.
quality[in] - Sets the output quality for the compression. Ignored for PNGs. We recomend 92.
bConvertToOriginalColorSpace[in] - Convert the file back to the input colorspace. If false, the resutling file will be in sRGB.
bEmbedOriginalMetadata[in] - Set to true to copy EXIF data from original to output. This can be critical for images with EXIF rotation flag.
Returns
size of destination buffer

◆ ExpandImageBuffer()

PFC_FILE_LOAD_STATUS ExpandImageBuffer ( char *  data,
long  size,
PFC_FILETYPE  type,
bool  bConvertToSRGB,
const char *  iccFolderPath 
)

Expands the image file data provided in a buffer.

Parameters
data[in] - pointer to compressed image data in a buffer. Its contets are examined but PFCImageFile does not take ownership.
size[in] - size of the data buffer.
type[in] - filetype of the buffer contents.
bConvertToSRGB[in] - Bool to control conversion to sRGB, usually should be set to true.
iccFolderPath[in] - Some JPEGs may be in AdobeRGB without AdobeRGB being actually embedded. Path to folder containing AdobeRGB1998.icc should be passed here
Returns
Status of the decomrpession

◆ LoadImageFile() [1/2]

PFC_FILE_LOAD_STATUS LoadImageFile ( const char *  filename,
bool  bConvertToSRGB,
const char *  iccFolderPath 
)

Load JPEG, PNG or RAW from file on disk.

Parameters
filename[in] - path to file to load
bConvertToSRGB[in] - Bool to control conversion to sRGB, usually should be set to true
iccFolderPath[in] - Some JPEGs may be in AdobeRGB without AdobeRGB being actually embedded. Path to folder containing AdobeRGB1998.icc should be passed here
Returns
Returns enum PFC_FILE_LOAD_STATUS showing file read status

◆ LoadImageFile() [2/2]

PFC_FILE_LOAD_STATUS LoadImageFile ( const char *  filename,
PFC_FILETYPE  type,
bool  bConvertToSRGB,
const char *  iccFolderPath 
)

Load JPEG, PNG or RAW from file on disk.

Parameters
filename[in] - path to file to load
type[in] - filetype of the file to create.
bConvertToSRGB[in] - Bool to control conversion to sRGB, usually should be set to true
iccFolderPath[in] - Some JPEGs may be in AdobeRGB without AdobeRGB being actually embedded. Path to folder containing AdobeRGB1998.icc should be passed here
Returns
Returns enum PFC_FILE_LOAD_STATUS showing file read status

◆ SaveImageFile() [1/2]

bool SaveImageFile ( const char *  filename,
int  quality,
bool  bConvertToOriginalColorSpace,
bool  bEmbedOriginalMetadata 
)

Write image data to file - specify file type with filename extension.

Parameters
filename[in] - filename to write to. The filename determines the type of file created, and must end in .jpg or .png
quality[in] - Sets the output quality for the compression. Ignored for PNGs. We recomend 92.
bConvertToOriginalColorSpace[in] - Convert the file back to the input colorspace. If false, the resutling file will be in sRGB.
bEmbedOriginalMetadata[in] - Set to true to copy EXIF data from original to output. This can be critical for images with EXIF rotation flag.
Returns
True if image was successfully saved to disk

◆ SaveImageFile() [2/2]

bool SaveImageFile ( const char *  filename,
PFC_FILETYPE  type,
int  quality,
bool  bConvertToOriginalColorSpace,
bool  bEmbedOriginalMetadata 
)

Write image data to file - specify file type with PFC_FILETYPE.

Parameters
filename[in] - filename to write to.
type[in] - filetype of the file to create.
quality[in] - Sets the output quality for the compression. Ignored for PNGs. We recomend 92.
bConvertToOriginalColorSpace[in] - Convert the file back to the input colorspace. If false, the resutling file will be in sRGB.
bEmbedOriginalMetadata[in] - Set to true to copy EXIF data from original to output. This can be critical for images with EXIF rotation flag.
Returns
True if image was successfully saved to disk

Member Enumeration Documentation

◆ PFC_FILETYPE

Type for compressing/decomrpessing a buffer.

Enumerator
PFC_JPEG 

JPEG.

PFC_PNG 

PNG.

PFC_WEBP 

WEPB.

Definition at line 64 of file PFCImageFile.h.

Constructor & Destructor Documentation

◆ PFCImageFile() [1/3]

Constructs empty PFCImageFile, to be filled with LoadImageFile()

◆ PFCImageFile() [2/3]

PFCImageFile ( int  width,
int  height,
const PFCImageFile model 
)

Constructs PFCImageFile with allocation for image of given size and format.

Parameters
width[in] - width
height[in] - height
model[in] - already loaded PFCImageFile, new image will inherit pixel format and original metadata from the model

◆ PFCImageFile() [3/3]

PFCImageFile ( int  width,
int  height,
int  bytes_per_pixel,
int  stride 
)

Constructs PFCImageFile with allocation for image of given size.

Parameters
width[in] - width
height[in] - height
bytes_per_pixel[in] - bytes per pixel
stride[in] - stride

Field Documentation

◆ bytes_per_pixel

int bytes_per_pixel

bytes per pixel

Definition at line 164 of file PFCImageFile.h.

◆ height

int height

image height

Definition at line 162 of file PFCImageFile.h.

◆ raw_image

unsigned char* raw_image

image data. Can be loaded directly into PFCIMAGE

im.data = myPFCImagFile.raw_image

Definition at line 158 of file PFCImageFile.h.

◆ sourceSRGB

bool sourceSRGB

set to true if the input image is determined to be in sRGB

Definition at line 168 of file PFCImageFile.h.

◆ stride

int stride

image stride

Definition at line 166 of file PFCImageFile.h.

◆ width

int width

image width

Definition at line 160 of file PFCImageFile.h.


The documentation for this class was generated from the following file: