9 #include "jasper/jasper.h"
40 jas_image_t *image = NULL;
41 jas_stream_t *jpcstream;
42 jas_image_cmpt_t *pcmpt;
53 jas_conf_set_max_mem_usage(10000000);
54 jas_conf_set_multithread(
true);
55 if (jas_init_library())
57 if (jas_init_thread())
66 jpcstream = jas_stream_memopen(injpc, bufsize);
72 if (!(image = jas_image_decode(jpcstream, fmt, opts)))
75 pcmpt = image->cmpts_[0];
100 if (image->numcmpts_ != 1)
105 data = jas_matrix_create(jas_image_height(image), jas_image_width(image));
106 jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image),
107 jas_image_height(image), data);
113 for (i = 0; i < pcmpt->height_; i++)
114 for (
j = 0;
j < pcmpt->width_;
j++)
115 ((
g2int *)outfld)[k++] = data->rows_[i][
j];
119 for (i = 0; i < pcmpt->height_; i++)
120 for (
j = 0;
j < pcmpt->width_;
j++)
121 ((
int *)outfld)[k++] = data->rows_[i][
j];
125 jas_matrix_destroy(data);
126 jas_stream_close(jpcstream);
127 jas_image_destroy(image);
131 jas_cleanup_thread();
132 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 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.