53 int ltype,
int ratio,
int retry,
char *outjpc,
56 g2int width8 = width, height8 = height, nbits8 = nbits, ltype8 = ltype;
57 g2int ratio8 = ratio, retry8 = retry, jpclen8 = jpclen;
59 return enc_jpeg2000(cin, width8, height8, nbits8, ltype8, ratio8, retry8,
100 jas_stream_t *jpcstream, *istream;
101 jas_image_cmpt_t cmpt, *pcmpt;
105 LOG((3,
"enc_jpeg2000 width %ld height %ld nbits %ld ltype %ld ratio %ld retry %ld jpclen %d",
106 width, height, nbits, ltype, ratio, retry, jpclen));
112 snprintf(opts,
MAXOPTSSIZE,
"mode=real\nrate=%f",1.0/(
float)ratio);
115 strcat(opts,
"\nnumgbits=4");
121 image.brx_ = (jas_image_coord_t)width;
122 image.bry_ = (jas_image_coord_t)height;
125 image.clrspc_ = JAS_CLRSPC_SGRAY;
132 cmpt.width_ = (jas_image_coord_t)width;
133 cmpt.height_ = (jas_image_coord_t)height;
134 cmpt.type_ = JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y);
137 cmpt.cps_ = (nbits + 7) / 8;
140 image.cmpts_ = &pcmpt;
148 jas_conf_set_max_mem_usage(10000000);
149 jas_conf_set_multithread(
true);
150 if (jas_init_library())
152 if (jas_init_thread())
160 istream = jas_stream_memopen((
char *)cin, height * width * cmpt.cps_);
161 cmpt.stream_ = istream;
165 jpcstream = jas_stream_memopen(outjpc, (
int)jpclen);
171 if ((ier = jas_image_encode(&image, jpcstream, fmt, opts)))
176 rwcnt = jpcstream->rwcnt_;
179 ier = jas_stream_close(istream);
180 ier = jas_stream_close(jpcstream);
184 jas_cleanup_thread();
185 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)
Encode a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits, g2int ltype, g2int ratio, g2int retry, char *outjpc, g2int jpclen)
Encode a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....