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_Decode


Use this function to decode J2K image, opened by J2K_Open(). The decoded image is placed into the memory buffer.

int J2K_Decode(void *image, unsigned char **buffer, int *size, char *options=0, int *pitch=0);


Parameters

image
A pointer, obtained from the J2K_Open() function.

buffer
Pointer to a variable, which stores the destination buffer address. If the variable is null, then the buffer will be allocated and its address will be put into the variable.

size
Pointer to a variable, which stores the size of the destination buffer. If the buffer is allocated inside J2K_Decode(), then this variable will be filled with the buffer size.

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

pitch
Pointer to a variable, which stores the buffer pitch - distance, in bytes, to the start of next line. Useful if the decoded image is a part of a larger picture or a larger buffer.
For example, if you decode an image into a DirectX surface, you will need to use this parameter.
If pitch is null, then Width*Components value will be used. If buffer is allocated inside, then this variable will be filled with the correct pitch.

Return value

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

Notes

1. You must not free the buffer if it was allocated inside this function. It will be automatically destroyed in J2K_Close().

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

3. For the plain C programs all arguments are mandatory. If you are not using options or pitch, simply pass NULL instead.

Example

unsigned char *buffer=0; int size;

int j2k_err = J2K_Decode(image, &buffer;, &size;);

if(j2k_err != J2KERR_SUCCESS) printf("\n J2K-Codec error: %s.", J2K_getErrorStr(j2k_err));

See also

J2K_Open()

List of options

Calculating buffer size
2004-2008 © Alex Saveliev