libpgf  6.12.24
PGF - Progressive Graphics File
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CPGFImage Class Referenceabstract

#include <PGFimage.h>

Public Member Functions

*Close PGF image after opening
and reading *Destructor calls
this method during destruction
*virtual void 
Close ()
 
*Destroy internal data
structures *Destructor calls
this method during destruction
*virtual void 
Destroy ()
 
*Returns true if the PGF has
been opened and not closed
*bool 
IsOpen () const
 
*Read and decode some levels
of a PGF image at current
stream position *A PGF image
is structered in numbered
between and 
Levels ()-1.*Each level can be seen as a single image
 
*Read and decode some levels
of a PGF image at current
stream position *A PGF image
is structered in numbered
between and containing the
same content *as all other but
in a different 
size (width, height).*The image size at level i is double the size(width
 
*Read and decode some levels
of a PGF image at current
stream position *A PGF image
is structered in numbered
between and containing the
same content *as all other but
in a different height of the
image at level i *The image at
level contains the original
size nLevels The image level
of the resulting image in the
internal image buffer *param
cb A pointer to a callback
procedure The procedure is
called after reading a single
level If cb returns then it
stops proceeding *param data
Data Pointer to C class
container to host callback
procedure *void 
Read (int level=0, CallbackPtr cb=NULL, void *data=NULL) THROW_
 
*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 *param
rect[inout] Rectangular region
of 
interest (ROI).The rect might be cropped.*@param level[0
 
*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 *param
rect[inout] Rectangular region
of nLevels The image level of
the resulting image in the
internal image buffer *param
cb A pointer to a callback
procedure The procedure is
called after reading a single
level If cb returns then it
stops proceeding *param data
Data Pointer to C class
container to host callback
procedure *void 
Read (PGFRect &rect, int level=0, CallbackPtr cb=NULL, void *data=NULL) THROW_
 
*Read and decode smallest
level of a PGF image at
current stream position *For
please refert to Read
*(...)*Precondition After you
ve written a PGF you can call
this method followed by
GetBitmap GetYUV *to get a
quick 
reconstruction (coded-> decoded image).*It might throw an IOException.*@param level The image level of the resulting image in the internal image buffer.*/void Reconstruct(int level=0) THROW_
 
*Get image data in interleaved
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 then the image buffer
must point to the last row of
a bottom up 
image (first byte on last row).*if pitch is positive
 
*Get image data in interleaved
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 then the image buffer
must point to the last row of
a bottom up 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
 
*Get image data in interleaved
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 then the image buffer
must point to the last row of
a bottom up then the image
buffer must point to the first
row of a top down PGF provides
a channel sequence BGR in RGB
color mode *If your provided
image buffer expects a channel
sequence then the channelMap
looks then it stops proceeding
*param data Data Pointer to C
class container to host
callback procedure *void 
GetBitmap (int pitch, UINT8 *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) const THROW_
 
*Get YUV image data in
interleaved then the image
buffer must point to the last
row of a bottom up 
image (first byte on last row).*if pitch is positive
 
*Get YUV image data in
interleaved then the image
buffer must point to the last
row of a bottom up 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
 
*Get YUV image data in
interleaved then the image
buffer must point to the last
row of a bottom up then the
image buffer must point to the
first row of a top down PGF
provides a channel sequence
BGR in RGB color mode *If your
provided image buffer expects
a channel sequence then the
channelMap looks then it stops
proceeding *param data Data
Pointer to C class container
to host callback procedure
*void 
GetYUV (int pitch, DataT *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) const THROW_
 
*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
 
*Import an image from a
specified image buffer *This
method is usually called
before then buff points to the
last row of a bottom up 
image (first byte on last row).*If pitch is positive
 
*Import an image from a
specified image buffer *This
method is usually called
before then buff points to the
last row of a bottom up 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
 
*Import an image from a
specified image buffer *This
method is usually called
before then buff points to the
last row of a bottom up then
buff points to the first row
of a top down PGF expects in
RGB color mode a channel
sequence BGR *If your provided
image buffer contains a
channel sequence then the
channelMap looks then it stops
proceeding *param data Data
Pointer to C class container
to host callback procedure
*void 
ImportBitmap (int pitch, UINT8 *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_
 
*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 then buff
points to the last row of a
bottom up 
image (first byte on last row).*If pitch is positive
 
*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 then buff
points to the last row of a
bottom up 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
 
*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 then buff
points to the last row of a
bottom up then buff points to
the first row of a top down
PGF expects in RGB color mode
a channel sequence BGR *If
your provided image buffer
contains a channel sequence
then the channelMap looks then
it stops proceeding *param
data Data Pointer to C class
container to host callback
procedure *void 
ImportYUV (int pitch, DataT *buff, BYTE bpp, int channelMap[]=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_
 
*Encode and write a entire PGF image (header and image) at current stream position.*A PGF image is structered in levels
 
*Encode and write a entire PGF
numbered between and 
Levels ()-1.*Each level can be seen as a single image
 
*Encode and write a entire PGF
numbered between and
containing the same content
*as all other but in a
different 
size (width, height).*The image size at level i is double the size(width
 
*Encode and write a entire PGF
numbered between and
containing the same content
*as all other but in a
different height of the image
at level i *The image at level
contains the original size
then it stops proceeding
*param data Data Pointer to C
class container to host
callback procedure *void 
Write (CPGFStream *stream, UINT32 *nWrittenBytes=NULL, CallbackPtr cb=NULL, void *data=NULL) THROW_
 
*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()
 
*Create wavelet transform
channels and encoder Write
header at current stream
position *Call this method
before your first call of but
after 
SetHeader ().*This method is called inside of Write(stream
 
*Create wavelet transform
channels and encoder Write
header at current stream
position *Call this method
before your first call of but
after *It might throw an
IOException *param stream A
PGF stream *return The number
of bytes written into stream
*UINT32 
WriteHeader (CPGFStream *stream) THROW_
 
*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
 
*Encode and write the one and
only image at current stream
position *Call this method
after *then do that after 
WriteHeader () and before WriteImage().*This method is called inside of Write(stream
 
*Encode and write the one and
only image at current stream
position *Call this method
after *then do that after *It
might throw an IOException
*param stream A PGF stream
*param cb A pointer to a
callback procedure The
procedure is called after
writing a single level If cb
returns then it stops
proceeding *param data Data
Pointer to C class container
to host callback procedure
*return The number of bytes
written into stream *UINT32 
WriteImage (CPGFStream *stream, CallbackPtr cb=NULL, void *data=NULL) THROW_
 
*Encode and write down to
given level at current stream
position *A PGF image is
structered in numbered between
and 
Levels ()-1.*Each level can be seen as a single image
 
*Encode and write down to
given level at current stream
position *A PGF image is
structered in numbered between
and containing the same
content *as all other but in a
different 
size (width, height).*The image size at level i is double the size(width
 
*Encode and write down to
given level at current stream
position *A PGF image is
structered in numbered between
and containing the same
content *as all other but in a
different height of the image
at level i *The image at level
contains the original size
nLevels The image level of the
resulting image in the
internal image buffer *param
cb A pointer to a callback
procedure The procedure is
called after writing a single
level If cb returns then it
stops proceeding *param data
Data Pointer to C class
container to host callback
procedure *return The number
of bytes written into stream
*UINT32 
Write (int level, CallbackPtr cb=NULL, void *data=NULL) THROW_
 
*Set internal PGF image buffer
channel *param channel A YUV
data channel *param c A
channel index *void 
SetChannel (DataT *channel, int c=0)
 
*Set maximum intensity value
for image modes with more than
eight bits per channel *Call
this method after but before
ImportBitmap *param maxValue
The maximum intensity value
*void 
SetMaxValue (UINT32 maxValue)
 
*Set progress mode used in
Read and Write *Default mode
is PM_Relative *This method
must be called before 
Open () or SetHeader().*PM_Relative
 
*Set refresh callback
procedure and its parameter
*The refresh callback is
called during 
Read (...) after each level read.*@param callback A refresh callback procedure *@param arg A parameter of the refresh callback procedure */void SetRefreshCallback(RefreshCB callback
 
*Sets the blue (RGB) color values for a range of entries in the palette(clut).*It might throw an IOException.*@param iFirstColor The color table index of the first entry to set.*@param nColors The number of color table entries to set.*@param prgbColors A pointer to the array of RGBQUAD structures to set the color table entries.*/void SetColorTable(UINT32 iFirstColor
 
*Return an internal YUV image
channel *param c A channel
index *return An internal YUV
image channel *DataT
GetChannel (int c=0)
 
*Retrieves blue (RGB) color values from a range of entries in the palette of the DIB section.*It might throw an IOException.*@param iFirstColor The color table index of the first entry to retrieve.*@param nColors The number of color table entries to retrieve.*@param prgbColors A pointer to the array of RGBQUAD structures to retrieve the color table entries.*/void GetColorTable(UINT32 iFirstColor
 
const RGBQUAD * GetColorTable () const
 
*Return the PGF header
structure *return A PGF header
structure *const PGFHeader
GetHeader () const
 
*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
*return The maximum intensity
value *UINT32 
GetMaxValue () const
 
*Return current image width of
given channel in pixels *The
returned width depends on the
levels read so far and on ROI
*param c A channel index
*return Channel width in
pixels *UINT32 
ChannelWidth (int c=0) const
 
*Return current image height
of given channel in pixels
*The returned height depends
on the levels read so far and
on ROI *param c A channel
index *return Channel height
in pixels *UINT32 
ChannelHeight (int c=0) const
 
*Return bits per channel of
the image s encoder *return
Bits per channel *BYTE 
ChannelDepth () const
 
*Return image width of channel
at given level in pixels *The
returned width is independent
of any Read operations and ROI
*param level A level *return
Image level width in pixels
*UINT32 
Width (int level=0) const
 
*Return image height of
channel at given level in
pixels *The returned height is
independent of any Read
operations and ROI *param
level A level *return Image
level height in pixels *UINT32 
Height (int level=0) const
 
*Return current image level *Since Read (...) can be used to read each image level separately
 
*Return current image level
*Since it is *helpful to know
the current level The current
level immediately after 
Open (...) is Levels().*@return Current image level */BYTE Level() const
 
*Return the number of image
levels *return Number of image
levels *BYTE 
Levels () const
 
*Return the PGF quality The
quality is inbetween and
MaxQuality *PGF quality means
lossless quality *return PGF
quality *BYTE 
Quality () const
 
*Return the number of image
channels *An image of type RGB
contains image 
channels (B, G, R).*@return Number of image channels */BYTE Channels() const
 
*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.*@return Image mode */BYTE Mode() const
 
*Return the number of bits per
pixel *Valid values can
*return Number of bits per
pixel *BYTE 
BPP () const
 
*Return true if the pgf image
supports Region Of 
Interest (ROI).*@return true if the pgf image supports ROI.*/bool ROIisSupported() const
 
*Returns images PGF version
*return PGF codec version of
the image *BYTE 
Version () const
 
*Check for valid import image
mode *param mode Image mode
*return True if an image of
given mode can be imported
with 
ImportBitmap (...)*/static bool ImportIsSupported(BYTE mode)
 
*Compute and return image
width at given level *param
width Original image 
width (at level 0)*@param level An image level *@return Image level width in pixels */static UINT32 LevelWidth(UINT32 width
 

Static Public Member Functions

*Compute and return codec
version *return current PGF
codec version *static BYTE 
CurrentChannelDepth (BYTE version=PGFVersion)
 

Public Attributes

*Standard constructor: It is used to create a PGF instance for opening and reading. */ CPGFImage()
 
Destructor: Destroy internal data structures. */ virtual ~CPGFImage()
 
*Open a PGF image at current stream position: read pre-header
 
*Open a PGF image at current stream header
 
*Open a PGF image at current
stream and ckeck image type * 
Precondition: The stream has been opened for reading. * It might throw an IOException. * @param stream A PGF stream */ void Open(CPGFStream* stream) THROW_
 
*Read and decode some levels
of a PGF image at current
stream position *A PGF image
is structered in 
levels
 
*Read and decode some levels
of a PGF image at current
stream position *A PGF image
is structered in numbered
between and containing the
same content *as all other 
levels
 
*Read and decode some levels
of a PGF image at current
stream position *A PGF image
is structered in numbered
between and containing the
same content *as all other but
in a different height of the
image at level i *The image at
level contains the original
size
Precondition: The PGF image has been opened with a call of Open(...). * It might throw an IOException. * @param level [0
 
*Read and decode some levels
of a PGF image at current
stream position *A PGF image
is structered in numbered
between and containing the
same content *as all other but
in a different height of the
image at level i *The image at
level contains the original
size nLevels The image level
of the resulting image in the
internal image buffer *param
cb A pointer to a callback
procedure The procedure is
called after reading a single
level If cb returns 
true
 
*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 *param
rect[inout] Rectangular region
of nLevels The image level of
the resulting image in the
internal image buffer *param
cb A pointer to a callback
procedure The procedure is
called after reading a single
level If cb returns 
true
 
*Read and decode smallest
level of a PGF image at
current stream position *For 
details
 
*Read and decode smallest
level of a PGF image at
current stream position *For
please refert to Read
*(...)*Precondition After you
ve written a PGF 
image
 
*Get image data in interleaved format: (ordering of RGB data is BGR[A]) * Upsampling
 
*Get image data in interleaved
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
 
*Get image data in interleaved
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 then the image buffer
must point to the last row of
a bottom up then the image
buffer must point to the first
row of a top down PGF provides
a channel sequence BGR in RGB
color mode *If your provided
image buffer expects a channel
sequence 
ARGB
 
*Get image data in interleaved
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 then the image buffer
must point to the last row of
a bottom up then the image
buffer must point to the first
row of a top down PGF provides
a channel sequence BGR in RGB
color mode *If your provided
image buffer expects a channel
sequence then the channelMap
looks 
like
 
*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
 
*Get YUV image data in
interleaved then the image
buffer must point to the last
row of a bottom up then the
image buffer must point to the
first row of a top down PGF
provides a channel sequence
BGR in RGB color mode *If your
provided image buffer expects
a channel sequence 
VUY
 
*Get YUV image data in
interleaved then the image
buffer must point to the last
row of a bottom up then the
image buffer must point to the
first row of a top down PGF
provides a channel sequence
BGR in RGB color mode *If your
provided image buffer expects
a channel sequence then the
channelMap looks 
like
 
*Import an image from a
specified image buffer *This
method is usually called
before then buff points to the
last row of a bottom up then
buff points to the first row
of a top down PGF expects in
RGB color mode a channel
sequence BGR *If your provided
image buffer contains a
channel sequence 
ARGB
 
*Import an image from a
specified image buffer *This
method is usually called
before then buff points to the
last row of a bottom up then
buff points to the first row
of a top down PGF expects in
RGB color mode a channel
sequence BGR *If your provided
image buffer contains a
channel sequence then the
channelMap looks 
like
 
*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
 
*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 then buff
points to the last row of a
bottom up then buff points to
the first row of a top down
PGF expects in RGB color mode
a channel sequence BGR *If
your provided image buffer
contains a channel sequence 
VUY
 
*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 then buff
points to the last row of a
bottom up then buff points to
the first row of a top down
PGF expects in RGB color mode
a channel sequence BGR *If
your provided image buffer
contains a channel sequence
then the channelMap looks 
like
 
*Encode and write a entire PGF
numbered between and
containing the same content
*as all other 
levels
 
*Encode and write a entire PGF
numbered between and
containing the same content
*as all other but in a
different height of the image
at level i *The image at level
contains the original size
Precondition: the PGF image contains a valid header (see also SetHeader(...)). * It might throw an IOException. * @param stream A PGF stream * @param nWrittenBytes [in-out] The number of bytes written into stream are added to the input value. * @param cb A pointer to a callback procedure. The procedure is called after writing a single level. If cb returns true
 
*Encode and write the one and
only image at current stream
position *Call this method
after *then do that after *It
might throw an IOException
*param stream A PGF stream
*param cb A pointer to a
callback procedure The
procedure is called after
writing a single level If cb
returns 
true
 
*Encode and write down to
given level at current stream
position *A PGF image is
structered in 
levels
 
*Encode and write down to
given level at current stream
position *A PGF image is
structered in numbered between
and containing the same
content *as all other 
levels
 
*Encode and write down to
given level at current stream
position *A PGF image is
structered in numbered between
and containing the same
content *as all other but in a
different height of the image
at level i *The image at level
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. * @param level [0
 
*Encode and write down to
given level at current stream
position *A PGF image is
structered in numbered between
and containing the same
content *as all other but in a
different height of the image
at level i *The image at level
contains the original size
nLevels The image level of the
resulting image in the
internal image buffer *param
cb A pointer to a callback
procedure The procedure is
called after writing a single
level If cb returns 
true
 
*Configures the encoder *param
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. * @param favorSpeedOverSize Favors encoding speed over compression ratio. Default value: false */ void ConfigureEncoder(bool useOMP = true
 
*Configures the encoder *param
useOMP Use parallel threading
with Open MP during encoding
Default bool 
favorSpeedOverSize
 
*Set PGF header and user dataPrecondition: The PGF image has been closed with Close(...) or never opened with Open(...). * It might throw an IOException. * @param header A valid and already filled in PGF header structure * @param flags A combination of additional version flags. In case you use level-wise encoding then set flag = PGFROI. * @param userData A user-defined memory block containing any kind of cached metadata. * @param userDataLength The size of user-defined memory block in bytes */ void SetHeader(const PGFHeader& header
 
*Set PGF header and user data BYTE flags = 0
 
*Set PGF header and user data
BYTE UINT8 * 
userData = 0
 
*Set PGF header and user data
BYTE UINT8 UINT32 
userDataLength = 0) THROW_
 
*Set maximum intensity value
for image modes with more than
eight bits per channel *Call
this method after 
SetHeader
 
*Set refresh callback
procedure and its parameter
*The refresh callback is
called during void * 
arg { m_cb = callback
 
 m_cbArg = arg
 
*Sets the red
 
*Sets the green
 
*Sets the UINT32 nColors
 
*Sets the UINT32 const RGBQUAD
*prgbColors 
THROW_
 
*Retrieves red
 
*Retrieves green
 
*Retrieves UINT32 nColors
 
*Retrieves UINT32 RGBQUAD
*prgbColors const 
THROW_
 
*Return the stream position of
the user data or * 
Precondition: The PGF image has been opened with a call of Open(...). */ UINT64 GetUserDataPos() const { return m_userDataPos
 
*Return user data and size of
user data
Precondition: The PGF image has been opened with a call of Open(...). * @param size [out] Size of user data in bytes. * @return A pointer to user data or NULL if there is no user data. */ const UINT8* GetUserData(UINT32& size) const
 
*Return the length of all
encoded headers in bytes * 
Precondition: The PGF image has been opened with a call of Open(...). * @return The length of all encoded headers in bytes */ UINT32 GetEncodedHeaderLength() const
 
*Return the length of an
encoded PGF level in bytes * 
Precondition: The PGF image has been opened with a call of Open(...). * @param level The image level * @return The length of a PGF level in bytes */ UINT32 GetEncodedLevelLength(int level) const { ASSERT(level >= 0 && level < m_header.nLevels)
 
return m_levelLength [m_header.nLevels-level-1]
 
*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. * @param target The target buffer * @param targetLen The length of the target buffer in bytes * @return The number of bytes copied to the target buffer */ UINT32 ReadEncodedHeader(UINT8* target
 
*Reads the encoded PGF headers
and copies it to a target
buffer UINT32 targetLen const 
THROW_
 
*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. * @param level The image level * @param target The target buffer * @param targetLen The length of the target buffer in bytes * @return The number of bytes copied to the target buffer */ UINT32 ReadEncodedData(int level
 
*Reads the data of an encoded
PGF level and copies it to a
target buffer *without
decoding UINT8 * 
target
 
*Reads the data of an encoded
PGF level and copies it to a
target buffer *without
decoding UINT8 UINT32
targetLen const 
THROW_
 
*Return the number of bits per
pixel *Valid values can 
be
 
*Returns number of used bits
per input output image channel * 
Precondition: header must be initialized. * @return number of used bits per input/output image channel. */ BYTE UsedBitsPerChannel() const
 
*Compute and return image
width at given level *param
width Original image int 
level { ASSERT(level >= 0)
 
UINT32 w = (width >> level)
 
return *((w<< level)==width)?w
Compute and return image
height at given level *param
height Original image int 
level { ASSERT(level >= 0)
 
UINT32 h = (height >> level)
 

Protected Attributes

CWaveletTransformm_wtChannel [MaxChannels]
 wavelet transformed color channels
 
DataTm_channel [MaxChannels]
 untransformed channels in YUV format
 
CDecoderm_decoder
 PGF decoder.
 
CEncoderm_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
 

Private Member Functions

void ComputeLevels ()
 
void CompleteHeader ()
 
void RgbToYuv (int pitch, UINT8 *rgbBuff, BYTE bpp, int channelMap[], CallbackPtr cb, void *data) THROW_
 
void Downsample (int nChannel)
 
UINT32 UpdatePostHeaderSize () THROW_
 
void WriteLevel () THROW_
 
void SetROI (PGFRect rect)
 
UINT8 Clamp4 (DataT v) const
 
UINT16 Clamp6 (DataT v) const
 
UINT8 Clamp8 (DataT v) const
 
UINT16 Clamp16 (DataT v) const
 
UINT32 Clamp31 (DataT v) const
 

Private Attributes

RefreshCB m_cb
 pointer to refresh callback procedure
 
void * m_cbArg
 refresh callback argument
 
double m_percent
 progress [0..1]
 
ProgressMode m_progressMode
 progress mode used in Read and Write; PM_Relative is default mode
 

Detailed Description

Definition at line 56 of file PGFimage.h.

Member Function Documentation

* Sets the CPGFImage::blue ( RGB  )
* Retrieves CPGFImage::blue ( RGB  )
* Return the number of bits per pixel* Valid values can * return Number of bits per pixel* BYTE CPGFImage::BPP ( ) const
inline

Definition at line 460 of file PGFimage.h.

{ return m_header.bpp; }
* Return bits per channel of the image s encoder* return Bits per channel* BYTE CPGFImage::ChannelDepth ( ) const
inline

Definition at line 409 of file PGFimage.h.

{ return CurrentChannelDepth(m_preHeader.version); }
* Return current image height of given channel in pixels* The returned height depends on the levels read so far and on ROI* param c A channel index* return Channel height in pixels* UINT32 CPGFImage::ChannelHeight ( int  c = 0) const
inline

Definition at line 404 of file PGFimage.h.

{ ASSERT(c >= 0 && c < MaxChannels); return m_height[c]; }
* Return the number of image channels* An image of type RGB contains image CPGFImage::channels ( ,
,
 
) const
inline

Definition at line 445 of file PGFimage.h.

{ return m_header.channels; }
* Return current image width of given channel in pixels* The returned width depends on the levels read so far and on ROI* param c A channel index* return Channel width in pixels* UINT32 CPGFImage::ChannelWidth ( int  c = 0) const
inline

Definition at line 397 of file PGFimage.h.

{ ASSERT(c >= 0 && c < MaxChannels); return m_width[c]; }
UINT16 CPGFImage::Clamp16 ( DataT  v) const
inlineprivate

Definition at line 561 of file PGFimage.h.

{
if (v & 0xFFFF0000) return (v < 0) ? (UINT16)0: (UINT16)65535; else return (UINT16)v;
}
UINT32 CPGFImage::Clamp31 ( DataT  v) const
inlineprivate

Definition at line 564 of file PGFimage.h.

{
return (v < 0) ? 0 : (UINT32)v;
}
UINT8 CPGFImage::Clamp4 ( DataT  v) const
inlineprivate

Definition at line 551 of file PGFimage.h.

{
if (v & 0xFFFFFFF0) return (v < 0) ? (UINT8)0: (UINT8)15; else return (UINT8)v;
}
UINT16 CPGFImage::Clamp6 ( DataT  v) const
inlineprivate

Definition at line 554 of file PGFimage.h.

{
if (v & 0xFFFFFFC0) return (v < 0) ? (UINT16)0: (UINT16)63; else return (UINT16)v;
}
UINT8 CPGFImage::Clamp8 ( DataT  v) const
inlineprivate

Definition at line 557 of file PGFimage.h.

{
// needs only one test in the normal case
if (v & 0xFFFFFF00) return (v < 0) ? (UINT8)0 : (UINT8)255; else return (UINT8)v;
}
void CPGFImage::Close ( )
virtual

Definition at line 121 of file PGFimage.cpp.

{
delete m_decoder; m_decoder = 0;
}
void CPGFImage::CompleteHeader ( )
private

Definition at line 207 of file PGFimage.cpp.

{
// undefined mode
switch(m_header.bpp) {
case 1: m_header.mode = ImageModeBitmap; break;
case 8: m_header.mode = ImageModeGrayScale; break;
case 12: m_header.mode = ImageModeRGB12; break;
case 16: m_header.mode = ImageModeRGB16; break;
case 24: m_header.mode = ImageModeRGBColor; break;
case 32: m_header.mode = ImageModeRGBA; break;
case 48: m_header.mode = ImageModeRGB48; break;
default: m_header.mode = ImageModeRGBColor; break;
}
}
if (!m_header.bpp) {
// undefined bpp
switch(m_header.mode) {
break;
break;
m_header.bpp = 12;
break;
m_header.bpp = 16;
break;
m_header.bpp = 24;
break;
m_header.bpp = 32;
break;
m_header.bpp = 48;
break;
m_header.bpp = 64;
break;
default:
ASSERT(false);
m_header.bpp = 24;
}
}
// change mode
}
// set number of channels
switch(m_header.mode) {
break;
break;
break;
default:
ASSERT(false);
}
}
// store used bits per channel
if (bpc > 31) bpc = 31;
}
}
void CPGFImage::ComputeLevels ( )
private

Definition at line 798 of file PGFimage.cpp.

{
const int maxThumbnailWidth = 20*FilterWidth;
const int m = __min(m_header.width, m_header.height);
int s = m;
// compute a good value depending on the size of the image
while (s > maxThumbnailWidth) {
s = s/2;
}
}
int levels = m_header.nLevels; // we need a signed value during level reduction
// reduce number of levels if the image size is smaller than FilterWidth*2^levels
s = FilterWidth*(1 << levels); // must be at least the double filter size because of subsampling
while (m < s) {
levels--;
s = s/2;
}
if (levels > MaxLevel) m_header.nLevels = MaxLevel;
else if (levels < 0) m_header.nLevels = 0;
else m_header.nLevels = (UINT8)levels;
// used in Write when PM_Absolute
m_percent = pow(0.25, m_header.nLevels);
}
* Compute and return codec version* return current PGF codec version* static BYTE CPGFImage::CurrentChannelDepth ( BYTE  version = PGFVersion)
inlinestatic

Definition at line 508 of file PGFimage.h.

{ return (version & PGF32) ? 32 : 16; }
void CPGFImage::Destroy ( )
virtual

Definition at line 104 of file PGFimage.cpp.

{
Close();
for (int i=0; i < m_header.channels; i++) {
delete m_wtChannel[i]; m_wtChannel[i]=0; // also deletes m_channel
m_channel[i] = 0;
}
delete m_encoder; m_encoder = NULL;
}
void CPGFImage::Downsample ( int  nChannel)
private

Definition at line 754 of file PGFimage.cpp.

{
ASSERT(ch > 0);
const int w = m_width[0];
const int w2 = w/2;
const int h2 = m_height[0]/2;
const int oddW = w%2; // don't use bool -> problems with MaxSpeed optimization
const int oddH = m_height[0]%2; // "
int loPos = 0;
int hiPos = w;
int sampledPos = 0;
DataT* buff = m_channel[ch]; ASSERT(buff);
for (int i=0; i < h2; i++) {
for (int j=0; j < w2; j++) {
// compute average of pixel block
buff[sampledPos] = (buff[loPos] + buff[loPos + 1] + buff[hiPos] + buff[hiPos + 1]) >> 2;
loPos += 2; hiPos += 2;
sampledPos++;
}
if (oddW) {
buff[sampledPos] = (buff[loPos] + buff[hiPos]) >> 1;
loPos++; hiPos++;
sampledPos++;
}
loPos += w; hiPos += w;
}
if (oddH) {
for (int j=0; j < w2; j++) {
buff[sampledPos] = (buff[loPos] + buff[loPos+1]) >> 1;
loPos += 2; hiPos += 2;
sampledPos++;
}
if (oddW) {
buff[sampledPos] = buff[loPos];
}
}
// downsampled image has half width and half height
m_width[ch] = (m_width[ch] + 1)/2;
m_height[ch] = (m_height[ch] + 1)/2;
}
void CPGFImage::GetBitmap ( int  pitch,
UINT8 *  buff,
BYTE  bpp,
int  channelMap[] = NULL,
CallbackPtr  cb = NULL,
void *  data = NULL 
) const

Definition at line 1697 of file PGFimage.cpp.

{
ASSERT(buff);
UINT32 w = m_width[0];
UINT32 h = m_height[0];
UINT8* targetBuff = 0; // used if ROI is used
UINT8* buffStart = 0; // used if ROI is used
int targetPitch = 0; // used if ROI is used
#ifdef __PGFROISUPPORT__
const PGFRect& roi = (ROIisSupported()) ? m_wtChannel[0]->GetROI(m_currentLevel) : PGFRect(0, 0, w, h); // roi is usually larger than m_roi
const PGFRect levelRoi(LevelWidth(m_roi.left, m_currentLevel), LevelHeight(m_roi.top, m_currentLevel), LevelWidth(m_roi.Width(), m_currentLevel), LevelHeight(m_roi.Height(), m_currentLevel));
ASSERT(w <= roi.Width() && h <= roi.Height());
ASSERT(roi.left <= levelRoi.left && levelRoi.right <= roi.right);
ASSERT(roi.top <= levelRoi.top && levelRoi.bottom <= roi.bottom);
if (ROIisSupported() && (levelRoi.Width() < w || levelRoi.Height() < h)) {
// ROI is used -> create a temporary image buffer for roi
// compute pitch
targetPitch = pitch;
pitch = AlignWordPos(w*bpp)/8;
// create temporary output buffer
targetBuff = buff;
buff = buffStart = new(std::nothrow) UINT8[pitch*h];
if (!buff) ReturnWithError(InsufficientMemory);
}
#endif
const bool wOdd = (1 == w%2);
const double dP = 1.0/h;
int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(sizeof(defMap)/sizeof(defMap[0]) == MaxChannels);
if (channelMap == NULL) channelMap = defMap;
int sampledPos = 0, yPos = 0;
DataT uAvg, vAvg;
double percent = 0;
UINT32 i, j;
switch(m_header.mode) {
{
ASSERT(bpp == 1);
const UINT32 w2 = (w + 7)/8;
DataT* y = m_channel[0]; ASSERT(y);
for (i=0; i < h; i++) {
for (j=0; j < w2; j++) {
buff[j] = Clamp8(y[yPos++] + YUVoffset8);
}
yPos += w - w2;
//UINT32 cnt = w;
//for (j=0; j < w2; j++) {
// buff[j] = 0;
// for (int k=0; k < 8; k++) {
// if (cnt) {
// buff[j] <<= 1;
// buff[j] |= (1 & (y[yPos++] - YUVoffset8));
// cnt--;
// }
// }
//}
buff += pitch;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
break;
}
{
ASSERT(bpp%8 == 0);
int cnt, channels = bpp/8; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
cnt = 0;
for (j=0; j < w; j++) {
for (int c=0; c < m_header.channels; c++) {
buff[cnt + channelMap[c]] = Clamp8(m_channel[c][yPos] + YUVoffset8);
}
cnt += channels;
yPos++;
}
buff += pitch;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
break;
}
{
const DataT yuvOffset16 = 1 << (UsedBitsPerChannel() - 1);
int cnt, channels;
if (bpp%16 == 0) {
const int shift = 16 - UsedBitsPerChannel(); ASSERT(shift >= 0);
UINT16 *buff16 = (UINT16 *)buff;
int pitch16 = pitch/2;
channels = bpp/16; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
cnt = 0;
for (j=0; j < w; j++) {
for (int c=0; c < m_header.channels; c++) {
buff16[cnt + channelMap[c]] = Clamp16((m_channel[c][yPos] + yuvOffset16) << shift);
}
cnt += channels;
yPos++;
}
buff16 += pitch16;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
} else {
ASSERT(bpp%8 == 0);
const int shift = __max(0, UsedBitsPerChannel() - 8);
channels = bpp/8; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
cnt = 0;
for (j=0; j < w; j++) {
for (int c=0; c < m_header.channels; c++) {
buff[cnt + channelMap[c]] = Clamp8((m_channel[c][yPos] + yuvOffset16) >> shift);
}
cnt += channels;
yPos++;
}
buff += pitch;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
break;
}
{
ASSERT(bpp%8 == 0);
ASSERT(bpp >= m_header.bpp);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
UINT8 *buffg = &buff[channelMap[1]],
*buffr = &buff[channelMap[2]],
*buffb = &buff[channelMap[0]];
UINT8 g;
int cnt, channels = bpp/8;
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
// Yuv
buffg[cnt] = g = Clamp8(y[yPos] + YUVoffset8 - ((uAvg + vAvg ) >> 2)); // must be logical shift operator
buffr[cnt] = Clamp8(uAvg + g);
buffb[cnt] = Clamp8(vAvg + g);
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buffb += pitch;
buffg += pitch;
buffr += pitch;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}else{
for (i=0; i < h; i++) {
cnt = 0;
for (j = 0; j < w; j++) {
uAvg = u[yPos];
vAvg = v[yPos];
// Yuv
buffg[cnt] = g = Clamp8(y[yPos] + YUVoffset8 - ((uAvg + vAvg ) >> 2)); // must be logical shift operator
buffr[cnt] = Clamp8(uAvg + g);
buffb[cnt] = Clamp8(vAvg + g);
yPos++;
cnt += channels;
}
buffb += pitch;
buffg += pitch;
buffr += pitch;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
break;
}
{
const DataT yuvOffset16 = 1 << (UsedBitsPerChannel() - 1);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
int cnt, channels;
DataT g;
if (bpp >= 48 && bpp%16 == 0) {
const int shift = 16 - UsedBitsPerChannel(); ASSERT(shift >= 0);
UINT16 *buff16 = (UINT16 *)buff;
int pitch16 = pitch/2;
channels = bpp/16; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
} else {
uAvg = u[yPos];
vAvg = v[yPos];
}
// Yuv
g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2); // must be logical shift operator
buff16[cnt + channelMap[1]] = Clamp16(g << shift);
buff16[cnt + channelMap[2]] = Clamp16((uAvg + g) << shift);
buff16[cnt + channelMap[0]] = Clamp16((vAvg + g) << shift);
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buff16 += pitch16;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
} else {
ASSERT(bpp%8 == 0);
const int shift = __max(0, UsedBitsPerChannel() - 8);
channels = bpp/8; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
} else {
uAvg = u[yPos];
vAvg = v[yPos];
}
// Yuv
g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2); // must be logical shift operator
buff[cnt + channelMap[1]] = Clamp8(g >> shift);
buff[cnt + channelMap[2]] = Clamp8((uAvg + g) >> shift);
buff[cnt + channelMap[0]] = Clamp8((vAvg + g) >> shift);
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buff += pitch;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
break;
}
{
ASSERT(bpp%8 == 0);
DataT* l = m_channel[0]; ASSERT(l);
DataT* a = m_channel[1]; ASSERT(a);
DataT* b = m_channel[2]; ASSERT(b);
int cnt, channels = bpp/8; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = a[sampledPos];
vAvg = b[sampledPos];
} else {
uAvg = a[yPos];
vAvg = b[yPos];
}
buff[cnt + channelMap[0]] = Clamp8(l[yPos] + YUVoffset8);
buff[cnt + channelMap[1]] = Clamp8(uAvg + YUVoffset8);
buff[cnt + channelMap[2]] = Clamp8(vAvg + YUVoffset8);
cnt += channels;
yPos++;
if (j%2) sampledPos++;
}
buff += pitch;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
break;
}
{
const DataT yuvOffset16 = 1 << (UsedBitsPerChannel() - 1);
DataT* l = m_channel[0]; ASSERT(l);
DataT* a = m_channel[1]; ASSERT(a);
DataT* b = m_channel[2]; ASSERT(b);
int cnt, channels;
if (bpp%16 == 0) {
const int shift = 16 - UsedBitsPerChannel(); ASSERT(shift >= 0);
UINT16 *buff16 = (UINT16 *)buff;
int pitch16 = pitch/2;
channels = bpp/16; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = a[sampledPos];
vAvg = b[sampledPos];
} else {
uAvg = a[yPos];
vAvg = b[yPos];
}
buff16[cnt + channelMap[0]] = Clamp16((l[yPos] + yuvOffset16) << shift);
buff16[cnt + channelMap[1]] = Clamp16((uAvg + yuvOffset16) << shift);
buff16[cnt + channelMap[2]] = Clamp16((vAvg + yuvOffset16) << shift);
cnt += channels;
yPos++;
if (j%2) sampledPos++;
}
buff16 += pitch16;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
} else {
ASSERT(bpp%8 == 0);
const int shift = __max(0, UsedBitsPerChannel() - 8);
channels = bpp/8; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = a[sampledPos];
vAvg = b[sampledPos];
} else {
uAvg = a[yPos];
vAvg = b[yPos];
}
buff[cnt + channelMap[0]] = Clamp8((l[yPos] + yuvOffset16) >> shift);
buff[cnt + channelMap[1]] = Clamp8((uAvg + yuvOffset16) >> shift);
buff[cnt + channelMap[2]] = Clamp8((vAvg + yuvOffset16) >> shift);
cnt += channels;
yPos++;
if (j%2) sampledPos++;
}
buff += pitch;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
break;
}
{
ASSERT(bpp%8 == 0);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
DataT* a = m_channel[3]; ASSERT(a);
UINT8 g, aAvg;
int cnt, channels = bpp/8; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
aAvg = Clamp8(a[sampledPos] + YUVoffset8);
} else {
uAvg = u[yPos];
vAvg = v[yPos];
aAvg = Clamp8(a[yPos] + YUVoffset8);
}
// Yuv
buff[cnt + channelMap[1]] = g = Clamp8(y[yPos] + YUVoffset8 - ((uAvg + vAvg ) >> 2)); // must be logical shift operator
buff[cnt + channelMap[2]] = Clamp8(uAvg + g);
buff[cnt + channelMap[0]] = Clamp8(vAvg + g);
buff[cnt + channelMap[3]] = aAvg;
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buff += pitch;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
break;
}
{
const DataT yuvOffset16 = 1 << (UsedBitsPerChannel() - 1);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
DataT* a = m_channel[3]; ASSERT(a);
DataT g, aAvg;
int cnt, channels;
if (bpp%16 == 0) {
const int shift = 16 - UsedBitsPerChannel(); ASSERT(shift >= 0);
UINT16 *buff16 = (UINT16 *)buff;
int pitch16 = pitch/2;
channels = bpp/16; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
aAvg = a[sampledPos] + yuvOffset16;
} else {
uAvg = u[yPos];
vAvg = v[yPos];
aAvg = a[yPos] + yuvOffset16;
}
// Yuv
g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2); // must be logical shift operator
buff16[cnt + channelMap[1]] = Clamp16(g << shift);
buff16[cnt + channelMap[2]] = Clamp16((uAvg + g) << shift);
buff16[cnt + channelMap[0]] = Clamp16((vAvg + g) << shift);
buff16[cnt + channelMap[3]] = Clamp16(aAvg << shift);
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buff16 += pitch16;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
} else {
ASSERT(bpp%8 == 0);
const int shift = __max(0, UsedBitsPerChannel() - 8);
channels = bpp/8; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
aAvg = a[sampledPos] + yuvOffset16;
} else {
uAvg = u[yPos];
vAvg = v[yPos];
aAvg = a[yPos] + yuvOffset16;
}
// Yuv
g = y[yPos] + yuvOffset16 - ((uAvg + vAvg ) >> 2); // must be logical shift operator
buff[cnt + channelMap[1]] = Clamp8(g >> shift);
buff[cnt + channelMap[2]] = Clamp8((uAvg + g) >> shift);
buff[cnt + channelMap[0]] = Clamp8((vAvg + g) >> shift);
buff[cnt + channelMap[3]] = Clamp8(aAvg >> shift);
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buff += pitch;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
break;
}
#ifdef __PGF32SUPPORT__
{
const int yuvOffset31 = 1 << (UsedBitsPerChannel() - 1);
DataT* y = m_channel[0]; ASSERT(y);
if (bpp == 32) {
const int shift = 31 - UsedBitsPerChannel(); ASSERT(shift >= 0);
UINT32 *buff32 = (UINT32 *)buff;
int pitch32 = pitch/4;
for (i=0; i < h; i++) {
for (j=0; j < w; j++) {
buff32[j] = Clamp31((y[yPos++] + yuvOffset31) << shift);
}
buff32 += pitch32;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
} else if (bpp == 16) {
const int usedBits = UsedBitsPerChannel();
UINT16 *buff16 = (UINT16 *)buff;
int pitch16 = pitch/2;
if (usedBits < 16) {
const int shift = 16 - usedBits;
for (i=0; i < h; i++) {
for (j=0; j < w; j++) {
buff16[j] = Clamp16((y[yPos++] + yuvOffset31) << shift);
}
buff16 += pitch16;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
} else {
const int shift = __max(0, usedBits - 16);
for (i=0; i < h; i++) {
for (j=0; j < w; j++) {
buff16[j] = Clamp16((y[yPos++] + yuvOffset31) >> shift);
}
buff16 += pitch16;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
} else {
ASSERT(bpp == 8);
const int shift = __max(0, UsedBitsPerChannel() - 8);
for (i=0; i < h; i++) {
for (j=0; j < w; j++) {
buff[j] = Clamp8((y[yPos++] + yuvOffset31) >> shift);
}
buff += pitch;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
break;
}
#endif
{
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
UINT16 yval;
int cnt;
for (i=0; i < h; i++) {
cnt = 0;
for (j=0; j < w; j++) {
// Yuv
uAvg = u[yPos];
vAvg = v[yPos];
yval = Clamp4(y[yPos++] + YUVoffset4 - ((uAvg + vAvg ) >> 2)); // must be logical shift operator
if (j%2 == 0) {
buff[cnt] = UINT8(Clamp4(vAvg + yval) | (yval << 4));
cnt++;
buff[cnt] = Clamp4(uAvg + yval);
} else {
buff[cnt] |= Clamp4(vAvg + yval) << 4;
cnt++;
buff[cnt] = UINT8(yval | (Clamp4(uAvg + yval) << 4));
cnt++;
}
}
buff += pitch;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
break;
}
{
ASSERT(bpp == 16);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
UINT16 yval;
UINT16 *buff16 = (UINT16 *)buff;
int pitch16 = pitch/2;
for (i=0; i < h; i++) {
for (j=0; j < w; j++) {
// Yuv
uAvg = u[yPos];
vAvg = v[yPos];
yval = Clamp6(y[yPos++] + YUVoffset6 - ((uAvg + vAvg ) >> 2)); // must be logical shift operator
buff16[j] = (yval << 5) | ((Clamp6(uAvg + yval) >> 1) << 11) | (Clamp6(vAvg + yval) >> 1);
}
buff16 += pitch16;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
break;
}
default:
ASSERT(false);
}
#ifdef __PGFROISUPPORT__
if (targetBuff) {
// copy valid ROI (m_roi) from temporary buffer (roi) to target buffer
if (bpp%8 == 0) {
BYTE bypp = bpp/8;
buff = buffStart + (levelRoi.top - roi.top)*pitch + (levelRoi.left - roi.left)*bypp;
w = levelRoi.Width()*bypp;
h = levelRoi.Height();
for (i=0; i < h; i++) {
for (j=0; j < w; j++) {
targetBuff[j] = buff[j];
}
targetBuff += targetPitch;
buff += pitch;
}
} else {
// to do
}
delete[] buffStart;
}
#endif
}
* Return an internal YUV image channel* param c A channel index* return An internal YUV image channel* DataT* CPGFImage::GetChannel ( int  c = 0)
inline

Definition at line 321 of file PGFimage.h.

{ ASSERT(c >= 0 && c < MaxChannels); return m_channel[c]; }
const RGBQUAD* CPGFImage::GetColorTable ( ) const
inline
Returns
Address of color table

Definition at line 334 of file PGFimage.h.

{ return m_postHeader.clut; }
* Return the PGF header structure* return A PGF header structure* const PGFHeader* CPGFImage::GetHeader ( ) const
inline

Definition at line 339 of file PGFimage.h.

{ return &m_header; }
* 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* return The maximum intensity value* UINT32 CPGFImage::GetMaxValue ( ) const
inline

Definition at line 345 of file PGFimage.h.

{ return (1 << m_header.usedBitsPerChannel) - 1; }
*Get YUV image data in interleaved then the image buffer must point to the last row of a bottom up then the image buffer must point to the first row of a top down PGF provides a channel sequence BGR in RGB color mode *If your provided image buffer expects a channel sequence then the channelMap looks then it stops proceeding *void CPGFImage::GetYUV ( int  pitch,
DataT buff,
BYTE  bpp,
int  channelMap[] = NULL,
CallbackPtr  cb = NULL,
void *  data = NULL 
) const

Definition at line 2455 of file PGFimage.cpp.

{
ASSERT(buff);
const UINT32 w = m_width[0];
const UINT32 h = m_height[0];
const bool wOdd = (1 == w%2);
const int dataBits = DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
const int pitch2 = pitch/DataTSize;
const int yuvOffset = (dataBits == 16) ? YUVoffset8 : YUVoffset16;
const double dP = 1.0/h;
int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(sizeof(defMap)/sizeof(defMap[0]) == MaxChannels);
if (channelMap == NULL) channelMap = defMap;
int sampledPos = 0, yPos = 0;
DataT uAvg, vAvg;
double percent = 0;
UINT32 i, j;
if (m_header.channels == 3) {
ASSERT(bpp%dataBits == 0);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
int cnt, channels = bpp/dataBits; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
} else {
uAvg = u[yPos];
vAvg = v[yPos];
}
buff[cnt + channelMap[0]] = y[yPos];
buff[cnt + channelMap[1]] = uAvg;
buff[cnt + channelMap[2]] = vAvg;
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buff += pitch2;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
} else if (m_header.channels == 4) {
ASSERT(bpp%dataBits == 0);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
DataT* a = m_channel[3]; ASSERT(a);
UINT8 aAvg;
int cnt, channels = bpp/dataBits; ASSERT(channels >= m_header.channels);
for (i=0; i < h; i++) {
if (i%2) sampledPos -= (w + 1)/2;
cnt = 0;
for (j=0; j < w; j++) {
if (m_downsample) {
// image was downsampled
uAvg = u[sampledPos];
vAvg = v[sampledPos];
aAvg = Clamp8(a[sampledPos] + yuvOffset);
} else {
uAvg = u[yPos];
vAvg = v[yPos];
aAvg = Clamp8(a[yPos] + yuvOffset);
}
// Yuv
buff[cnt + channelMap[0]] = y[yPos];
buff[cnt + channelMap[1]] = uAvg;
buff[cnt + channelMap[2]] = vAvg;
buff[cnt + channelMap[3]] = aAvg;
yPos++;
cnt += channels;
if (j%2) sampledPos++;
}
buff += pitch2;
if (wOdd) sampledPos++;
if (cb) {
percent += dP;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
}
* Return image height of channel at given level in pixels* The returned height is independent of any Read operations and ROI* param level A level* return Image level height in pixels* UINT32 CPGFImage::Height ( int  level = 0) const
inline

Definition at line 423 of file PGFimage.h.

{ ASSERT(level >= 0); return LevelHeight(m_header.height, level); }
* Get image data in interleaved 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 then the image buffer must point to the last row of a bottom up CPGFImage::image ( first byte on last  row)
* Get image data in interleaved 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 then the image buffer must point to the last row of a bottom up then the image buffer must point to the first row of a top down CPGFImage::image ( first  byte)
* Get YUV image data in interleaved then the image buffer must point to the last row of a bottom up CPGFImage::image ( first byte on last  row)
* Get YUV image data in interleaved then the image buffer must point to the last row of a bottom up then the image buffer must point to the first row of a top down CPGFImage::image ( first  byte)
* Import an image from a specified image buffer* This method is usually called before then buff points to the last row of a bottom up CPGFImage::image ( first byte on last  row)
* Import an image from a specified image buffer* This method is usually called before then buff points to the last row of a bottom up then buff points to the first row of a top down CPGFImage::image ( first  byte)
* 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 then buff points to the last row of a bottom up CPGFImage::image ( first byte on last  row)
* 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 then buff points to the last row of a bottom up then buff points to the first row of a top down CPGFImage::image ( first  byte)
* Encode and write a entire PGF CPGFImage::image ( header and  image)
void CPGFImage::ImportBitmap ( int  pitch,
UINT8 *  buff,
BYTE  bpp,
int  channelMap[] = NULL,
CallbackPtr  cb = NULL,
void *  data = NULL 
)

Definition at line 737 of file PGFimage.cpp.

{
ASSERT(buff);
// color transform
RgbToYuv(pitch, buff, bpp, channelMap, cb, data);
if (m_downsample) {
// Subsampling of the chrominance and alpha channels
for (int i=1; i < m_header.channels; i++) {
}
}
}
* Check for valid import image mode* param mode Image mode* return True if an image of given mode can be imported with CPGFImage::ImportBitmap (   ...)
*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 then buff points to the last row of a bottom up then buff points to the first row of a top down PGF expects in RGB color mode a channel sequence BGR *If your provided image buffer contains a channel sequence then the channelMap looks then it stops proceeding *void CPGFImage::ImportYUV ( int  pitch,
DataT buff,
BYTE  bpp,
int  channelMap[] = NULL,
CallbackPtr  cb = NULL,
void *  data = NULL 
)

Definition at line 2566 of file PGFimage.cpp.

{
ASSERT(buff);
const double dP = 1.0/m_header.height;
const int dataBits = DataTSize*8; ASSERT(dataBits == 16 || dataBits == 32);
const int pitch2 = pitch/DataTSize;
const int yuvOffset = (dataBits == 16) ? YUVoffset8 : YUVoffset16;
int yPos = 0, cnt = 0;
double percent = 0;
int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(sizeof(defMap)/sizeof(defMap[0]) == MaxChannels);
if (channelMap == NULL) channelMap = defMap;
if (m_header.channels == 3) {
ASSERT(bpp%dataBits == 0);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
const int channels = bpp/dataBits; ASSERT(channels >= m_header.channels);
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
y[yPos] = buff[cnt + channelMap[0]];
u[yPos] = buff[cnt + channelMap[1]];
v[yPos] = buff[cnt + channelMap[2]];
yPos++;
cnt += channels;
}
buff += pitch2;
}
} else if (m_header.channels == 4) {
ASSERT(bpp%dataBits == 0);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
DataT* a = m_channel[3]; ASSERT(a);
const int channels = bpp/dataBits; ASSERT(channels >= m_header.channels);
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
y[yPos] = buff[cnt + channelMap[0]];
u[yPos] = buff[cnt + channelMap[1]];
v[yPos] = buff[cnt + channelMap[2]];
a[yPos] = buff[cnt + channelMap[3]] - yuvOffset;
yPos++;
cnt += channels;
}
buff += pitch2;
}
}
if (m_downsample) {
// Subsampling of the chrominance and alpha channels
for (int i=1; i < m_header.channels; i++) {
}
}
}
* 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* param rect [inout] Rectangular region of CPGFImage::interest ( ROI  )
* Return true if the pgf image supports Region Of CPGFImage::Interest ( ROI  ) const
inline

Definition at line 463 of file PGFimage.h.

{ return (m_preHeader.version & PGFROI) == PGFROI; }
* Returns true if the PGF has been opened and not closed* bool CPGFImage::IsOpen ( ) const
inline

Definition at line 87 of file PGFimage.h.

{ return m_decoder != NULL; }
* Read and decode some levels of a PGF image at current stream position* A PGF image is structered in numbered between and CPGFImage::Levels ( )
* Encode and write a entire PGF numbered between and CPGFImage::Levels ( )
* Encode and write down to given level at current stream position* A PGF image is structered in numbered between and CPGFImage::Levels ( )
* Return the number of image levels* return Number of image levels* BYTE CPGFImage::Levels ( ) const
inline

Definition at line 435 of file PGFimage.h.

{ return m_header.nLevels; }
* Set progress mode used in Read and Write* Default mode is PM_Relative* This method must be called before CPGFImage::Open ( )
inline

Definition at line 297 of file PGFimage.h.

{ m_progressMode = pm; }
* Return current image level* Since it is* helpful to know the current level The current level immediately after CPGFImage::Open (   ...) const
inline

Definition at line 428 of file PGFimage.h.

{ return (BYTE)m_currentLevel; }
* Return the PGF quality The quality is inbetween and MaxQuality* PGF quality means lossless quality* return PGF quality* BYTE CPGFImage::Quality ( ) const
inline

Definition at line 441 of file PGFimage.h.

{ return m_header.quality; }
void CPGFImage::Read ( int  level = 0,
CallbackPtr  cb = NULL,
void *  data = NULL 
)

Definition at line 382 of file PGFimage.cpp.

{
ASSERT((level >= 0 && level < m_header.nLevels) || m_header.nLevels == 0); // m_header.nLevels == 0: image didn't use wavelet transform
#ifdef __PGFROISUPPORT__
if (ROIisSupported() && m_header.nLevels > 0) {
// new encoding scheme supporting ROI
Read(rect, level, cb, data);
return;
}
#endif
if (m_header.nLevels == 0) {
if (level == 0) {
// the data has already been read during open
// now update progress
if (cb) {
if ((*cb)(1.0, true, data)) ReturnWithError(EscapePressed);
}
}
} else {
const int levelDiff = m_currentLevel - level;
double percent = (m_progressMode == PM_Relative) ? pow(0.25, levelDiff) : m_percent;
// encoding scheme without ROI
while (m_currentLevel > level) {
for (int i=0; i < m_header.channels; i++) {
// decode file and write stream to m_wtChannel
// last level also has LL band
}
if (m_preHeader.version & Version5) {
// since version 5
} else {
// until version 4
m_decoder->DecodeInterleaved(m_wtChannel[i], m_currentLevel, m_quant);
}
}
volatile OSError error = NoError; // volatile prevents optimizations
#pragma omp parallel for default(shared)
for (int i=0; i < m_header.channels; i++) {
// inverse transform from m_wtChannel to m_channel
if (error == NoError) {
OSError err = m_wtChannel[i]->InverseTransform(m_currentLevel, &m_width[i], &m_height[i], &m_channel[i]);
if (err != NoError) error = err;
}
}
if (error != NoError) ReturnWithError(error);
// set new level: must be done before refresh callback
// now we have to refresh the display
if (m_cb) m_cb(m_cbArg);
// now update progress
if (cb) {
percent *= 4;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
}
// automatically closing
if (m_currentLevel == 0) Close();
}
* 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* param rect [inout] Rectangular region of nLevels The image level of the resulting image in the internal image buffer* param cb A pointer to a callback procedure The procedure is called after reading a single level If cb returns then it stops proceeding* param 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 
)
* Set refresh callback procedure and its parameter* The refresh callback is called during CPGFImage::Read (   ...)
* Return current image level* Since CPGFImage::Read (   ...)
* Read and decode smallest level of a PGF image at current stream position* For please refert to Read* (...) * Precondition After you ve written a PGF you can call this method followed by GetBitmap GetYUV* to get a quick CPGFImage::reconstruction ( coded-> decoded  image) const
pure virtual
void CPGFImage::RgbToYuv ( int  pitch,
UINT8 *  rgbBuff,
BYTE  bpp,
int  channelMap[],
CallbackPtr  cb,
void *  data 
)
private

Definition at line 1308 of file PGFimage.cpp.

{
ASSERT(buff);
int yPos = 0, cnt = 0;
double percent = 0;
const double dP = 1.0/m_header.height;
int defMap[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; ASSERT(sizeof(defMap)/sizeof(defMap[0]) == MaxChannels);
if (channelMap == NULL) channelMap = defMap;
switch(m_header.mode) {
{
ASSERT(bpp == 1);
const UINT32 w = m_header.width;
const UINT32 w2 = (m_header.width + 7)/8;
DataT* y = m_channel[0]; ASSERT(y);
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
for (UINT32 j=0; j < w2; j++) {
y[yPos++] = buff[j] - YUVoffset8;
}
for (UINT32 j=w2; j < w; j++) {
y[yPos++] = YUVoffset8;
}
//UINT cnt = w;
//for (UINT32 j=0; j < w2; j++) {
// for (int k=7; k >= 0; k--) {
// if (cnt) {
// y[yPos++] = YUVoffset8 + (1 & (buff[j] >> k));
// cnt--;
// }
// }
//}
buff += pitch;
}
}
break;
{
ASSERT(bpp%8 == 0);
const int channels = bpp/8; ASSERT(channels >= m_header.channels);
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
for (int c=0; c < m_header.channels; c++) {
m_channel[c][yPos] = buff[cnt + channelMap[c]] - YUVoffset8;
}
cnt += channels;
yPos++;
}
buff += pitch;
}
}
break;
{
ASSERT(bpp%16 == 0);
UINT16 *buff16 = (UINT16 *)buff;
const int pitch16 = pitch/2;
const int channels = bpp/16; ASSERT(channels >= m_header.channels);
const int shift = 16 - UsedBitsPerChannel(); ASSERT(shift >= 0);
const DataT yuvOffset16 = 1 << (UsedBitsPerChannel() - 1);
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
for (int c=0; c < m_header.channels; c++) {
m_channel[c][yPos] = (buff16[cnt + channelMap[c]] >> shift) - yuvOffset16;
}
cnt += channels;
yPos++;
}
buff16 += pitch16;
}
}
break;
{
ASSERT(bpp%8 == 0);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
const int channels = bpp/8; ASSERT(channels >= m_header.channels);
UINT8 b, g, r;
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
b = buff[cnt + channelMap[0]];
g = buff[cnt + channelMap[1]];
r = buff[cnt + channelMap[2]];
// Yuv
y[yPos] = ((b + (g << 1) + r) >> 2) - YUVoffset8;
u[yPos] = r - g;
v[yPos] = b - g;
yPos++;
cnt += channels;
}
buff += pitch;
}
}
break;
{
ASSERT(bpp%16 == 0);
UINT16 *buff16 = (UINT16 *)buff;
const int pitch16 = pitch/2;
const int channels = bpp/16; ASSERT(channels >= m_header.channels);
const int shift = 16 - UsedBitsPerChannel(); ASSERT(shift >= 0);
const DataT yuvOffset16 = 1 << (UsedBitsPerChannel() - 1);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
UINT16 b, g, r;
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
b = buff16[cnt + channelMap[0]] >> shift;
g = buff16[cnt + channelMap[1]] >> shift;
r = buff16[cnt + channelMap[2]] >> shift;
// Yuv
y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
u[yPos] = r - g;
v[yPos] = b - g;
yPos++;
cnt += channels;
}
buff16 += pitch16;
}
}
break;
{
ASSERT(bpp%8 == 0);
const int channels = bpp/8; ASSERT(channels >= m_header.channels);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
DataT* a = m_channel[3]; ASSERT(a);
UINT8 b, g, r;
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
b = buff[cnt + channelMap[0]];
g = buff[cnt + channelMap[1]];
r = buff[cnt + channelMap[2]];
// Yuv
y[yPos] = ((b + (g << 1) + r) >> 2) - YUVoffset8;
u[yPos] = r - g;
v[yPos] = b - g;
a[yPos++] = buff[cnt + channelMap[3]] - YUVoffset8;
cnt += channels;
}
buff += pitch;
}
}
break;
{
ASSERT(bpp%16 == 0);
UINT16 *buff16 = (UINT16 *)buff;
const int pitch16 = pitch/2;
const int channels = bpp/16; ASSERT(channels >= m_header.channels);
const int shift = 16 - UsedBitsPerChannel(); ASSERT(shift >= 0);
const DataT yuvOffset16 = 1 << (UsedBitsPerChannel() - 1);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
DataT* a = m_channel[3]; ASSERT(a);
UINT16 b, g, r;
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
b = buff16[cnt + channelMap[0]] >> shift;
g = buff16[cnt + channelMap[1]] >> shift;
r = buff16[cnt + channelMap[2]] >> shift;
// Yuv
y[yPos] = ((b + (g << 1) + r) >> 2) - yuvOffset16;
u[yPos] = r - g;
v[yPos] = b - g;
a[yPos++] = (buff16[cnt + channelMap[3]] >> shift) - yuvOffset16;
cnt += channels;
}
buff16 += pitch16;
}
}
break;
#ifdef __PGF32SUPPORT__
{
ASSERT(bpp == 32);
ASSERT(DataTSize == sizeof(UINT32));
DataT* y = m_channel[0]; ASSERT(y);
UINT32 *buff32 = (UINT32 *)buff;
const int pitch32 = pitch/4;
const int shift = 31 - UsedBitsPerChannel(); ASSERT(shift >= 0);
const DataT yuvOffset31 = 1 << (UsedBitsPerChannel() - 1);
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
for (UINT32 w=0; w < m_header.width; w++) {
y[yPos++] = (buff32[w] >> shift) - yuvOffset31;
}
buff32 += pitch32;
}
}
break;
#endif
{
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
UINT8 rgb = 0, b, g, r;
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
cnt = 0;
for (UINT32 w=0; w < m_header.width; w++) {
if (w%2 == 0) {
// even pixel position
rgb = buff[cnt];
b = rgb & 0x0F;
g = (rgb & 0xF0) >> 4;
cnt++;
rgb = buff[cnt];
r = rgb & 0x0F;
} else {
// odd pixel position
b = (rgb & 0xF0) >> 4;
cnt++;
rgb = buff[cnt];
g = rgb & 0x0F;
r = (rgb & 0xF0) >> 4;
cnt++;
}
// Yuv
y[yPos] = ((b + (g << 1) + r) >> 2) - YUVoffset4;
u[yPos] = r - g;
v[yPos] = b - g;
yPos++;
}
buff += pitch;
}
}
break;
{
ASSERT(bpp == 16);
DataT* y = m_channel[0]; ASSERT(y);
DataT* u = m_channel[1]; ASSERT(u);
DataT* v = m_channel[2]; ASSERT(v);
UINT16 *buff16 = (UINT16 *)buff;
UINT16 rgb, b, g, r;
const int pitch16 = pitch/2;
for (UINT32 h=0; h < m_header.height; h++) {
if (cb) {
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
percent += dP;
}
for (UINT32 w=0; w < m_header.width; w++) {
rgb = buff16[w];
r = (rgb & 0xF800) >> 10; // highest 5 bits
g = (rgb & 0x07E0) >> 5; // middle 6 bits
b = (rgb & 0x001F) << 1; // lowest 5 bits
// Yuv
y[yPos] = ((b + (g << 1) + r) >> 2) - YUVoffset6;
u[yPos] = r - g;
v[yPos] = b - g;
yPos++;
}
buff16 += pitch16;
}
}
break;
default:
ASSERT(false);
}
}
* Set internal PGF image buffer channel* param channel A YUV data channel* param c A channel index* void CPGFImage::SetChannel ( DataT channel,
int  c = 0 
)
inline

Definition at line 276 of file PGFimage.h.

{ ASSERT(c >= 0 && c < MaxChannels); m_channel[c] = channel; }
* Create wavelet transform channels and encoder Write header at current stream position* Call this method before your first call of but after CPGFImage::SetHeader ( )
*Set maximum intensity value for image modes with more than eight bits per channel *Call this method after but before ImportBitmap *param maxValue The maximum intensity value *void CPGFImage::SetMaxValue ( UINT32  maxValue)

Definition at line 684 of file PGFimage.cpp.

{
const BYTE bpc = m_header.bpp/m_header.channels;
BYTE pot = 0;
while(maxValue > 0) {
pot++;
maxValue >>= 1;
}
// store bits per channel
if (pot > bpc) pot = bpc;
if (pot > 31) pot = 31;
}
void CPGFImage::SetROI ( PGFRect  rect)
private
* Read and decode some levels of a PGF image at current stream position* A PGF image is structered in numbered between and containing the same content* as all other but in a different CPGFImage::size ( width  ,
height   
)
* Encode and write a entire PGF numbered between and containing the same content* as all other but in a different CPGFImage::size ( width  ,
height   
)
* Encode and write down to given level at current stream position* A PGF image is structered in numbered between and containing the same content* as all other but in a different CPGFImage::size ( width  ,
height   
)
UINT32 CPGFImage::UpdatePostHeaderSize ( )
private

Definition at line 1044 of file PGFimage.cpp.

{
INT64 offset = m_encoder->ComputeOffset(); ASSERT(offset >= 0);
if (offset > 0) {
// update post-header size and rewrite pre-header
m_preHeader.hSize += (UINT32)offset;
}
// write dummy levelLength into stream
}
* Return the image mode* An image mode is a predefined constant CPGFImage::value ( see also PGFtypes.  h) const
inline

Definition at line 451 of file PGFimage.h.

{ return m_header.mode; }
* Returns images PGF version* return PGF codec version of the image* BYTE CPGFImage::Version ( ) const
inline

Definition at line 476 of file PGFimage.h.

{ return CurrentVersion(m_preHeader.version); }
* Return image width of channel at given level in pixels* The returned width is independent of any Read operations and ROI* param level A level* return Image level width in pixels* UINT32 CPGFImage::Width ( int  level = 0) const
inline

Definition at line 416 of file PGFimage.h.

{ ASSERT(level >= 0); return LevelWidth(m_header.width, level); }
* Compute and return image width at given level* param width Original image CPGFImage::width ( at level  0)
* Import an image from a specified image buffer* This method is usually called before CPGFImage::Write (   ...)
*Encode and write a entire PGF numbered between and containing the same content *as all other but in a different height of the image at level i *The image at level contains the original size then it stops proceeding *param data Data Pointer to C class container to host callback procedure *void CPGFImage::Write ( CPGFStream stream,
UINT32 *  nWrittenBytes = NULL,
CallbackPtr  cb = NULL,
void *  data = NULL 
)

Definition at line 1140 of file PGFimage.cpp.

{
ASSERT(stream);
// create wavelet transform channels and encoder
UINT32 nBytes = WriteHeader(stream);
// write image
nBytes += WriteImage(stream, cb, data);
// return written bytes
if (nWrittenBytes) *nWrittenBytes += nBytes;
}
* Create wavelet transform channels and encoder Write header at current stream position* Call this method before your first call of CPGFImage::Write ( int  level)
* Encode and write down to given level at current stream position* A PGF image is structered in numbered between and containing the same content* as all other but in a different height of the image at level i* The image at level contains the original size nLevels The image level of the resulting image in the internal image buffer* param cb A pointer to a callback procedure The procedure is called after writing a single level If cb returns then it stops proceeding* param data Data Pointer to C class container to host callback procedure* return The number of bytes written into stream* UINT32 CPGFImage::Write ( int  level,
CallbackPtr  cb = NULL,
void *  data = NULL 
)
*Create wavelet transform channels and encoder Write header at current stream position *Call this method before your first call of but after *It might throw an IOException *param stream A PGF stream *return The number of bytes written into stream *UINT32 CPGFImage::WriteHeader ( CPGFStream stream)

Definition at line 917 of file PGFimage.cpp.

{
ASSERT(m_header.quality <= MaxQuality); // quality is already initialized
if (m_header.nLevels > 0) {
volatile OSError error = NoError; // volatile prevents optimizations
// create new wt channels
#pragma omp parallel for default(shared)
for (int i=0; i < m_header.channels; i++) {
DataT *temp = NULL;
if (error == NoError) {
if (m_wtChannel[i]) {
// copy m_channel to temp
int size = m_height[i]*m_width[i];
temp = new(std::nothrow) DataT[size];
if (temp) {
memcpy(temp, m_channel[i], size*DataTSize);
delete m_wtChannel[i]; // also deletes m_channel
} else {
error = InsufficientMemory;
}
}
if (error == NoError) {
if (temp) m_channel[i] = temp;
#ifdef __PGFROISUPPORT__
#endif
// wavelet subband decomposition
for (int l=0; error == NoError && l < m_header.nLevels; l++) {
OSError err = m_wtChannel[i]->ForwardTransform(l, m_quant);
if (err != NoError) error = err;
}
}
}
}
if (error != NoError) ReturnWithError(error);
// create encoder and eventually write headers and levelLength
#ifdef __PGFROISUPPORT__
if (ROIisSupported()) {
// new encoding scheme supporting ROI
m_encoder->SetROI();
}
#endif
} else {
// very small image: we don't use DWT and encoding
// create encoder and eventually write headers and levelLength
}
INT64 nBytes = m_encoder->ComputeHeaderLength();
return (nBytes > 0) ? (UINT32)nBytes : 0;
}
* Encode and write the one and only image at current stream position* Call this method after CPGFImage::WriteHeader ( )
* Encode and write the one and only image at current stream position* Call this method after * then do that after CPGFImage::WriteHeader ( )
*Encode and write the one and only image at current stream position *Call this method after *then do that after *It might throw an IOException *param stream A PGF stream *param cb A pointer to a callback procedure The procedure is called after writing a single level If cb returns then it stops proceeding *param data Data Pointer to C class container to host callback procedure *return The number of bytes written into stream *UINT32 CPGFImage::WriteImage ( CPGFStream stream,
CallbackPtr  cb = NULL,
void *  data = NULL 
)

Definition at line 1069 of file PGFimage.cpp.

{
ASSERT(stream);
double percent = pow(0.25, levels);
// update post-header size, rewrite pre-header, and write dummy levelLength
UINT32 nWrittenBytes = UpdatePostHeaderSize();
if (levels == 0) {
// write channels
for (int c=0; c < m_header.channels; c++) {
const UINT32 size = m_width[c]*m_height[c];
// write channel data into stream
for (UINT32 i=0; i < size; i++) {
stream->Write(&count, &m_channel[c][i]);
}
}
// now update progress
if (cb) {
if ((*cb)(1, true, data)) ReturnWithError(EscapePressed);
}
} else {
// encode quantized wavelet coefficients and write to PGF file
// encode subbands, higher levels first
// color channels are interleaved
// encode all levels
for (m_currentLevel = levels; m_currentLevel > 0; ) {
WriteLevel(); // decrements m_currentLevel
// now update progress
if (cb) {
percent *= 4;
if ((*cb)(percent, true, data)) ReturnWithError(EscapePressed);
}
}
// flush encoder and write level lengths
}
// update level lengths
nWrittenBytes = m_encoder->UpdateLevelLength(); // return written image bytes
// delete encoder
delete m_encoder; m_encoder = NULL;
return nWrittenBytes;
}
void CPGFImage::WriteLevel ( )
private

Definition at line 989 of file PGFimage.cpp.

{
#ifdef __PGFROISUPPORT__
if (ROIisSupported()) {
const int lastChannel = m_header.channels - 1;
for (int i=0; i < m_header.channels; i++) {
// get number of tiles and tile indices
const UINT32 nTiles = m_wtChannel[i]->GetNofTiles(m_currentLevel);
const UINT32 lastTile = nTiles - 1;
// last level also has LL band
ASSERT(nTiles == 1);
m_encoder->EncodeTileBuffer();
}
for (UINT32 tileY=0; tileY < nTiles; tileY++) {
for (UINT32 tileX=0; tileX < nTiles; tileX++) {
if (i == lastChannel && tileY == lastTile && tileX == lastTile) {
// all necessary data are buffered. next call of EncodeBuffer will write the last piece of data of the current level.
m_encoder->SetEncodedLevel(--m_currentLevel);
}
m_encoder->EncodeTileBuffer();
}
}
}
} else
#endif
{
for (int i=0; i < m_header.channels; i++) {
// last level also has LL band
}
//encoder.EncodeInterleaved(m_wtChannel[i], m_currentLevel, m_quant); // until version 4
}
// all necessary data are buffered. next call of EncodeBuffer will write the last piece of data of the current level.
m_encoder->SetEncodedLevel(--m_currentLevel);
}
}

Member Data Documentation

* Set refresh callback procedure and its parameter* The refresh callback is called during void* CPGFImage::arg { m_cb = callback

Definition at line 307 of file PGFimage.h.

* Get image data in interleaved 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 then the image buffer must point to the last row of a bottom up then the image buffer must point to the first row of a top down PGF provides a channel sequence BGR in RGB color mode* If your provided image buffer expects a channel sequence CPGFImage::ARGB

Definition at line 139 of file PGFimage.h.

* Import an image from a specified image buffer* This method is usually called before then buff points to the last row of a bottom up then buff points to the first row of a top down PGF expects in RGB color mode a channel sequence BGR* If your provided image buffer contains a channel sequence CPGFImage::ARGB

Definition at line 174 of file PGFimage.h.

* Return the number of bits per pixel* Valid values can CPGFImage::be

Definition at line 458 of file PGFimage.h.

* Standard CPGFImage::constructor

Definition at line 62 of file PGFimage.h.

* CPGFImage::Destructor

Definition at line 66 of file PGFimage.h.

* Read and decode smallest level of a PGF image at current stream position* For CPGFImage::details

Definition at line 118 of file PGFimage.h.

* Configures the encoder* param useOMP Use parallel threading with Open MP during encoding Default bool CPGFImage::favorSpeedOverSize
Initial value:
* Configures the decoder.
* @param 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.
* @param 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. */
void ConfigureDecoder(bool useOMP = true, bool skipUserData = false) { m_useOMPinDecoder = useOMP; m_skipUserData = skipUserData; }
* Reset stream position to start of PGF pre-header */
void ResetStreamPos() THROW_

Definition at line 260 of file PGFimage.h.

* Set PGF header and user data BYTE CPGFImage::flags = 0

Definition at line 286 of file PGFimage.h.

* Get image data in interleaved CPGFImage::format

Definition at line 132 of file PGFimage.h.

* Get YUV image data in interleaved CPGFImage::format

Definition at line 152 of file PGFimage.h.

* Sets the CPGFImage::green

Definition at line 310 of file PGFimage.h.

* Retrieves CPGFImage::green

Definition at line 324 of file PGFimage.h.

UINT32 CPGFImage::h = (height >> level)

Definition at line 498 of file PGFimage.h.

* Open a PGF image at current stream CPGFImage::header

Definition at line 79 of file PGFimage.h.

* Read and decode smallest level of a PGF image at current stream position* For please refert to Read* (...) * Precondition After you ve written a PGF CPGFImage::image

Definition at line 118 of file PGFimage.h.

* Compute and return image width at given level* param width Original image int CPGFImage::level { ASSERT(level >= 0)

Definition at line 491 of file PGFimage.h.

return* ((w << level) == width) ? w Compute and return image height at given level* param height Original image int CPGFImage::level { ASSERT(level >= 0)

Definition at line 498 of file PGFimage.h.

* Read and decode some levels of a PGF image at current stream position* A PGF image is structered in CPGFImage::levels

Definition at line 91 of file PGFimage.h.

* Read and decode some levels of a PGF image at current stream position* A PGF image is structered in numbered between and containing the same content* as all other CPGFImage::levels

Definition at line 93 of file PGFimage.h.

* Encode and write a entire PGF numbered between and containing the same content* as all other CPGFImage::levels

Definition at line 205 of file PGFimage.h.

* Encode and write down to given level at current stream position* A PGF image is structered in CPGFImage::levels

Definition at line 240 of file PGFimage.h.

* Encode and write down to given level at current stream position* A PGF image is structered in numbered between and containing the same content* as all other CPGFImage::levels

Definition at line 242 of file PGFimage.h.

* Get image data in interleaved 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 then the image buffer must point to the last row of a bottom up then the image buffer must point to the first row of a top down PGF provides a channel sequence BGR in RGB color mode* If your provided image buffer expects a channel sequence then the channelMap looks CPGFImage::like
Initial value:
{ 3, 2, 1, 0 }.
* It might throw an IOException.
* @param pitch The number of bytes of a row of the image buffer.
* @param buff An image buffer.
* @param bpp The number of bits per pixel used in image buffer.
* @param channelMap A integer array containing the mapping of PGF channel ordering to expected channel ordering.
* @param cb A pointer to a callback procedure. The procedure is called after each copied buffer row. If cb returns true

Definition at line 139 of file PGFimage.h.

* Get YUV image data in interleaved then the image buffer must point to the last row of a bottom up then the image buffer must point to the first row of a top down PGF provides a channel sequence BGR in RGB color mode* If your provided image buffer expects a channel sequence then the channelMap looks CPGFImage::like
Initial value:
{ 2, 1, 0 }.
* It might throw an IOException.
* @param pitch The number of bytes of a row of the image buffer.
* @param buff An image buffer.
* @param bpp The number of bits per pixel used in image buffer.
* @param channelMap A integer array containing the mapping of PGF channel ordering to expected channel ordering.
* @param cb A pointer to a callback procedure. The procedure is called after each copied buffer row. If cb returns true

Definition at line 156 of file PGFimage.h.

* Import an image from a specified image buffer* This method is usually called before then buff points to the last row of a bottom up then buff points to the first row of a top down PGF expects in RGB color mode a channel sequence BGR* If your provided image buffer contains a channel sequence then the channelMap looks CPGFImage::like
Initial value:
{ 3, 2, 1, 0 }.
* It might throw an IOException.
* @param pitch The number of bytes of a row of the image buffer.
* @param buff An image buffer.
* @param bpp The number of bits per pixel used in image buffer.
* @param channelMap A integer array containing the mapping of input channel ordering to expected channel ordering.
* @param cb A pointer to a callback procedure. The procedure is called after each imported buffer row. If cb returns true

Definition at line 174 of file PGFimage.h.

* 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 then buff points to the last row of a bottom up then buff points to the first row of a top down PGF expects in RGB color mode a channel sequence BGR* If your provided image buffer contains a channel sequence then the channelMap looks CPGFImage::like
Initial value:
{ 2, 1, 0 }.
* It might throw an IOException.
* @param pitch The number of bytes of a row of the image buffer.
* @param buff An image buffer.
* @param bpp The number of bits per pixel used in image buffer.
* @param channelMap A integer array containing the mapping of input channel ordering to expected channel ordering.
* @param cb A pointer to a callback procedure. The procedure is called after each imported buffer row. If cb returns true

Definition at line 191 of file PGFimage.h.

RefreshCB CPGFImage::m_cb
private

pointer to refresh callback procedure

Definition at line 535 of file PGFimage.h.

CPGFImage::m_cbArg = arg

Definition at line 307 of file PGFimage.h.

void* CPGFImage::m_cbArg
private

refresh callback argument

Definition at line 536 of file PGFimage.h.

DataT* CPGFImage::m_channel[MaxChannels]
protected

untransformed channels in YUV format

Definition at line 512 of file PGFimage.h.

int CPGFImage::m_currentLevel
protected

transform level of current image

Definition at line 522 of file PGFimage.h.

CDecoder* CPGFImage::m_decoder
protected

PGF decoder.

Definition at line 513 of file PGFimage.h.

bool CPGFImage::m_downsample
protected

chrominance channels are downsampled

Definition at line 524 of file PGFimage.h.

CEncoder* CPGFImage::m_encoder
protected

PGF encoder.

Definition at line 514 of file PGFimage.h.

bool CPGFImage::m_favorSpeedOverSize
protected

favor encoding speed over compression ratio

Definition at line 525 of file PGFimage.h.

PGFHeader CPGFImage::m_header
protected

PGF file header.

Definition at line 519 of file PGFimage.h.

UINT32 CPGFImage::m_height[MaxChannels]
protected

height of each channel at current level

Definition at line 517 of file PGFimage.h.

return CPGFImage::m_levelLength[m_header.nLevels-level-1]

Definition at line 370 of file PGFimage.h.

UINT32* CPGFImage::m_levelLength
protected

length of each level in bytes; first level starts immediately after this array

Definition at line 515 of file PGFimage.h.

double CPGFImage::m_percent
private

progress [0..1]

Definition at line 537 of file PGFimage.h.

PGFPostHeader CPGFImage::m_postHeader
protected

PGF post-header.

Definition at line 520 of file PGFimage.h.

PGFPreHeader CPGFImage::m_preHeader
protected

PGF pre-header.

Definition at line 518 of file PGFimage.h.

ProgressMode CPGFImage::m_progressMode
private

progress mode used in Read and Write; PM_Relative is default mode

Definition at line 538 of file PGFimage.h.

BYTE CPGFImage::m_quant
protected

quantization parameter

Definition at line 523 of file PGFimage.h.

PGFRect CPGFImage::m_roi
protected

region of interest

Definition at line 531 of file PGFimage.h.

bool CPGFImage::m_skipUserData
protected

skip user data (metadata) during open

Definition at line 528 of file PGFimage.h.

bool CPGFImage::m_streamReinitialized
protected

stream has been reinitialized

Definition at line 530 of file PGFimage.h.

bool CPGFImage::m_useOMPinDecoder
protected

use Open MP in decoder

Definition at line 527 of file PGFimage.h.

bool CPGFImage::m_useOMPinEncoder
protected

use Open MP in encoder

Definition at line 526 of file PGFimage.h.

UINT64 CPGFImage::m_userDataPos
protected

stream position of user data

Definition at line 521 of file PGFimage.h.

UINT32 CPGFImage::m_width[MaxChannels]
protected

width of each channel at current level

Definition at line 516 of file PGFimage.h.

CWaveletTransform* CPGFImage::m_wtChannel[MaxChannels]
protected

wavelet transformed color channels

Definition at line 511 of file PGFimage.h.

* Sets the UINT32 CPGFImage::nColors

Definition at line 315 of file PGFimage.h.

* Retrieves UINT32 CPGFImage::nColors

Definition at line 329 of file PGFimage.h.

* Get image data in interleaved 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 CPGFImage::negative

Definition at line 132 of file PGFimage.h.

* 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 CPGFImage::negative

Definition at line 187 of file PGFimage.h.

* Open a PGF image at current stream CPGFImage::position

Definition at line 79 of file PGFimage.h.

* Open a PGF image at current stream and ckeck image type* CPGFImage::Precondition

Definition at line 79 of file PGFimage.h.

* Read and decode some levels of a PGF image at current stream position* A PGF image is structered in numbered between and containing the same content* as all other but in a different height of the image at level i* The image at level contains the original size* CPGFImage::Precondition

Definition at line 98 of file PGFimage.h.

* Encode and write a entire PGF numbered between and containing the same content* as all other but in a different height of the image at level i* The image at level contains the original size* CPGFImage::Precondition

Definition at line 212 of file PGFimage.h.

* Set PGF header and user data* CPGFImage::Precondition

Definition at line 286 of file PGFimage.h.

* Return the stream position of the user data or* CPGFImage::Precondition

Definition at line 350 of file PGFimage.h.

* Return user data and size of user data* CPGFImage::Precondition

Definition at line 357 of file PGFimage.h.

* Return the length of all encoded headers in bytes* CPGFImage::Precondition

Definition at line 363 of file PGFimage.h.

* Return the length of an encoded PGF level in bytes* CPGFImage::Precondition

Definition at line 370 of file PGFimage.h.

* Reads the encoded PGF headers and copies it to a target buffer* CPGFImage::Precondition

Definition at line 379 of file PGFimage.h.

* Reads the data of an encoded PGF level and copies it to a target buffer* without decoding* CPGFImage::Precondition

Definition at line 390 of file PGFimage.h.

* Returns number of used bits per input output image channel* CPGFImage::Precondition

Definition at line 471 of file PGFimage.h.

* Encode and write down to given level at current stream position* A PGF image is structered in numbered between and containing the same content* as all other but in a different height of the image at level i* The image at level contains the original size* CPGFImage::Preconditions

Definition at line 249 of file PGFimage.h.

* Sets the CPGFImage::red

Definition at line 310 of file PGFimage.h.

* Retrieves CPGFImage::red

Definition at line 324 of file PGFimage.h.

* Set maximum intensity value for image modes with more than eight bits per channel* Call this method after CPGFImage::SetHeader

Definition at line 290 of file PGFimage.h.

* Reads the data of an encoded PGF level and copies it to a target buffer* without decoding UINT8* CPGFImage::target

Definition at line 390 of file PGFimage.h.

* Sets the UINT32 const RGBQUAD* prgbColors CPGFImage::THROW_

Definition at line 315 of file PGFimage.h.

* Retrieves UINT32 RGBQUAD* prgbColors const CPGFImage::THROW_

Definition at line 329 of file PGFimage.h.

* Reads the encoded PGF headers and copies it to a target buffer UINT32 targetLen const CPGFImage::THROW_

Definition at line 379 of file PGFimage.h.

* Reads the data of an encoded PGF level and copies it to a target buffer* without decoding UINT8 UINT32 targetLen const CPGFImage::THROW_

Definition at line 390 of file PGFimage.h.

* Read and decode some levels of a PGF image at current stream position* A PGF image is structered in numbered between and containing the same content* as all other but in a different height of the image at level i* The image at level contains the original size nLevels The image level of the resulting image in the internal image buffer* param cb A pointer to a callback procedure The procedure is called after reading a single level If cb returns CPGFImage::true

Definition at line 98 of file PGFimage.h.

* 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* param rect [inout] Rectangular region of nLevels The image level of the resulting image in the internal image buffer* param cb A pointer to a callback procedure The procedure is called after reading a single level If cb returns CPGFImage::true

Definition at line 111 of file PGFimage.h.

* Encode and write the one and only image at current stream position* Call this method after * then do that after * It might throw an IOException* param stream A PGF stream* param cb A pointer to a callback procedure The procedure is called after writing a single level If cb returns CPGFImage::true

Definition at line 232 of file PGFimage.h.

* Encode and write down to given level at current stream position* A PGF image is structered in numbered between and containing the same content* as all other but in a different height of the image at level i* The image at level contains the original size nLevels The image level of the resulting image in the internal image buffer* param cb A pointer to a callback procedure The procedure is called after writing a single level If cb returns CPGFImage::true

Definition at line 249 of file PGFimage.h.

* Set PGF header and user data BYTE UINT8* CPGFImage::userData = 0

Definition at line 286 of file PGFimage.h.

* Set PGF header and user data BYTE UINT8 UINT32 CPGFImage::userDataLength = 0) THROW_

Definition at line 286 of file PGFimage.h.

* Configures the encoder* param useOMP Use parallel threading with Open MP during encoding Default CPGFImage::value

Definition at line 260 of file PGFimage.h.

* Get YUV image data in interleaved then the image buffer must point to the last row of a bottom up then the image buffer must point to the first row of a top down PGF provides a channel sequence BGR in RGB color mode* If your provided image buffer expects a channel sequence CPGFImage::VUY

Definition at line 156 of file PGFimage.h.

* 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 then buff points to the last row of a bottom up then buff points to the first row of a top down PGF expects in RGB color mode a channel sequence BGR* If your provided image buffer contains a channel sequence CPGFImage::VUY

Definition at line 191 of file PGFimage.h.

UINT32 CPGFImage::w = (width >> level)

Definition at line 491 of file PGFimage.h.


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