![]() |
Scribus
Open source desktop publishing at your fingertips
|
PGF main class. More...
#include <PGFimage.h>
Public Member Functions | |
CPGFImage () | |
Standard constructor: It is used to create a PGF instance for opening and reading. | |
virtual | ~CPGFImage () |
Destructor: Destroy internal data structures. | |
virtual void | Close () |
virtual void | Destroy () |
void | Open (CPGFStream *stream) THROW_ |
bool | IsOpen () const |
Returns true if the PGF has been opened and not closed. | |
void | Read (int level=0, CallbackPtr cb=NULL, void *data=NULL) THROW_ |
void | Read (PGFRect &rect, int level=0, CallbackPtr cb=NULL, void *data=NULL) THROW_ |
void | ReadPreview () THROW_ |
void | Reconstruct (int level=0) THROW_ |
void | GetBitmap (int pitch, UINT8 *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) const THROW_ |
void | GetYUV (int pitch, DataT *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) const THROW_ |
void | ImportBitmap (int pitch, UINT8 *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_ |
void | ImportYUV (int pitch, DataT *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_ |
void | Write (CPGFStream *stream, UINT32 *nWrittenBytes=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_ |
UINT32 | WriteHeader (CPGFStream *stream) THROW_ |
UINT32 | WriteImage (CPGFStream *stream, CallbackPtr cb=NULL, void *data=NULL) THROW_ |
UINT32 | Write (int level, CallbackPtr cb=NULL, void *data=NULL) THROW_ |
void | ConfigureEncoder (bool useOMP=true, bool favorSpeedOverSize=false) |
void | ConfigureDecoder (bool useOMP=true, bool skipUserData=false) |
void | ResetStreamPos () THROW_ |
Reset stream position to start of PGF pre-header. | |
void | SetChannel (DataT *channel, int c=0) |
void | SetHeader (const PGFHeader &header, BYTE flags=0, UINT8 *userData=0, UINT32 userDataLength=0) THROW_ |
void | SetMaxValue (UINT32 maxValue) |
void | SetProgressMode (ProgressMode pm) |
void | SetRefreshCallback (RefreshCB callback, void *arg) |
void | SetColorTable (UINT32 iFirstColor, UINT32 nColors, const RGBQUAD *prgbColors) THROW_ |
DataT * | GetChannel (int c=0) |
void | GetColorTable (UINT32 iFirstColor, UINT32 nColors, RGBQUAD *prgbColors) const THROW_ |
const RGBQUAD * | GetColorTable () const |
const PGFHeader * | GetHeader () const |
UINT32 | GetMaxValue () const |
UINT64 | GetUserDataPos () const |
const UINT8 * | GetUserData (UINT32 &size) const |
UINT32 | GetEncodedHeaderLength () const |
UINT32 | GetEncodedLevelLength (int level) const |
UINT32 | ReadEncodedHeader (UINT8 *target, UINT32 targetLen) const THROW_ |
UINT32 | ReadEncodedData (int level, UINT8 *target, UINT32 targetLen) const THROW_ |
UINT32 | ChannelWidth (int c=0) const |
UINT32 | ChannelHeight (int c=0) const |
BYTE | ChannelDepth () const |
UINT32 | Width (int level=0) const |
UINT32 | Height (int level=0) const |
BYTE | Level () const |
BYTE | Levels () const |
BYTE | Quality () const |
BYTE | Channels () const |
BYTE | Mode () const |
BYTE | BPP () const |
bool | ROIisSupported () const |
BYTE | UsedBitsPerChannel () const |
BYTE | Version () const |
Static Public Member Functions | |
static bool | ImportIsSupported (BYTE mode) |
static UINT32 | LevelWidth (UINT32 width, int level) |
static UINT32 | LevelHeight (UINT32 height, int level) |
static BYTE | CurrentVersion (BYTE version=PGFVersion) |
Return version. More... | |
static BYTE | CurrentChannelDepth (BYTE version=PGFVersion) |
Protected Attributes | |
CWaveletTransform * | m_wtChannel [MaxChannels] |
wavelet transformed color channels | |
DataT * | m_channel [MaxChannels] |
untransformed channels in YUV format | |
CDecoder * | m_decoder |
PGF decoder. | |
CEncoder * | m_encoder |
PGF encoder. | |
UINT32 * | m_levelLength |
length of each level in bytes; first level starts immediately after this array | |
UINT32 | m_width [MaxChannels] |
width of each channel at current level | |
UINT32 | m_height [MaxChannels] |
height of each channel at current level | |
PGFPreHeader | m_preHeader |
PGF pre-header. | |
PGFHeader | m_header |
PGF file header. | |
PGFPostHeader | m_postHeader |
PGF post-header. | |
UINT64 | m_userDataPos |
stream position of user data | |
int | m_currentLevel |
transform level of current image | |
BYTE | m_quant |
quantization parameter | |
bool | m_downsample |
chrominance channels are downsampled | |
bool | m_favorSpeedOverSize |
favor encoding speed over compression ratio | |
bool | m_useOMPinEncoder |
use Open MP in encoder | |
bool | m_useOMPinDecoder |
use Open MP in decoder | |
bool | m_skipUserData |
skip user data (metadata) during open | |
bool | m_streamReinitialized |
stream has been reinitialized | |
PGFRect | m_roi |
region of interest | |
PGF main class.
PGF image class is the main class. You always need a PGF object for encoding or decoding image data. Decoding: pgf.Open(...) pgf.Read(...) pgf.GetBitmap(...) Encoding: pgf.SetHeader(...) pgf.ImportBitmap(...) pgf.Write(...)
|
inline |
Return the number of bits per pixel. Valid values can be 1, 8, 12, 16, 24, 32, 48, 64.
|
inline |
Return bits per channel of the image's encoder.
|
inline |
Return current image height of given channel in pixels. The returned height depends on the levels read so far and on ROI.
c | A channel index |
|
inline |
Return the number of image channels. An image of type RGB contains 3 image channels (B, G, R).
|
inline |
Return current image width of given channel in pixels. The returned width depends on the levels read so far and on ROI.
c | A channel index |
|
virtual |
Close PGF image after opening and reading. Destructor calls this method during destruction.
|
inline |
Configures the decoder.
useOMP | Use parallel threading with Open MP during decoding. Default value: true. Influences the decoding only if the codec has been compiled with OpenMP support. |
skipUserData | The file might contain user data (metadata). User data ist usually read during Open and stored in memory. Set this flag to false when storing in memory is not needed. |
|
inline |
Configures the encoder.
useOMP | Use parallel threading with Open MP during encoding. Default value: true. Influences the encoding only if the codec has been compiled with OpenMP support. |
favorSpeedOverSize | Favors encoding speed over compression ratio. Default value: false |
|
inlinestatic |
Compute and return codec version.
|
static |
Return version.
Compute and return codec version.
|
virtual |
Destroy internal data structures. Destructor calls this method during destruction.
void CPGFImage::GetBitmap | ( | int | pitch, |
UINT8 * | buff, | ||
BYTE | bpp, | ||
int | channelMap[] = NULL , |
||
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) | const |
Get image data in interleaved format: (ordering of RGB data is BGR[A]) Upsampling, YUV to RGB transform and interleaving are done here to reduce the number of passes over the data. The absolute value of pitch is the number of bytes of an image row of the given image buffer. If pitch is negative, then the image buffer must point to the last row of a bottom-up image (first byte on last row). if pitch is positive, then the image buffer must point to the first row of a top-down image (first byte). The sequence of output channels in the output image buffer does not need to be the same as provided by PGF. In case of different sequences you have to provide a channelMap of size of expected channels (depending on image mode). For example, PGF provides a channel sequence BGR in RGB color mode. If your provided image buffer expects a channel sequence ARGB, then the channelMap looks like { 3, 2, 1, 0 }. It might throw an IOException.
pitch | The number of bytes of a row of the image buffer. |
buff | An image buffer. |
bpp | The number of bits per pixel used in image buffer. |
channelMap | A integer array containing the mapping of PGF channel ordering to expected channel ordering. |
cb | A pointer to a callback procedure. The procedure is called after each copied buffer row. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
|
inline |
Return an internal YUV image channel.
c | A channel index |
void CPGFImage::GetColorTable | ( | UINT32 | iFirstColor, |
UINT32 | nColors, | ||
RGBQUAD * | prgbColors | ||
) | const |
Retrieves red, green, blue (RGB) color values from a range of entries in the palette of the DIB section. It might throw an IOException.
iFirstColor | The color table index of the first entry to retrieve. |
nColors | The number of color table entries to retrieve. |
prgbColors | A pointer to the array of RGBQUAD structures to retrieve the color table entries. |
|
inline |
UINT32 CPGFImage::GetEncodedHeaderLength | ( | ) | const |
Return the length of all encoded headers in bytes. Precondition: The PGF image has been opened with a call of Open(...).
|
inline |
Return the length of an encoded PGF level in bytes. Precondition: The PGF image has been opened with a call of Open(...).
level | The image level |
|
inline |
Return the PGF header structure.
|
inline |
Get maximum intensity value for image modes with more than eight bits per channel. Don't call this method before the PGF header has been read.
const UINT8 * CPGFImage::GetUserData | ( | UINT32 & | size | ) | const |
Return user data and size of user data. Precondition: The PGF image has been opened with a call of Open(...).
size | [out] Size of user data in bytes. |
|
inline |
Return the stream position of the user data or 0. Precondition: The PGF image has been opened with a call of Open(...).
void CPGFImage::GetYUV | ( | int | pitch, |
DataT * | buff, | ||
BYTE | bpp, | ||
int | channelMap[] = NULL , |
||
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) | const |
Get YUV image data in interleaved format: (ordering is YUV[A]) The absolute value of pitch is the number of bytes of an image row of the given image buffer. If pitch is negative, then the image buffer must point to the last row of a bottom-up image (first byte on last row). if pitch is positive, then the image buffer must point to the first row of a top-down image (first byte). The sequence of output channels in the output image buffer does not need to be the same as provided by PGF. In case of different sequences you have to provide a channelMap of size of expected channels (depending on image mode). For example, PGF provides a channel sequence BGR in RGB color mode. If your provided image buffer expects a channel sequence VUY, then the channelMap looks like { 2, 1, 0 }. It might throw an IOException.
pitch | The number of bytes of a row of the image buffer. |
buff | An image buffer. |
bpp | The number of bits per pixel used in image buffer. |
channelMap | A integer array containing the mapping of PGF channel ordering to expected channel ordering. |
cb | A pointer to a callback procedure. The procedure is called after each copied buffer row. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
Get YUV image data in interleaved format: (ordering is YUV[A]) The absolute value of pitch is the number of bytes of an image row of the given image buffer. If pitch is negative, then the image buffer must point to the last row of a bottom-up image (first byte on last row). if pitch is positive, then the image buffer must point to the first row of a top-down image (first byte). The sequence of output channels in the output image buffer does not need to be the same as provided by PGF. In case of different sequences you have to provide a channelMap of size of expected channels (depending on image mode). For example, PGF provides a channel sequence BGR in RGB color mode. If your provided image buffer expects a channel sequence VUY, then the channelMap looks like { 2, 1, 0 }. It might throw an IOException.
pitch | The number of bytes of a row of the image buffer. |
buff | An image buffer. |
bpp | The number of bits per pixel used in image buffer. |
channelMap | A integer array containing the mapping of PGF channel ordering to expected channel ordering. |
cb | A pointer to a callback procedure. The procedure is called after each copied buffer row. If cb returns true, then it stops proceeding. |
|
inline |
Return image height of channel 0 at given level in pixels. The returned height is independent of any Read-operations and ROI.
level | A level |
void CPGFImage::ImportBitmap | ( | int | pitch, |
UINT8 * | buff, | ||
BYTE | bpp, | ||
int | channelMap[] = NULL , |
||
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) |
Import an image from a specified image buffer. This method is usually called before Write(...) and after SetHeader(...). The absolute value of pitch is the number of bytes of an image row. If pitch is negative, then buff points to the last row of a bottom-up image (first byte on last row). If pitch is positive, then buff points to the first row of a top-down image (first byte). The sequence of input channels in the input image buffer does not need to be the same as expected from PGF. In case of different sequences you have to provide a channelMap of size of expected channels (depending on image mode). For example, PGF expects in RGB color mode a channel sequence BGR. If your provided image buffer contains a channel sequence ARGB, then the channelMap looks like { 3, 2, 1, 0 }. It might throw an IOException.
pitch | The number of bytes of a row of the image buffer. |
buff | An image buffer. |
bpp | The number of bits per pixel used in image buffer. |
channelMap | A integer array containing the mapping of input channel ordering to expected channel ordering. |
cb | A pointer to a callback procedure. The procedure is called after each imported buffer row. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
|
static |
Check for valid import image mode.
mode | Image mode |
void CPGFImage::ImportYUV | ( | int | pitch, |
DataT * | buff, | ||
BYTE | bpp, | ||
int | channelMap[] = NULL , |
||
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) |
Import a YUV image from a specified image buffer. The absolute value of pitch is the number of bytes of an image row. If pitch is negative, then buff points to the last row of a bottom-up image (first byte on last row). If pitch is positive, then buff points to the first row of a top-down image (first byte). The sequence of input channels in the input image buffer does not need to be the same as expected from PGF. In case of different sequences you have to provide a channelMap of size of expected channels (depending on image mode). For example, PGF expects in RGB color mode a channel sequence BGR. If your provided image buffer contains a channel sequence VUY, then the channelMap looks like { 2, 1, 0 }. It might throw an IOException.
pitch | The number of bytes of a row of the image buffer. |
buff | An image buffer. |
bpp | The number of bits per pixel used in image buffer. |
channelMap | A integer array containing the mapping of input channel ordering to expected channel ordering. |
cb | A pointer to a callback procedure. The procedure is called after each imported buffer row. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
Import a YUV image from a specified image buffer. The absolute value of pitch is the number of bytes of an image row. If pitch is negative, then buff points to the last row of a bottom-up image (first byte on last row). If pitch is positive, then buff points to the first row of a top-down image (first byte). The sequence of input channels in the input image buffer does not need to be the same as expected from PGF. In case of different sequences you have to provide a channelMap of size of expected channels (depending on image mode). For example, PGF expects in RGB color mode a channel sequence BGR. If your provided image buffer contains a channel sequence VUY, then the channelMap looks like { 2, 1, 0 }. It might throw an IOException.
pitch | The number of bytes of a row of the image buffer. |
buff | An image buffer. |
bpp | The number of bits per pixel used in image buffer. |
channelMap | A integer array containing the mapping of input channel ordering to expected channel ordering. |
cb | A pointer to a callback procedure. The procedure is called after each imported buffer row. If cb returns true, then it stops proceeding. |
|
inline |
Return current image level. Since Read(...) can be used to read each image level separately, it is helpful to know the current level. The current level immediately after Open(...) is Levels().
|
inlinestatic |
Compute and return image height at given level.
height | Original image height (at level 0) |
level | An image level |
|
inline |
Return the number of image levels.
|
inlinestatic |
Compute and return image width at given level.
width | Original image width (at level 0) |
level | An image level |
|
inline |
Return the image mode. An image mode is a predefined constant value (see also PGFtypes.h) compatible with Adobe Photoshop. It represents an image type and format.
void CPGFImage::Open | ( | CPGFStream * | stream | ) |
Open a PGF image at current stream position: read pre-header, header, and ckeck image type. Precondition: The stream has been opened for reading. It might throw an IOException.
stream | A PGF stream |
|
inline |
Return the PGF quality. The quality is inbetween 0 and MaxQuality. PGF quality 0 means lossless quality.
void CPGFImage::Read | ( | int | level = 0 , |
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) |
Read and decode some levels of a PGF image at current stream position. A PGF image is structered in levels, numbered between 0 and Levels() - 1. Each level can be seen as a single image, containing the same content as all other levels, but in a different size (width, height). The image size at level i is double the size (width, height) of the image at level i+1. The image at level 0 contains the original size. Precondition: The PGF image has been opened with a call of Open(...). It might throw an IOException.
level | [0, nLevels) The image level of the resulting image in the internal image buffer. |
cb | A pointer to a callback procedure. The procedure is called after reading a single level. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
void CPGFImage::Read | ( | PGFRect & | rect, |
int | level = 0 , |
||
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) |
Read a rectangular region of interest of a PGF image at current stream position. The origin of the coordinate axis is the top-left corner of the image. All coordinates are measured in pixels. It might throw an IOException.
rect | [inout] Rectangular region of interest (ROI). The rect might be cropped. |
level | [0, nLevels) The image level of the resulting image in the internal image buffer. |
cb | A pointer to a callback procedure. The procedure is called after reading a single level. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
Read a rectangular region of interest of a PGF image at current stream position. The origin of the coordinate axis is the top-left corner of the image. All coordinates are measured in pixels. It might throw an IOException.
rect | [inout] Rectangular region of interest (ROI). The rect might be cropped. |
level | The image level of the resulting image in the internal image buffer. |
cb | A pointer to a callback procedure. The procedure is called after reading a single level. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
UINT32 CPGFImage::ReadEncodedData | ( | int | level, |
UINT8 * | target, | ||
UINT32 | targetLen | ||
) | const |
Reads the data of an encoded PGF level and copies it to a target buffer without decoding. Precondition: The PGF image has been opened with a call of Open(...). It might throw an IOException.
level | The image level |
target | The target buffer |
targetLen | The length of the target buffer in bytes |
UINT32 CPGFImage::ReadEncodedHeader | ( | UINT8 * | target, |
UINT32 | targetLen | ||
) | const |
Reads the encoded PGF headers and copies it to a target buffer. Precondition: The PGF image has been opened with a call of Open(...). It might throw an IOException.
target | The target buffer |
targetLen | The length of the target buffer in bytes |
|
inline |
Read and decode smallest level of a PGF image at current stream position. For details, please refert to Read(...) Precondition: The PGF image has been opened with a call of Open(...). It might throw an IOException.
void CPGFImage::Reconstruct | ( | int | level = 0 | ) |
After you've written a PGF image, you can call this method followed by GetBitmap/GetYUV to get a quick reconstruction (coded -> decoded image). It might throw an IOException.
level | The image level of the resulting image in the internal image buffer. |
|
inline |
Return true if the pgf image supports Region Of Interest (ROI).
|
inline |
Set internal PGF image buffer channel.
channel | A YUV data channel |
c | A channel index |
void CPGFImage::SetColorTable | ( | UINT32 | iFirstColor, |
UINT32 | nColors, | ||
const RGBQUAD * | prgbColors | ||
) |
Sets the red, green, blue (RGB) color values for a range of entries in the palette (clut). It might throw an IOException.
iFirstColor | The color table index of the first entry to set. |
nColors | The number of color table entries to set. |
prgbColors | A pointer to the array of RGBQUAD structures to set the color table entries. |
void CPGFImage::SetHeader | ( | const PGFHeader & | header, |
BYTE | flags = 0 , |
||
UINT8 * | userData = 0 , |
||
UINT32 | userDataLength = 0 |
||
) |
Set PGF header and user data. Precondition: The PGF image has been closed with Close(...) or never opened with Open(...). It might throw an IOException.
header | A valid and already filled in PGF header structure |
flags | A combination of additional version flags. In case you use level-wise encoding then set flag = PGFROI. |
userData | A user-defined memory block containing any kind of cached metadata. |
userDataLength | The size of user-defined memory block in bytes |
void CPGFImage::SetMaxValue | ( | UINT32 | maxValue | ) |
Set maximum intensity value for image modes with more than eight bits per channel. Call this method after SetHeader, but before ImportBitmap.
maxValue | The maximum intensity value. |
|
inline |
Set progress mode used in Read and Write. Default mode is PM_Relative. This method must be called before Open() or SetHeader(). PM_Relative: 100% = level difference between current level and target level of Read/Write PM_Absolute: 100% = number of levels
|
inline |
Set refresh callback procedure and its parameter. The refresh callback is called during Read(...) after each level read.
callback | A refresh callback procedure |
arg | A parameter of the refresh callback procedure |
BYTE CPGFImage::UsedBitsPerChannel | ( | ) | const |
Returns number of used bits per input/output image channel. Precondition: header must be initialized.
|
inline |
Returns images' PGF version
|
inline |
Return image width of channel 0 at given level in pixels. The returned width is independent of any Read-operations and ROI.
level | A level |
void CPGFImage::Write | ( | CPGFStream * | stream, |
UINT32 * | nWrittenBytes = NULL , |
||
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) |
Encode and write a entire PGF image (header and image) at current stream position. A PGF image is structered in levels, numbered between 0 and Levels() - 1. Each level can be seen as a single image, containing the same content as all other levels, but in a different size (width, height). The image size at level i is double the size (width, height) of the image at level i+1. The image at level 0 contains the original size. Precondition: the PGF image contains a valid header (see also SetHeader(...)). It might throw an IOException.
stream | A PGF stream |
nWrittenBytes | [in-out] The number of bytes written into stream are added to the input value. |
cb | A pointer to a callback procedure. The procedure is called after writing a single level. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
UINT32 CPGFImage::Write | ( | int | level, |
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) |
Encode and write down to given level at current stream position. A PGF image is structered in levels, numbered between 0 and Levels() - 1. Each level can be seen as a single image, containing the same content as all other levels, but in a different size (width, height). The image size at level i is double the size (width, height) of the image at level i+1. The image at level 0 contains the original size. Preconditions: the PGF image contains a valid header (see also SetHeader(...)) and WriteHeader() has been called before. Levels() > 0. The ROI encoding scheme must be used (see also SetHeader(...)). It might throw an IOException.
level | [0, nLevels) The image level of the resulting image in the internal image buffer. |
cb | A pointer to a callback procedure. The procedure is called after writing a single level. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |
UINT32 CPGFImage::WriteHeader | ( | CPGFStream * | stream | ) |
Create wavelet transform channels and encoder. Write header at current stream position. Call this method before your first call of Write(int level) or WriteImage(), but after SetHeader(). This method is called inside of Write(stream, ...). It might throw an IOException.
stream | A PGF stream |
UINT32 CPGFImage::WriteImage | ( | CPGFStream * | stream, |
CallbackPtr | cb = NULL , |
||
void * | data = NULL |
||
) |
Encode and write the one and only image at current stream position. Call this method after WriteHeader(). In case you want to write uncached metadata, then do that after WriteHeader() and before WriteImage(). This method is called inside of Write(stream, ...). It might throw an IOException.
stream | A PGF stream |
cb | A pointer to a callback procedure. The procedure is called after writing a single level. If cb returns true, then it stops proceeding. |
data | Data Pointer to C++ class container to host callback procedure. |