8 #include "jasper/jasper.h"
11 #define MAXOPTSSIZE 1024
50 int ltype,
int ratio,
int retry,
char *outjpc,
53 g2int width8 = width, height8 = height, nbits8 = nbits, ltype8 = ltype;
54 g2int ratio8 = ratio, retry8 = retry, jpclen8 = jpclen;
56 return enc_jpeg2000(cin, width8, height8, nbits8, ltype8, ratio8, retry8,
97 jas_stream_t *jpcstream, *istream;
98 jas_image_cmpt_t cmpt, *pcmpt;
106 snprintf(opts,
MAXOPTSSIZE,
"mode=real\nrate=%f",1.0/(
float)ratio);
109 strcat(opts,
"\nnumgbits=4");
115 image.brx_ = (jas_image_coord_t)width;
116 image.bry_ = (jas_image_coord_t)height;
119 image.clrspc_ = JAS_CLRSPC_SGRAY;
126 cmpt.width_ = (jas_image_coord_t)width;
127 cmpt.height_ = (jas_image_coord_t)height;
128 cmpt.type_ = JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y);
131 cmpt.cps_ = (nbits + 7) / 8;
134 image.cmpts_ = &pcmpt;
142 jas_conf_set_max_mem_usage(10000000);
143 jas_conf_set_multithread(
true);
144 if (jas_init_library())
146 if (jas_init_thread())
154 istream = jas_stream_memopen((
char *)cin, height * width * cmpt.cps_);
155 cmpt.stream_ = istream;
159 jpcstream = jas_stream_memopen(outjpc, (
int)jpclen);
165 if ((ier = jas_image_encode(&image, jpcstream, fmt, opts)))
170 rwcnt = jpcstream->rwcnt_;
173 ier = jas_stream_close(istream);
174 ier = jas_stream_close(jpcstream);
178 jas_cleanup_thread();
179 jas_cleanup_library();
int g2c_enc_jpeg2000(unsigned char *cin, int width, int height, int nbits, int ltype, int ratio, int retry, char *outjpc, size_t jpclen)
This Function encodes a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 ...
#define MAXOPTSSIZE
Maximum size of options.
int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits, g2int ltype, g2int ratio, g2int retry, char *outjpc, g2int jpclen)
This Function encodes a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 ...
#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_ENCODE
In enc_jpeg2000() error encoding image with jasper.