78 #include <jasper/jas_config.h> 80 #include <jasper/jas_stream.h> 81 #include <jasper/jas_types.h> 82 #include <jasper/jas_seq.h> 83 #include <jasper/jas_cm.h> 99 #define JAS_IMAGE_KIBI (JAS_CAST(size_t, 1024)) 100 #define JAS_IMAGE_MEBI (JAS_IMAGE_KIBI * JAS_IMAGE_KIBI) 103 #define JAS_IMAGE_INMEMTHRESH (256 * JAS_IMAGE_MEBI) 109 #define JAS_IMAGE_CT_UNKNOWN 0x10000 110 #define JAS_IMAGE_CT_COLOR(n) ((n) & 0x7fff) 111 #define JAS_IMAGE_CT_OPACITY 0x08000 113 #define JAS_IMAGE_CT_RGB_R 0 114 #define JAS_IMAGE_CT_RGB_G 1 115 #define JAS_IMAGE_CT_RGB_B 2 117 #define JAS_IMAGE_CT_YCBCR_Y 0 118 #define JAS_IMAGE_CT_YCBCR_CB 1 119 #define JAS_IMAGE_CT_YCBCR_CR 2 121 #define JAS_IMAGE_CT_GRAY_Y 0 128 typedef int_fast32_t jas_image_coord_t;
129 #define JAS_IMAGE_COORD_MAX INT_FAST32_MAX 130 #define JAS_IMAGE_COORD_MIN INT_FAST32_MIN 133 typedef int_fast16_t jas_image_colorspc_t;
136 typedef int_fast32_t jas_image_cmpttype_t;
139 typedef int_fast16_t jas_image_smpltype_t;
149 jas_image_coord_t tlx_;
152 jas_image_coord_t tly_;
155 jas_image_coord_t hstep_;
158 jas_image_coord_t vstep_;
161 jas_image_coord_t width_;
164 jas_image_coord_t height_;
179 jas_stream_t *stream_;
185 jas_image_cmpttype_t type_;
194 jas_image_coord_t tlx_;
197 jas_image_coord_t tly_;
200 jas_image_coord_t brx_;
204 jas_image_coord_t bry_;
215 jas_image_cmpt_t **cmpts_;
218 jas_clrspc_t clrspc_;
220 jas_cmprof_t *cmprof_;
232 jas_image_coord_t tlx;
235 jas_image_coord_t tly;
238 jas_image_coord_t hstep;
241 jas_image_coord_t vstep;
244 jas_image_coord_t width;
247 jas_image_coord_t height;
260 } jas_image_cmptparm_t;
266 #define JAS_IMAGE_MAXFMTS 32 273 jas_image_t *(*decode)(jas_stream_t *in,
const char *opts);
276 int (*encode)(jas_image_t *image, jas_stream_t *out,
const char *opts);
279 int (*validate)(jas_stream_t *in);
282 } jas_image_fmtops_t;
300 jas_image_fmtops_t ops;
303 } jas_image_fmtinfo_t;
310 JAS_DLLEXPORT jas_image_t *jas_image_create(
unsigned numcmpts,
311 const jas_image_cmptparm_t *cmptparms, jas_clrspc_t clrspc);
314 JAS_DLLEXPORT jas_image_t *jas_image_create0(
void);
317 JAS_DLLEXPORT jas_image_t *jas_image_copy(jas_image_t *image);
320 JAS_DLLEXPORT
void jas_image_destroy(jas_image_t *image);
323 #define jas_image_width(image) \ 324 ((image)->brx_ - (image)->tlx_) 327 #define jas_image_height(image) \ 328 ((image)->bry_ - (image)->tly_) 332 #define jas_image_tlx(image) \ 337 #define jas_image_tly(image) \ 342 #define jas_image_brx(image) \ 347 #define jas_image_bry(image) \ 351 #define jas_image_numcmpts(image) \ 355 #define jas_image_clrspc(image) \ 359 #define jas_image_setclrspc(image, clrspc) \ 360 ((image)->clrspc_ = (clrspc)) 362 #define jas_image_cmpttype(image, cmptno) \ 363 ((image)->cmpts_[(cmptno)]->type_) 364 #define jas_image_setcmpttype(image, cmptno, type) \ 365 ((image)->cmpts_[(cmptno)]->type_ = (type)) 368 #define jas_image_cmptwidth(image, cmptno) \ 369 ((image)->cmpts_[cmptno]->width_) 372 #define jas_image_cmptheight(image, cmptno) \ 373 ((image)->cmpts_[cmptno]->height_) 376 #define jas_image_cmptsgnd(image, cmptno) \ 377 ((image)->cmpts_[cmptno]->sgnd_) 380 #define jas_image_cmptprec(image, cmptno) \ 381 ((image)->cmpts_[cmptno]->prec_) 384 #define jas_image_cmpthstep(image, cmptno) \ 385 ((image)->cmpts_[cmptno]->hstep_) 388 #define jas_image_cmptvstep(image, cmptno) \ 389 ((image)->cmpts_[cmptno]->vstep_) 392 #define jas_image_cmpttlx(image, cmptno) \ 393 ((image)->cmpts_[cmptno]->tlx_) 396 #define jas_image_cmpttly(image, cmptno) \ 397 ((image)->cmpts_[cmptno]->tly_) 401 #define jas_image_cmptbrx(image, cmptno) \ 402 ((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \ 403 (image)->cmpts_[cmptno]->hstep_) 407 #define jas_image_cmptbry(image, cmptno) \ 408 ((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \ 409 (image)->cmpts_[cmptno]->vstep_) 413 JAS_DLLEXPORT
bool jas_image_cmpt_domains_same(
const jas_image_t *image);
418 JAS_DLLEXPORT uint_fast32_t jas_image_rawsize(
const jas_image_t *image);
421 JAS_DLLEXPORT jas_image_t *jas_image_decode(jas_stream_t *in,
int fmt,
const char *optstr);
424 JAS_DLLEXPORT
int jas_image_encode(jas_image_t *image, jas_stream_t *out,
int fmt,
430 JAS_DLLEXPORT
int jas_image_readcmpt(jas_image_t *image,
unsigned cmptno, jas_image_coord_t x,
431 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
435 JAS_DLLEXPORT
int jas_image_writecmpt(jas_image_t *image,
unsigned cmptno, jas_image_coord_t x,
436 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
437 const jas_matrix_t *data);
440 JAS_DLLEXPORT
void jas_image_delcmpt(jas_image_t *image,
unsigned cmptno);
443 JAS_DLLEXPORT
int jas_image_addcmpt(jas_image_t *image,
int cmptno,
444 const jas_image_cmptparm_t *cmptparm);
447 JAS_DLLEXPORT
int jas_image_copycmpt(jas_image_t *dstimage,
unsigned dstcmptno,
448 jas_image_t *srcimage,
unsigned srccmptno);
451 static inline bool JAS_IMAGE_CDT_GETSGND(uint_least8_t dtype)
453 return (dtype >> 7) & 1;
457 static inline uint_least8_t JAS_IMAGE_CDT_SETSGND(
bool sgnd)
459 return (uint_least8_t)sgnd << 7;
463 static inline uint_least8_t JAS_IMAGE_CDT_GETPREC(uint_least8_t dtype)
469 static inline uint_least8_t JAS_IMAGE_CDT_SETPREC(uint_least8_t dtype)
475 static inline uint_least8_t jas_image_cmptdtype(
const jas_image_t *image,
unsigned cmptno)
477 return JAS_IMAGE_CDT_SETSGND(image->cmpts_[cmptno]->sgnd_) |
478 JAS_IMAGE_CDT_SETPREC(image->cmpts_[cmptno]->prec_);
481 JAS_DLLEXPORT
int jas_image_depalettize(jas_image_t *image,
unsigned cmptno,
unsigned numlutents,
482 const int_fast32_t *lutents,
int dtype,
unsigned newcmptno);
484 JAS_DLLEXPORT
int jas_image_readcmptsample(jas_image_t *image,
unsigned cmptno,
int x,
int y);
485 JAS_DLLEXPORT
void jas_image_writecmptsample(jas_image_t *image,
unsigned cmptno,
int x,
int y,
489 JAS_DLLEXPORT
int jas_image_getcmptbytype(
const jas_image_t *image,
int ctype);
496 JAS_DLLEXPORT
void jas_image_clearfmts(
void);
499 JAS_DLLEXPORT
int jas_image_addfmt(
int id,
const char *name,
const char *ext,
const char *desc,
500 const jas_image_fmtops_t *ops);
504 JAS_DLLEXPORT
int jas_image_strtofmt(
const char *s);
508 JAS_DLLEXPORT
const char *jas_image_fmttostr(
int fmt);
512 JAS_DLLEXPORT
const jas_image_fmtinfo_t *jas_image_lookupfmtbyid(
int id);
516 JAS_DLLEXPORT
const jas_image_fmtinfo_t *jas_image_lookupfmtbyname(
const char *name);
520 JAS_DLLEXPORT
int jas_image_fmtfromname(
const char *filename);
524 JAS_DLLEXPORT
int jas_image_getfmt(jas_stream_t *in);
527 #define jas_image_cmprof(image) ((image)->cmprof_) 529 int jas_image_ishomosamp(
const jas_image_t *image);
530 int jas_image_sampcmpt(jas_image_t *image,
unsigned cmptno,
unsigned newcmptno,
531 jas_image_coord_t ho, jas_image_coord_t vo, jas_image_coord_t hs,
532 jas_image_coord_t vs,
int sgnd,
int prec);
533 int jas_image_writecmpt2(jas_image_t *image,
unsigned cmptno, jas_image_coord_t x,
534 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
536 int jas_image_readcmpt2(jas_image_t *image,
unsigned cmptno, jas_image_coord_t x,
537 jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height,
540 #define jas_image_setcmprof(image, cmprof) ((image)->cmprof_ = cmprof) 541 JAS_DLLEXPORT jas_image_t *jas_image_chclrspc(jas_image_t *image, jas_cmprof_t *outprof,
543 void jas_image_dump(jas_image_t *image, FILE *out);
549 #if !defined(EXCLUDE_JPG_SUPPORT) 551 jas_image_t *jpg_decode(jas_stream_t *in,
const char *optstr);
552 int jpg_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
553 int jpg_validate(jas_stream_t *in);
556 #if !defined(EXCLUDE_MIF_SUPPORT) 558 jas_image_t *mif_decode(jas_stream_t *in,
const char *optstr);
559 int mif_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
560 int mif_validate(jas_stream_t *in);
563 #if !defined(EXCLUDE_PNM_SUPPORT) 565 jas_image_t *pnm_decode(jas_stream_t *in,
const char *optstr);
566 int pnm_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
567 int pnm_validate(jas_stream_t *in);
570 #if !defined(EXCLUDE_RAS_SUPPORT) 572 jas_image_t *ras_decode(jas_stream_t *in,
const char *optstr);
573 int ras_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
574 int ras_validate(jas_stream_t *in);
577 #if !defined(EXCLUDE_BMP_SUPPORT) 579 jas_image_t *bmp_decode(jas_stream_t *in,
const char *optstr);
580 int bmp_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
581 int bmp_validate(jas_stream_t *in);
584 #if !defined(EXCLUDE_JP2_SUPPORT) 586 jas_image_t *jp2_decode(jas_stream_t *in,
const char *optstr);
587 int jp2_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
588 int jp2_validate(jas_stream_t *in);
591 #if !defined(EXCLUDE_JPC_SUPPORT) 593 jas_image_t *jpc_decode(jas_stream_t *in,
const char *optstr);
594 int jpc_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
595 int jpc_validate(jas_stream_t *in);
598 #if !defined(EXCLUDE_PGX_SUPPORT) 600 jas_image_t *pgx_decode(jas_stream_t *in,
const char *optstr);
601 int pgx_encode(jas_image_t *image, jas_stream_t *out,
const char *optstr);
602 int pgx_validate(jas_stream_t *in);