78 #include <jasper/jas_config.h> 80 #include <jasper/jas_stream.h> 81 #include <jasper/jas_seq.h> 82 #include <jasper/jas_cm.h> 98 #define JAS_IMAGE_KIBI (JAS_CAST(size_t, 1024)) 99 #define JAS_IMAGE_MEBI (JAS_IMAGE_KIBI * JAS_IMAGE_KIBI) 102 #define JAS_IMAGE_INMEMTHRESH (256 * JAS_IMAGE_MEBI) 108 #define JAS_IMAGE_CT_UNKNOWN 0x10000 109 #define JAS_IMAGE_CT_COLOR(n) ((n) & 0x7fff) 110 #define JAS_IMAGE_CT_OPACITY 0x08000 112 #define JAS_IMAGE_CT_RGB_R 0 113 #define JAS_IMAGE_CT_RGB_G 1 114 #define JAS_IMAGE_CT_RGB_B 2 116 #define JAS_IMAGE_CT_YCBCR_Y 0 117 #define JAS_IMAGE_CT_YCBCR_CB 1 118 #define JAS_IMAGE_CT_YCBCR_CR 2 120 #define JAS_IMAGE_CT_GRAY_Y 0 127 typedef int_fast32_t jas_image_coord_t;
128 #define JAS_IMAGE_COORD_MAX INT_FAST32_MAX 129 #define JAS_IMAGE_COORD_MIN INT_FAST32_MIN 132 typedef int_fast16_t jas_image_colorspc_t;
135 typedef int_fast32_t jas_image_cmpttype_t;
138 typedef int_fast16_t jas_image_smpltype_t;
148 jas_image_coord_t tlx_;
151 jas_image_coord_t tly_;
154 jas_image_coord_t hstep_;
157 jas_image_coord_t vstep_;
160 jas_image_coord_t width_;
163 jas_image_coord_t height_;
178 jas_stream_t *stream_;
184 jas_image_cmpttype_t type_;
193 jas_image_coord_t tlx_;
196 jas_image_coord_t tly_;
199 jas_image_coord_t brx_;
203 jas_image_coord_t bry_;
214 jas_image_cmpt_t **cmpts_;
217 jas_clrspc_t clrspc_;
219 jas_cmprof_t *cmprof_;
231 jas_image_coord_t tlx;
234 jas_image_coord_t tly;
237 jas_image_coord_t hstep;
240 jas_image_coord_t vstep;
243 jas_image_coord_t width;
246 jas_image_coord_t height;
259 } jas_image_cmptparm_t;
265 #define JAS_IMAGE_MAXFMTS 32 272 jas_image_t *(*decode)(jas_stream_t *in,
const char *opts);
275 int (*encode)(jas_image_t *image, jas_stream_t *out,
const char *opts);
278 int (*validate)(jas_stream_t *in);
281 } jas_image_fmtops_t;
299 jas_image_fmtops_t ops;
302 } jas_image_fmtinfo_t;
309 JAS_DLLEXPORT jas_image_t *jas_image_create(
int numcmpts,
310 jas_image_cmptparm_t *cmptparms, jas_clrspc_t clrspc);
313 JAS_DLLEXPORT jas_image_t *jas_image_create0(
void);
316 JAS_DLLEXPORT jas_image_t *jas_image_copy(jas_image_t *image);
319 JAS_DLLEXPORT
void jas_image_destroy(jas_image_t *image);
322 #define jas_image_width(image) \ 323 ((image)->brx_ - (image)->tlx_) 326 #define jas_image_height(image) \ 327 ((image)->bry_ - (image)->tly_) 331 #define jas_image_tlx(image) \ 336 #define jas_image_tly(image) \ 341 #define jas_image_brx(image) \ 346 #define jas_image_bry(image) \ 350 #define jas_image_numcmpts(image) \ 354 #define jas_image_clrspc(image) \ 358 #define jas_image_setclrspc(image, clrspc) \ 359 ((image)->clrspc_ = (clrspc)) 361 #define jas_image_cmpttype(image, cmptno) \ 362 ((image)->cmpts_[(cmptno)]->type_) 363 #define jas_image_setcmpttype(image, cmptno, type) \ 364 ((image)->cmpts_[(cmptno)]->type_ = (type)) 367 #define jas_image_cmptwidth(image, cmptno) \ 368 ((image)->cmpts_[cmptno]->width_) 371 #define jas_image_cmptheight(image, cmptno) \ 372 ((image)->cmpts_[cmptno]->height_) 375 #define jas_image_cmptsgnd(image, cmptno) \ 376 ((image)->cmpts_[cmptno]->sgnd_) 379 #define jas_image_cmptprec(image, cmptno) \ 380 ((image)->cmpts_[cmptno]->prec_) 383 #define jas_image_cmpthstep(image, cmptno) \ 384 ((image)->cmpts_[cmptno]->hstep_) 387 #define jas_image_cmptvstep(image, cmptno) \ 388 ((image)->cmpts_[cmptno]->vstep_) 391 #define jas_image_cmpttlx(image, cmptno) \ 392 ((image)->cmpts_[cmptno]->tlx_) 395 #define jas_image_cmpttly(image, cmptno) \ 396 ((image)->cmpts_[cmptno]->tly_) 400 #define jas_image_cmptbrx(image, cmptno) \ 401 ((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \ 402 (image)->cmpts_[cmptno]->hstep_) 406 #define jas_image_cmptbry(image, cmptno) \ 407 ((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \ 408 (image)->cmpts_[cmptno]->vstep_) 411 JAS_DLLEXPORT
bool jas_image_cmpt_domains_same(jas_image_t *image);
415 JAS_DLLEXPORT uint_fast32_t jas_image_rawsize(jas_image_t *image);
418 JAS_DLLEXPORT jas_image_t *jas_image_decode(jas_stream_t *in,
int fmt,
const char *optstr);
421 JAS_DLLEXPORT
int jas_image_encode(jas_image_t *image, jas_stream_t *out,
int fmt,
427 JAS_DLLEXPORT
int jas_image_readcmpt(jas_image_t *image,
int cmptno, jas_image_coord_t x,
428 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
432 JAS_DLLEXPORT
int jas_image_writecmpt(jas_image_t *image,
int cmptno, jas_image_coord_t x,
433 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
437 JAS_DLLEXPORT
void jas_image_delcmpt(jas_image_t *image,
int cmptno);
440 JAS_DLLEXPORT
int jas_image_addcmpt(jas_image_t *image,
int cmptno,
441 jas_image_cmptparm_t *cmptparm);
444 JAS_DLLEXPORT
int jas_image_copycmpt(jas_image_t *dstimage,
int dstcmptno,
445 jas_image_t *srcimage,
int srccmptno);
447 #define JAS_IMAGE_CDT_GETSGND(dtype) (((dtype) >> 7) & 1) 448 #define JAS_IMAGE_CDT_SETSGND(dtype) (((dtype) & 1) << 7) 449 #define JAS_IMAGE_CDT_GETPREC(dtype) ((dtype) & 0x7f) 450 #define JAS_IMAGE_CDT_SETPREC(dtype) ((dtype) & 0x7f) 452 #define jas_image_cmptdtype(image, cmptno) \ 453 (JAS_IMAGE_CDT_SETSGND((image)->cmpts_[cmptno]->sgnd_) | JAS_IMAGE_CDT_SETPREC((image)->cmpts_[cmptno]->prec_)) 455 JAS_DLLEXPORT
int jas_image_depalettize(jas_image_t *image,
int cmptno,
int numlutents,
456 int_fast32_t *lutents,
int dtype,
int newcmptno);
458 JAS_DLLEXPORT
int jas_image_readcmptsample(jas_image_t *image,
int cmptno,
int x,
int y);
459 JAS_DLLEXPORT
void jas_image_writecmptsample(jas_image_t *image,
int cmptno,
int x,
int y,
462 JAS_DLLEXPORT
int jas_image_getcmptbytype(jas_image_t *image,
int ctype);
469 JAS_DLLEXPORT
void jas_image_clearfmts(
void);
472 JAS_DLLEXPORT
int jas_image_addfmt(
int id,
char *name,
char *ext,
char *desc,
473 jas_image_fmtops_t *ops);
476 JAS_DLLEXPORT
int jas_image_strtofmt(
char *s);
479 JAS_DLLEXPORT
char *jas_image_fmttostr(
int fmt);
482 JAS_DLLEXPORT jas_image_fmtinfo_t *jas_image_lookupfmtbyid(
int id);
485 JAS_DLLEXPORT jas_image_fmtinfo_t *jas_image_lookupfmtbyname(
const char *name);
488 JAS_DLLEXPORT
int jas_image_fmtfromname(
char *filename);
491 JAS_DLLEXPORT
int jas_image_getfmt(jas_stream_t *in);
494 #define jas_image_cmprof(image) ((image)->cmprof_) 495 int jas_image_ishomosamp(jas_image_t *image);
496 int jas_image_sampcmpt(jas_image_t *image,
int cmptno,
int newcmptno,
497 jas_image_coord_t ho, jas_image_coord_t vo, jas_image_coord_t hs,
498 jas_image_coord_t vs,
int sgnd,
int prec);
499 int jas_image_writecmpt2(jas_image_t *image,
int cmptno, jas_image_coord_t x,
500 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
502 int jas_image_readcmpt2(jas_image_t *image,
int cmptno, jas_image_coord_t x,
503 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
506 #define jas_image_setcmprof(image, cmprof) ((image)->cmprof_ = cmprof) 507 JAS_DLLEXPORT jas_image_t *jas_image_chclrspc(jas_image_t *image, jas_cmprof_t *outprof,
509 void jas_image_dump(jas_image_t *image, FILE *out);
515 #if !defined(EXCLUDE_JPG_SUPPORT) 517 jas_image_t *jpg_decode(jas_stream_t *in,
const char *optstr);
518 int jpg_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
519 int jpg_validate(jas_stream_t *in);
522 #if !defined(EXCLUDE_MIF_SUPPORT) 524 jas_image_t *mif_decode(jas_stream_t *in,
const char *optstr);
525 int mif_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
526 int mif_validate(jas_stream_t *in);
529 #if !defined(EXCLUDE_PNM_SUPPORT) 531 jas_image_t *pnm_decode(jas_stream_t *in,
const char *optstr);
532 int pnm_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
533 int pnm_validate(jas_stream_t *in);
536 #if !defined(EXCLUDE_RAS_SUPPORT) 538 jas_image_t *ras_decode(jas_stream_t *in,
const char *optstr);
539 int ras_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
540 int ras_validate(jas_stream_t *in);
543 #if !defined(EXCLUDE_BMP_SUPPORT) 545 jas_image_t *bmp_decode(jas_stream_t *in,
const char *optstr);
546 int bmp_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
547 int bmp_validate(jas_stream_t *in);
550 #if !defined(EXCLUDE_JP2_SUPPORT) 552 jas_image_t *jp2_decode(jas_stream_t *in,
const char *optstr);
553 int jp2_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
554 int jp2_validate(jas_stream_t *in);
557 #if !defined(EXCLUDE_JPC_SUPPORT) 559 jas_image_t *jpc_decode(jas_stream_t *in,
const char *optstr);
560 int jpc_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
561 int jpc_validate(jas_stream_t *in);
564 #if !defined(EXCLUDE_PGX_SUPPORT) 566 jas_image_t *pgx_decode(jas_stream_t *in,
const char *optstr);
567 int pgx_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
568 int pgx_validate(jas_stream_t *in);