13 #include "jasper/jasper.h"
15 #define MAXOPTSSIZE 1024
63 jas_stream_t *jpcstream, *istream;
64 jas_image_cmpt_t cmpt, *pcmpt;
71 snprintf(opts,
MAXOPTSSIZE,
"mode=real\nrate=%f",1.0/(
float)ratio);
74 strcat(opts,
"\nnumgbits=4");
81 image.brx_ = (uint_fast32_t)width;
82 image.bry_ = (uint_fast32_t)height;
85 image.brx_ = (jas_image_coord_t)width;
86 image.bry_ = (jas_image_coord_t)height;
91 image.colormodel_ = JAS_IMAGE_CM_GRAY;
94 image.clrspc_ = JAS_CLRSPC_SGRAY;
103 cmpt.width_ = (uint_fast32_t)width;
104 cmpt.height_ = (uint_fast32_t)height;
107 cmpt.width_ = (jas_image_coord_t)width;
108 cmpt.height_ = (jas_image_coord_t)height;
109 cmpt.type_ = JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y);
113 cmpt.cps_ = (nbits + 7) / 8;
116 image.cmpts_ = &pcmpt;
119 istream = jas_stream_memopen((
char *)cin, height * width * cmpt.cps_);
120 cmpt.stream_ = istream;
124 jpcstream = jas_stream_memopen(outjpc, (
int)jpclen);
127 if ((ier = jpc_encode(&image, jpcstream, opts)))
129 printf(
" jpc_encode return = %d \n",ier);
134 rwcnt = jpcstream->rwcnt_;
135 ier = jas_stream_close(istream);
136 ier = jas_stream_close(jpcstream);
#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 ...
Header file for NCEPLIBS-g2c library.
int64_t g2int
Long integer type.