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
135 #define JAS_IMAGE_COORD_MAX INT_FAST32_MAX
136 #define JAS_IMAGE_COORD_MIN INT_FAST32_MIN
293 #define JAS_IMAGE_MAXFMTS 32
374 #define jas_image_width(image) \
375 ((image)->brx_ - (image)->tlx_)
380 #define jas_image_height(image) \
381 ((image)->bry_ - (image)->tly_)
387 #define jas_image_tlx(image) \
394 #define jas_image_tly(image) \
401 #define jas_image_brx(image) \
408 #define jas_image_bry(image) \
414 #define jas_image_numcmpts(image) \
420 #define jas_image_clrspc(image) \
426 #define jas_image_setclrspc(image, clrspc) \
427 ((image)->clrspc_ = (clrspc))
429 #define jas_image_cmpttype(image, cmptno) \
430 ((image)->cmpts_[(cmptno)]->type_)
431 #define jas_image_setcmpttype(image, cmptno, type) \
432 ((image)->cmpts_[(cmptno)]->type_ = (type))
437 #define jas_image_cmptwidth(image, cmptno) \
438 ((image)->cmpts_[cmptno]->width_)
443 #define jas_image_cmptheight(image, cmptno) \
444 ((image)->cmpts_[cmptno]->height_)
449 #define jas_image_cmptsgnd(image, cmptno) \
450 ((image)->cmpts_[cmptno]->sgnd_)
455 #define jas_image_cmptprec(image, cmptno) \
456 ((image)->cmpts_[cmptno]->prec_)
461 #define jas_image_cmpthstep(image, cmptno) \
462 ((image)->cmpts_[cmptno]->hstep_)
467 #define jas_image_cmptvstep(image, cmptno) \
468 ((image)->cmpts_[cmptno]->vstep_)
473 #define jas_image_cmpttlx(image, cmptno) \
474 ((image)->cmpts_[cmptno]->tlx_)
479 #define jas_image_cmpttly(image, cmptno) \
480 ((image)->cmpts_[cmptno]->tly_)
486 #define jas_image_cmptbrx(image, cmptno) \
487 ((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \
488 (image)->cmpts_[cmptno]->hstep_)
494 #define jas_image_cmptbry(image, cmptno) \
495 ((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \
496 (image)->cmpts_[cmptno]->vstep_)
567 static inline bool JAS_IMAGE_CDT_GETSGND(uint_least8_t dtype)
569 return (dtype >> 7) & 1;
573 static inline uint_least8_t JAS_IMAGE_CDT_SETSGND(
bool sgnd)
575 return (uint_least8_t)sgnd << 7;
579 static inline uint_least8_t JAS_IMAGE_CDT_GETPREC(uint_least8_t dtype)
585 static inline uint_least8_t JAS_IMAGE_CDT_SETPREC(uint_least8_t dtype)
591 static inline uint_least8_t jas_image_cmptdtype(
const jas_image_t *image,
594 return JAS_IMAGE_CDT_SETSGND(image->cmpts_[cmptno]->sgnd_) |
595 JAS_IMAGE_CDT_SETPREC(image->cmpts_[cmptno]->prec_);
603 unsigned numlutents,
const int_fast32_t *lutents,
unsigned dtype,
618 unsigned x,
unsigned y, int_fast32_t v);
637 #if defined(JAS_FOR_INTERNAL_USE_ONLY)
639 size_t *image_numfmts);
656 int jas_image_delfmtbyid(
int id);
672 int jas_image_getfmtindbyname(
const char* name);
682 #if defined(JAS_FOR_INTERNAL_USE_ONLY)
684 size_t *image_numfmts,
int id,
const char *name,
const char *ext,
736 #define jas_image_cmprof(image) ((image)->cmprof_)
773 #define jas_image_setcmprof(image, cmprof) ((image)->cmprof_ = cmprof)
792 #if defined(JAS_INCLUDE_JPG_CODEC)
802 #if defined(JAS_INCLUDE_HEIC_CODEC)
812 #if defined(JAS_INCLUDE_MIF_CODEC)
822 #if defined(JAS_INCLUDE_PNM_CODEC)
832 #if defined(JAS_INCLUDE_RAS_CODEC)
842 #if defined(JAS_INCLUDE_BMP_CODEC)
852 #if defined(JAS_INCLUDE_JP2_CODEC)
862 #if defined(JAS_INCLUDE_JPC_CODEC)
872 #if defined(JAS_INCLUDE_PGX_CODEC)
JasPer Initialization/Cleanup Code.
void jas_image_delcmpt(jas_image_t *image, unsigned cmptno)
Delete a component from an image.
Definition: jas_image.c:932
JAS_EXPORT int jas_logwarnf(const char *fmt,...)
Generate a warning log message.
Definition: jas_debug.c:131
JAS_EXPORT int jas_stringtokenize(const char *string, const char *delim, char ***tokens_buf, size_t *max_tokens_buf, size_t *num_tokens_buf)
Split a string into tokens based on specified delimiters.
Definition: jas_string.c:135
#define jas_cmprof_clrspc(prof)
Get the color space associated with a color-management profile.
Definition: jas_cm.h:489
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:1220
int(* validate)(jas_stream_t *in)
Definition: jas_image.h:307
#define jas_image_cmptvstep(image, cmptno)
Get the vertical subsampling factor for a component.
Definition: jas_image.h:467
int id
Definition: jas_image.h:317
#define jas_stream_putc(stream, c)
jas_stream_putc Write a character to a stream.
Definition: jas_stream.h:575
JAS_EXPORT int jas_logerrorf(const char *fmt,...)
Generate an error log message.
Definition: jas_debug.c:119
const jas_image_fmtinfo_t * jas_image_lookupfmtbyname(const char *name)
Lookup image format information by the format name.
Definition: jas_image.c:993
jas_image_t * jas_image_copy(jas_image_t *image)
Clone an image.
Definition: jas_image.c:223
int_fast32_t jas_image_cmpttype_t
Component type (e.g., color, opacity).
Definition: jas_image.h:146
jas_cmprof_t * jas_cmprof_createfromclrspc(jas_clrspc_t clrspc)
Create a color-management profile from a color space.
Definition: jas_cm.c:169
int jas_stream_copy(jas_stream_t *out, jas_stream_t *in, ssize_t n)
Copy data from one stream to another.
Definition: jas_stream.c:1100
Image component class.
Definition: jas_image.h:168
unsigned jas_clrspc_numchans(jas_clrspc_t clrspc)
Get the number of channels associated with a particular color space.
Definition: jas_cm.c:1388
#define jas_image_cmptsgnd(image, cmptno)
Get the signedness of the sample data for a component.
Definition: jas_image.h:449
int jas_image_dump(jas_image_t *image, FILE *out)
Dump the information for an image (for debugging).
Definition: jas_image.c:1102
int jas_image_strtofmt(const char *name)
Get the ID for the image format with the specified name.
Definition: jas_image.c:835
void * jas_realloc2(void *ptr, size_t num_elements, size_t element_size)
Resize a block of allocated memory (with overflow checking).
Definition: jas_malloc.c:231
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:918
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:485
JAS_EXPORT int jas_eprintf(const char *fmt,...)
Print formatted text for the standard error stream (i.e., stderr).
Definition: jas_debug.c:96
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:1079
int jas_cmxform_apply(const jas_cmxform_t *xform, const jas_cmpixmap_t *in, jas_cmpixmap_t *out)
Apply a transform to data.
Definition: jas_cm.c:540
#define jas_clrspc_isunknown(clrspc)
Test if a color space is unknown.
Definition: jas_cm.h:166
I/O stream object.
Definition: jas_stream.h:206
void * jas_alloc2(size_t num_elements, size_t element_size)
Allocate array (with overflow checking).
Definition: jas_malloc.c:212
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:1197
#define jas_clrspc_isgeneric(clrspc)
Test if a color space is generic.
Definition: jas_cm.h:160
static JAS_ATTRIBUTE_PURE jas_matind_t jas_matrix_numcols(const jas_matrix_t *matrix)
Get the number of columns in a matrix.
Definition: jas_seq.h:196
int jas_image_fmtfromname(const char *name)
Guess the format of an image file based on its name.
Definition: jas_image.c:875
int_fast16_t jas_image_smpltype_t
Component sample data format (e.g., real/integer, signedness, precision).
Definition: jas_image.h:152
jas_cmprof_t * jas_cmprof_copy(const jas_cmprof_t *prof)
Copy a color-management profile.
Definition: jas_cm.c:395
#define JAS_CLRSPC_UNKNOWN
Specific color spaces.
Definition: jas_cm.h:183
Component format.
Definition: jas_cm.h:218
jas_image_fmtops_t ops
Definition: jas_image.h:338
char * desc
Definition: jas_image.h:335
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:1313
jas_stream_t * jas_stream_memopen(char *buf, size_t bufsize)
Open a memory buffer as a stream.
Definition: jas_stream.c:203
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:1275
int(* encode)(jas_image_t *image, jas_stream_t *out, const char *opts)
Definition: jas_image.h:304
int jas_stream_rewind(jas_stream_t *stream)
Seek to the beginning of a stream.
Definition: jas_stream.c:858
#define jas_image_cmpthstep(image, cmptno)
Get the horizontal subsampling factor for a component.
Definition: jas_image.h:461
static JAS_ATTRIBUTE_PURE jas_matind_t jas_matrix_numrows(const jas_matrix_t *matrix)
Get the number of rows in a matrix.
Definition: jas_seq.h:187
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:126
char ** exts
Definition: jas_image.h:327
jas_image_t *(* decode)(jas_stream_t *in, const char *opts)
Definition: jas_image.h:301
size_t jas_stream_read(jas_stream_t *stream, void *buf, size_t cnt)
Read characters from a stream into a buffer.
Definition: jas_stream.c:650
JAS_EXPORT void * jas_malloc(size_t size)
Allocate memory.
Definition: jas_malloc.c:136
#define JAS_IMAGE_MAXFMTS
The maximum number of image data formats supported.
Definition: jas_image.h:293
size_t jas_stream_write(jas_stream_t *stream, const void *buf, size_t cnt)
Write characters from a buffer to a stream.
Definition: jas_stream.c:719
void jas_cmprof_destroy(jas_cmprof_t *prof)
Destroy a color-management profile.
Definition: jas_cm.c:381
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:901
#define jas_image_cmptwidth(image, cmptno)
Get the width of a component.
Definition: jas_image.h:437
Pixmap (i.e., multicomponent) format.
Definition: jas_cm.h:230
const jas_image_fmtinfo_t * jas_image_lookupfmtbyid(int id)
Lookup image format information by the format ID.
Definition: jas_image.c:978
const char * jas_image_fmttostr(int fmt)
Get the name of the image format with the specified ID.
Definition: jas_image.c:844
#define jas_image_setcmprof(image, cmprof)
Set the color management profile for an image.
Definition: jas_image.h:773
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:1236
#define jas_image_setclrspc(image, clrspc)
Set the color model for an image.
Definition: jas_image.h:426
jas_stream_t * jas_stream_tmpfile()
Open a temporary file as a stream.
Definition: jas_stream.c:471
#define jas_image_cmprof(image)
Get the color management profile of an image.
Definition: jas_image.h:736
long jas_stream_seek(jas_stream_t *stream, long offset, int origin)
Set the current position within the stream.
Definition: jas_stream.c:864
JAS_EXPORT int jas_image_getnumfmts(void)
Get the number of image format table entries.
Definition: jas_image.c:730
jas_image_t * jas_image_create0()
Create an "empty" image.
Definition: jas_image.c:201
JasPer Debugging-Related Functionality.
int jas_image_getfmt(jas_stream_t *in)
Get the format of image data in a stream.
Definition: jas_image.c:853
char * jas_strdup(const char *s)
Create a copy of a null-terminated string.
Definition: jas_string.c:89
int jas_stream_close(jas_stream_t *stream)
Close a stream.
Definition: jas_stream.c:591
Image format-dependent operations.
Definition: jas_image.h:298
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:588
#define jas_image_numcmpts(image)
Get the number of image components.
Definition: jas_image.h:414
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:947
JAS_EXPORT void jas_free(void *ptr)
Free memory.
Definition: jas_malloc.c:186
const JAS_EXPORT jas_image_fmtinfo_t * jas_image_getfmtbyind(int index)
Get a image format entry by its table index.
Definition: jas_image.c:722
int enabled
Definition: jas_image.h:332
static JAS_ATTRIBUTE_PURE jas_seqent_t * jas_matrix_getref(const jas_matrix_t *matrix, jas_matind_t i, jas_matind_t j)
Get the address of an element in a matrix.
Definition: jas_seq.h:271
jas_cmxform_intent_t
Rendering intents.
Definition: jas_cm.h:114
int jas_image_ishomosamp(const jas_image_t *image)
Test if the sampling of the image is homogeneous.
Definition: jas_image.c:1416
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:469
#define jas_stream_getc(stream)
jas_stream_getc Read a character from a stream.
Definition: jas_stream.h:554
void jas_image_clearfmts()
Clear the table of image formats.
Definition: jas_image.c:755
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:1175
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:1574
Image class.
Definition: jas_image.h:215
jas_cmxform_t * jas_cmxform_create(const jas_cmprof_t *inprof, const jas_cmprof_t *outprof, const jas_cmprof_t *prfprof, jas_cmxform_op_t op, jas_cmxform_intent_t intent, jas_cmxform_optm_t optimize)
Create a transform from a CM profile.
Definition: jas_cm.c:425
void jas_image_destroy(jas_image_t *image)
Deallocate any resources associated with an image.
Definition: jas_image.c:304
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:1132
#define jas_image_cmptprec(image, cmptno)
Get the precision of the sample data for a component.
Definition: jas_image.h:455
Image format information.
Definition: jas_image.h:314
JAS_EXPORT int jas_image_setfmtenable(int index, int enabled)
Get the number of image format table entries.
Definition: jas_image.c:737
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:806
unsigned jas_clrspc_t
Color space.
Definition: jas_cm.h:97
int jas_matrix_resize(jas_matrix_t *matrix, jas_matind_t numrows, jas_matind_t numcols)
Resize a matrix. The previous contents of the matrix are lost.
Definition: jas_seq.c:375
static JAS_ATTRIBUTE_PURE size_t jas_matrix_rowstep(const jas_matrix_t *matrix)
The spacing between rows of a matrix.
Definition: jas_seq.h:383
int_fast32_t jas_image_coord_t
Image coordinate.
Definition: jas_image.h:134
int_fast16_t jas_image_colorspc_t
Color space (e.g., RGB, YCbCr).
Definition: jas_image.h:141
Component parameters class.
Definition: jas_image.h:258
Matrix type.
Definition: jas_seq.h:129
void jas_cmxform_destroy(jas_cmxform_t *xform)
Destroy a transform.
Definition: jas_cm.c:649
char * name
Definition: jas_image.h:320
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:420
#define jas_image_clrspc(image)
Get the color model used by the image.
Definition: jas_image.h:420
#define jas_image_cmptheight(image, cmptno)
Get the height of a component.
Definition: jas_image.h:443