Go to the documentation of this file.
77 #include <jasper/jas_config.h>
103 #define JAS_IMAGE_KIBI (JAS_CAST(size_t, 1024))
104 #define JAS_IMAGE_MEBI (JAS_IMAGE_KIBI * JAS_IMAGE_KIBI)
107 #define JAS_IMAGE_INMEMTHRESH (256 * JAS_IMAGE_MEBI)
113 #define JAS_IMAGE_CT_UNKNOWN 0x10000
114 #define JAS_IMAGE_CT_COLOR(n) ((n) & 0x7fff)
115 #define JAS_IMAGE_CT_OPACITY 0x08000
117 #define JAS_IMAGE_CT_RGB_R 0
118 #define JAS_IMAGE_CT_RGB_G 1
119 #define JAS_IMAGE_CT_RGB_B 2
121 #define JAS_IMAGE_CT_YCBCR_Y 0
122 #define JAS_IMAGE_CT_YCBCR_CB 1
123 #define JAS_IMAGE_CT_YCBCR_CR 2
125 #define JAS_IMAGE_CT_GRAY_Y 0
134 #define JAS_IMAGE_COORD_MAX INT_FAST32_MAX
135 #define JAS_IMAGE_COORD_MIN INT_FAST32_MIN
188 jas_stream_t *stream_;
228 jas_clrspc_t clrspc_;
230 jas_cmprof_t *cmprof_;
278 #define JAS_IMAGE_MAXFMTS 32
285 jas_image_t *(*decode)(jas_stream_t *in,
const char *opts);
288 int (*encode)(
jas_image_t *image, jas_stream_t *out,
const char *opts);
291 int (*validate)(jas_stream_t *in);
346 #define jas_image_width(image) \
347 ((image)->brx_ - (image)->tlx_)
352 #define jas_image_height(image) \
353 ((image)->bry_ - (image)->tly_)
359 #define jas_image_tlx(image) \
366 #define jas_image_tly(image) \
373 #define jas_image_brx(image) \
380 #define jas_image_bry(image) \
386 #define jas_image_numcmpts(image) \
392 #define jas_image_clrspc(image) \
398 #define jas_image_setclrspc(image, clrspc) \
399 ((image)->clrspc_ = (clrspc))
401 #define jas_image_cmpttype(image, cmptno) \
402 ((image)->cmpts_[(cmptno)]->type_)
403 #define jas_image_setcmpttype(image, cmptno, type) \
404 ((image)->cmpts_[(cmptno)]->type_ = (type))
409 #define jas_image_cmptwidth(image, cmptno) \
410 ((image)->cmpts_[cmptno]->width_)
415 #define jas_image_cmptheight(image, cmptno) \
416 ((image)->cmpts_[cmptno]->height_)
421 #define jas_image_cmptsgnd(image, cmptno) \
422 ((image)->cmpts_[cmptno]->sgnd_)
427 #define jas_image_cmptprec(image, cmptno) \
428 ((image)->cmpts_[cmptno]->prec_)
433 #define jas_image_cmpthstep(image, cmptno) \
434 ((image)->cmpts_[cmptno]->hstep_)
439 #define jas_image_cmptvstep(image, cmptno) \
440 ((image)->cmpts_[cmptno]->vstep_)
445 #define jas_image_cmpttlx(image, cmptno) \
446 ((image)->cmpts_[cmptno]->tlx_)
451 #define jas_image_cmpttly(image, cmptno) \
452 ((image)->cmpts_[cmptno]->tly_)
458 #define jas_image_cmptbrx(image, cmptno) \
459 ((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \
460 (image)->cmpts_[cmptno]->hstep_)
466 #define jas_image_cmptbry(image, cmptno) \
467 ((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \
468 (image)->cmpts_[cmptno]->vstep_)
535 static inline bool JAS_IMAGE_CDT_GETSGND(uint_least8_t dtype)
537 return (dtype >> 7) & 1;
541 static inline uint_least8_t JAS_IMAGE_CDT_SETSGND(
bool sgnd)
543 return (uint_least8_t)sgnd << 7;
547 static inline uint_least8_t JAS_IMAGE_CDT_GETPREC(uint_least8_t dtype)
553 static inline uint_least8_t JAS_IMAGE_CDT_SETPREC(uint_least8_t dtype)
559 static inline uint_least8_t jas_image_cmptdtype(
const jas_image_t *image,
unsigned cmptno)
561 return JAS_IMAGE_CDT_SETSGND(image->cmpts_[cmptno]->sgnd_) |
562 JAS_IMAGE_CDT_SETPREC(image->cmpts_[cmptno]->prec_);
570 unsigned numlutents,
const int_fast32_t *lutents,
unsigned dtype,
585 unsigned x,
unsigned y, int_fast32_t v);
657 #define jas_image_cmprof(image) ((image)->cmprof_)
692 #define jas_image_setcmprof(image, cmprof) ((image)->cmprof_ = cmprof)
698 jas_cmxform_intent_t intent);
709 #if defined(JAS_INCLUDE_JPG_CODEC)
711 JAS_DLLEXPORT
jas_image_t *jpg_decode(jas_stream_t *in,
const char *optstr);
712 JAS_DLLEXPORT
int jpg_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
713 JAS_DLLEXPORT
int jpg_validate(jas_stream_t *in);
716 #if defined(JAS_INCLUDE_MIF_CODEC)
718 JAS_DLLEXPORT
jas_image_t *mif_decode(jas_stream_t *in,
const char *optstr);
719 JAS_DLLEXPORT
int mif_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
720 JAS_DLLEXPORT
int mif_validate(jas_stream_t *in);
723 #if defined(JAS_INCLUDE_PNM_CODEC)
725 JAS_DLLEXPORT
jas_image_t *pnm_decode(jas_stream_t *in,
const char *optstr);
726 JAS_DLLEXPORT
int pnm_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
727 JAS_DLLEXPORT
int pnm_validate(jas_stream_t *in);
730 #if defined(JAS_INCLUDE_RAS_CODEC)
732 JAS_DLLEXPORT
jas_image_t *ras_decode(jas_stream_t *in,
const char *optstr);
733 JAS_DLLEXPORT
int ras_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
734 JAS_DLLEXPORT
int ras_validate(jas_stream_t *in);
737 #if defined(JAS_INCLUDE_BMP_CODEC)
739 JAS_DLLEXPORT
jas_image_t *bmp_decode(jas_stream_t *in,
const char *optstr);
740 JAS_DLLEXPORT
int bmp_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
741 JAS_DLLEXPORT
int bmp_validate(jas_stream_t *in);
744 #if defined(JAS_INCLUDE_JP2_CODEC)
746 JAS_DLLEXPORT
jas_image_t *jp2_decode(jas_stream_t *in,
const char *optstr);
747 JAS_DLLEXPORT
int jp2_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
748 JAS_DLLEXPORT
int jp2_validate(jas_stream_t *in);
751 #if defined(JAS_INCLUDE_JPC_CODEC)
753 JAS_DLLEXPORT
jas_image_t *jpc_decode(jas_stream_t *in,
const char *optstr);
754 JAS_DLLEXPORT
int jpc_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
755 JAS_DLLEXPORT
int jpc_validate(jas_stream_t *in);
758 #if defined(JAS_INCLUDE_PGX_CODEC)
760 JAS_DLLEXPORT
jas_image_t *pgx_decode(jas_stream_t *in,
const char *optstr);
761 JAS_DLLEXPORT
int pgx_encode(
jas_image_t *image, jas_stream_t *out,
const char *optstr);
762 JAS_DLLEXPORT
int pgx_validate(jas_stream_t *in);
void jas_image_destroy(jas_image_t *image)
Deallocate any resources associated with an image.
Definition: jas_image.c:303
int jas_image_copycmpt(jas_image_t *dstimage, unsigned dstcmptno, jas_image_t *srcimage, unsigned srccmptno)
Copy a component from one image to another.
Definition: jas_image.c:974
jas_image_t * jas_image_create0()
Create an "empty" image.
Definition: jas_image.c:202
jas_image_t * jas_image_chclrspc(jas_image_t *image, const jas_cmprof_t *outprof, jas_cmxform_intent_t intent)
Change the color space for an image.
Definition: jas_image.c:1458
void jas_image_delcmpt(jas_image_t *image, unsigned cmptno)
Delete a component from an image.
Definition: jas_image.c:830
#define jas_stream_putc(stream, c)
jas_stream_putc Write a character to a stream.
Definition: jas_stream.h:551
int_fast16_t jas_image_smpltype_t
Component sample data format (e.g., real/integer, signedness, precision).
Definition: jas_image.h:151
#define jas_image_cmptprec(image, cmptno)
Get the precision of the sample data for a component.
Definition: jas_image.h:427
#define JAS_IMAGE_MAXFMTS
The maximum number of image data formats supported.
Definition: jas_image.h:278
#define jas_image_cmprof(image)
Get the color management profile of an image.
Definition: jas_image.h:657
int_fast32_t jas_image_coord_t
Image coordinate.
Definition: jas_image.h:133
const jas_image_fmtinfo_t * jas_image_lookupfmtbyname(const char *name)
Lookup image format information by the format name.
Definition: jas_image.c:889
Image component class.
Definition: jas_image.h:160
unsigned jas_stream_read(jas_stream_t *stream, void *buf, unsigned cnt)
Read characters from a stream into a buffer.
Definition: jas_stream.c:670
#define jas_image_numcmpts(image)
Get the number of image components.
Definition: jas_image.h:386
int jas_stream_close(jas_stream_t *stream)
Close a stream.
Definition: jas_stream.c:610
#define jas_image_cmptvstep(image, cmptno)
Get the vertical subsampling factor for a component.
Definition: jas_image.h:439
int jas_image_readcmpt(jas_image_t *image, unsigned cmptno, jas_image_coord_t x, jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height, jas_matrix_t *data)
Read a rectangular region of an image component.
Definition: jas_image.c:470
int jas_image_depalettize(jas_image_t *image, unsigned cmptno, unsigned numlutents, const int_fast32_t *lutents, unsigned dtype, unsigned newcmptno)
Depalettize an image.
Definition: jas_image.c:1025
int jas_image_addcmpt(jas_image_t *image, int cmptno, const jas_image_cmptparm_t *cmptparm)
Add a component to an image.
Definition: jas_image.c:845
int jas_image_getfmt(jas_stream_t *in)
Get the format of image data in a stream.
Definition: jas_image.c:753
#define jas_image_cmpthstep(image, cmptno)
Get the horizontal subsampling factor for a component.
Definition: jas_image.h:433
#define jas_image_cmptheight(image, cmptno)
Get the height of a component.
Definition: jas_image.h:415
int_fast16_t jas_image_colorspc_t
Color space (e.g., RGB, YCbCr).
Definition: jas_image.h:140
int jas_image_ishomosamp(const jas_image_t *image)
???
Definition: jas_image.c:1308
int jas_image_readcmptsample(jas_image_t *image, unsigned cmptno, unsigned x, unsigned y)
Read a component sample for an image.
Definition: jas_image.c:1067
int jas_image_strtofmt(const char *name)
Get the ID for the image format with the specified name.
Definition: jas_image.c:735
int jas_stream_rewind(jas_stream_t *stream)
Seek to the beginning of a stream.
Definition: jas_stream.c:885
jas_stream_t * jas_stream_memopen2(char *buf, size_t bufsize)
Definition: jas_stream.c:189
jas_image_t * jas_image_copy(jas_image_t *image)
Clone an image.
Definition: jas_image.c:224
int jas_image_sampcmpt(jas_image_t *image, unsigned cmptno, unsigned newcmptno, jas_image_coord_t ho, jas_image_coord_t vo, jas_image_coord_t hs, jas_image_coord_t vs, int sgnd, unsigned prec)
???
Definition: jas_image.c:1211
int jas_image_writecmpt(jas_image_t *image, unsigned cmptno, jas_image_coord_t x, jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height, const jas_matrix_t *data)
Write a rectangular region of an image component.
Definition: jas_image.c:570
jas_stream_t * jas_stream_memopen(char *buf, int bufsize)
Open a memory buffer as a stream.
Definition: jas_stream.c:276
const char * jas_image_fmttostr(int fmt)
Get the name of the image format with the specified ID.
Definition: jas_image.c:744
#define jas_image_setclrspc(image, clrspc)
Set the color model for an image.
Definition: jas_image.h:398
#define jas_stream_getc(stream)
jas_stream_getc Read a character from a stream.
Definition: jas_stream.h:540
JasPer Debugging-Related Functionality.
#define jas_image_cmptwidth(image, cmptno)
Get the width of a component.
Definition: jas_image.h:409
uint_fast32_t jas_image_rawsize(const jas_image_t *image)
Get the raw size of an image (i.e., the nominal size of the image without any compression.
Definition: jas_image.c:816
int jas_image_addfmt(int id, const char *name, const char *ext, const char *desc, const jas_image_fmtops_t *ops)
Add entry to table of image formats.
Definition: jas_image.c:687
jas_image_t * jas_image_create(unsigned numcmpts, const jas_image_cmptparm_t *cmptparms, jas_clrspc_t clrspc)
Create an image.
Definition: jas_image.c:127
Image format-dependent operations.
Definition: jas_image.h:283
int_fast32_t jas_image_cmpttype_t
Component type (e.g., color, opacity).
Definition: jas_image.h:145
long jas_stream_seek(jas_stream_t *stream, long offset, int origin)
Set the current position within the stream.
Definition: jas_stream.c:891
#define jas_image_cmptsgnd(image, cmptno)
Get the signedness of the sample data for a component.
Definition: jas_image.h:421
int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt, const char *optstr)
Write an image to a stream in a specified format.
Definition: jas_image.c:454
const jas_image_fmtinfo_t * jas_image_lookupfmtbyid(int id)
Lookup image format information by the format ID.
Definition: jas_image.c:876
int jas_image_readcmpt2(jas_image_t *image, unsigned cmptno, jas_image_coord_t x, jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height, long *buf)
Read sample data in a component of an image.
Definition: jas_image.c:1142
unsigned jas_stream_write(jas_stream_t *stream, const void *buf, unsigned cnt)
Write characters from a buffer to a stream.
Definition: jas_stream.c:735
void jas_image_clearfmts()
Clear the table of image formats.
Definition: jas_image.c:666
jas_image_t * jas_image_decode(jas_stream_t *in, int fmt, const char *optstr)
Create an image from a stream in some specified format.
Definition: jas_image.c:416
int jas_stream_copy(jas_stream_t *out, jas_stream_t *in, int n)
Copy data from one stream to another.
Definition: jas_stream.c:1129
#define jas_image_clrspc(image)
Get the color model used by the image.
Definition: jas_image.h:392
int jas_image_writecmpt2(jas_image_t *image, unsigned cmptno, jas_image_coord_t x, jas_image_coord_t y, jas_image_coord_t width, jas_image_coord_t height, const long *buf)
Write sample data in a component of an image.
Definition: jas_image.c:1177
Image class.
Definition: jas_image.h:202
void jas_image_writecmptsample(jas_image_t *image, unsigned cmptno, unsigned x, unsigned y, int_fast32_t v)
Write a component sample for an image.
Definition: jas_image.c:1089
Image format information.
Definition: jas_image.h:299
jas_stream_t * jas_stream_tmpfile()
Open a temporary file as a stream.
Definition: jas_stream.c:490
int jas_image_fmtfromname(const char *name)
Guess the format of an image file based on its name.
Definition: jas_image.c:774
#define jas_image_setcmprof(image, cmprof)
Set the color management profile for an image.
Definition: jas_image.h:692
int jas_image_getcmptbytype(const jas_image_t *image, jas_image_cmpttype_t ctype)
Get an image component by its type.
Definition: jas_image.c:1112
Component parameters class.
Definition: jas_image.h:243
bool jas_image_cmpt_domains_same(const jas_image_t *image)
Test if all components are specified at the same positions in space.
Definition: jas_image.c:799
void jas_image_dump(jas_image_t *image, FILE *out)
Dump the information for an image (for debugging).
Definition: jas_image.c:997