J2K-Codec ™

News
Overview
Download
Order
F.A.Q.
More info
Support
Links

Welcome
QuickStart

ActiveX Control

C++ Wrapper
J2K_Image
open
easyDecode
selectTiles
getMetaData
decode
close
J2K_Frames
open
getFrames
getFrame
operators
close

API Reference
General
getVersion
getLastError
getErrorStr
getLastErrorStr
Unlock
Open / Close
Open
Close
Info
GetInfo
GetInfoEx
GetResolutions
GetResDimensions
GetMetaData
Decoding
EasyDecode
SelectTiles
Decode
Cancel
Debug
StartLogging
StopLogging


J2K_Image::decode


Use this function to decode a J2K image, opened by J2K_Image::open() function.

int decode(char *options=0);


Parameters

options
Options string. See the list of valid options here.

Return value

Returns J2KERR_SUCCESS or an error code if the function has failed. See the list of error codes here.

Notes

1. Before using this function you must call J2K_Image::open().

2. By default the buffer member of the J2K_Image class is NULL so the buffer will be allocated inside this function.
You may override this behavior by setting the buffer member to point to your own buffer before the call.
Note, that in this case you also need to set size and pitch members and add "bpp" option into the options string to specify the bytes-per-pixel value of your buffer.

3. If the buffer is allocated inside, then by default it will have 1 byte per pixel for grayscale images and 4 bytes per pixel for color images. You can change the default BPP using the options string.

4. You must not free the buffer if it was allocated inside. It will be automatically destroyed in J2K_Image::close() function.

5. If you have allocated the buffer yourself, then you must free it as well. For calculating the buffer size see "Calculating buffer size" section.

Example

J2K_Image image;

int j2k_err = image.open("test.j2k");
if(j2k_err!=J2KERR_SUCCESS){ printf("\n J2K-Codec error: %s.\n", image.errStr); return -1; }

j2k_err = image.decode("bpp=3");
if(j2k_err != J2KERR_SUCCESS){ printf("\n J2K-Codec error: %s.\n", image.errStr); return -1; }

// Use image.buffer here

image.close();

See also

J2K_Image::open()

J2K_Image class
2004-2008 © Alex Saveliev