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_EasyDecode


You can use this "1-Call" shortcut to quickly add the decoding capabilities to your program.

void* J2K_EasyDecode(char *filename, unsigned char **buffer, int *width, int *height, int *components, char *options);


Parameters

filename
Name of a JPEG 2000 image file.

buffer
Pointer to a variable, where the address of the memory buffer with decoded image will be places.

width
Pointer to a variable, where the width of the image will be placed.

height
Pointer to a variable, where the height of the image will be placed.

components
Pointer to a variable, where the number of components in the image will be placed.

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

Return value

Returns a pointer to an internal object, which represents J2K image or NULL if the function has failed. Use J2K_getLastError() to obtain the error code.

Notes

1. You must not free the buffer yourself. Instead, pass the returned pointer to J2K_Close() and it will do all required cleanup.

2. Unlike C++ Wrapper's easyDecode(), which allows using an external buffer, this function doesn't. The buffer is always allocated inside.

Example

int width, height, components; unsigned char *buffer=0; int size;

void *image = J2K_EasyDecode("test.j2k", &buffer;, &width;, &height;, &components;, NULL);

if(!image) printf("\n J2K-Codec error: %s.\n", J2K_getLastErrorStr());
else
{
   printf("\n Image info: %ux%u, %u component(s).\n", width, height, components);

   /* Use buffer here */

}

J2K_Close(image); /* It is safe to pass NULL here */

See also

List of options
2004-2008 © Alex Saveliev