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;
101 char *g2jaspermaxmem;
107 snprintf(opts,
MAXOPTSSIZE,
"mode=real\nrate=%f",1.0/(
float)ratio);
110 strcat(opts,
"\nnumgbits=4");
116 image.brx_ = (jas_image_coord_t)width;
117 image.bry_ = (jas_image_coord_t)height;
120 image.clrspc_ = JAS_CLRSPC_SGRAY;
127 cmpt.width_ = (jas_image_coord_t)width;
128 cmpt.height_ = (jas_image_coord_t)height;
129 cmpt.type_ = JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y);
132 cmpt.cps_ = (nbits + 7) / 8;
135 image.cmpts_ = &pcmpt;
143 if (( g2jaspermaxmem = getenv(
"G2_JASPER_MAXMEM")) != NULL )
144 jas_conf_set_max_mem_usage(atoi(g2jaspermaxmem));
147 jas_conf_set_multithread(
true);
148 if (jas_init_library())
150 if (jas_init_thread())
158 istream = jas_stream_memopen((
char *)cin, height * width * cmpt.cps_);
159 cmpt.stream_ = istream;
163 jpcstream = jas_stream_memopen(outjpc, (
int)jpclen);
169 if ((ier = jas_image_encode(&image, jpcstream, fmt, opts)))
174 rwcnt = jpcstream->rwcnt_;
177 ier = jas_stream_close(istream);
178 ier = jas_stream_close(jpcstream);
182 jas_cleanup_thread();
183 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.
#define G2C_JASPER_MAX_MEMORY
Max memory size setting for Jasper.