9 #include "jasper/jasper.h"
40 jas_image_t *image = NULL;
41 jas_stream_t *jpcstream;
42 jas_image_cmpt_t *pcmpt;
54 if (( g2jaspermaxmem = getenv(
"G2_JASPER_MAXMEM")) != NULL )
55 jas_conf_set_max_mem_usage(atoi(g2jaspermaxmem));
58 jas_conf_set_multithread(
true);
59 if (jas_init_library())
61 if (jas_init_thread())
70 jpcstream = jas_stream_memopen(injpc, bufsize);
76 if (!(image = jas_image_decode(jpcstream, fmt, opts)))
79 pcmpt = image->cmpts_[0];
104 if (image->numcmpts_ != 1)
109 data = jas_matrix_create(jas_image_height(image), jas_image_width(image));
110 jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image),
111 jas_image_height(image), data);
117 for (i = 0; i < pcmpt->height_; i++)
118 for (
j = 0;
j < pcmpt->width_;
j++)
119 ((
g2int *)outfld)[k++] = data->rows_[i][
j];
123 for (i = 0; i < pcmpt->height_; i++)
124 for (
j = 0;
j < pcmpt->width_;
j++)
125 ((
int *)outfld)[k++] = data->rows_[i][
j];
129 jas_matrix_destroy(data);
130 jas_stream_close(jpcstream);
131 jas_image_destroy(image);
135 jas_cleanup_thread();
136 jas_cleanup_library();
int g2c_dec_jpeg2000(char *injpc, size_t bufsize, int *outfld)
This Function decodes a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
static int int_dec_jpeg2000(char *injpc, g2int bufsize, void *outfld, int out_is_g2int)
This Function decodes a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld)
This Function decodes a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
#define G2C_JASPER_JPEG_FORMAT_NAME
Name of JPEG codec in Jasper.
#define G2_JASPER_INIT
In enc_jpeg2000()/dec_jpeg2000() error initializing jasper library.
#define G2C_JASPER_MAX_MEMORY
Max memory size setting for Jasper.
#define G2_JASPER_DECODE
In dec_jpeg2000() error decoding image with jasper.
#define G2_JASPER_DECODE_COLOR
In dec_jpeg2000() decoded image had multiple color components.