JasPer  3.0.1
jas_image.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2000 Image Power, Inc. and the University of
3  * British Columbia.
4  * Copyright (c) 2001-2003 Michael David Adams.
5  * All rights reserved.
6  */
7 
8 /* __START_OF_JASPER_LICENSE__
9  *
10  * JasPer License Version 2.0
11  *
12  * Copyright (c) 2001-2006 Michael David Adams
13  * Copyright (c) 1999-2000 Image Power, Inc.
14  * Copyright (c) 1999-2000 The University of British Columbia
15  *
16  * All rights reserved.
17  *
18  * Permission is hereby granted, free of charge, to any person (the
19  * "User") obtaining a copy of this software and associated documentation
20  * files (the "Software"), to deal in the Software without restriction,
21  * including without limitation the rights to use, copy, modify, merge,
22  * publish, distribute, and/or sell copies of the Software, and to permit
23  * persons to whom the Software is furnished to do so, subject to the
24  * following conditions:
25  *
26  * 1. The above copyright notices and this permission notice (which
27  * includes the disclaimer below) shall be included in all copies or
28  * substantial portions of the Software.
29  *
30  * 2. The name of a copyright holder shall not be used to endorse or
31  * promote products derived from the Software without specific prior
32  * written permission.
33  *
34  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
35  * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
36  * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
37  * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
39  * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
40  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
41  * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
42  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
43  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
44  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
45  * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
46  * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
47  * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
48  * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
49  * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
50  * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
51  * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
52  * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
53  * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
54  * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
55  * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
56  * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
57  * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
58  * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
59  * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
60  *
61  * __END_OF_JASPER_LICENSE__
62  */
63 
69 #ifndef JAS_IMAGE_H
70 #define JAS_IMAGE_H
71 
72 /******************************************************************************\
73 * Includes.
74 \******************************************************************************/
75 
76 /* The configuration header file should be included first. */
77 #include <jasper/jas_config.h>
78 
79 #include <jasper/jas_stream.h>
80 #include <jasper/jas_types.h>
81 #include <jasper/jas_seq.h> /* IWYU pragma: export */
82 #include <jasper/jas_cm.h> /* IWYU pragma: export */
83 #include <stdio.h>
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
94 /******************************************************************************\
95 * Constants.
96 \******************************************************************************/
97 
98 /*
99  * Miscellaneous constants.
100  */
101 
102 /* Basic units */
103 #define JAS_IMAGE_KIBI (JAS_CAST(size_t, 1024))
104 #define JAS_IMAGE_MEBI (JAS_IMAGE_KIBI * JAS_IMAGE_KIBI)
105 
106 /* The threshold at which image data is no longer stored in memory. */
107 #define JAS_IMAGE_INMEMTHRESH (256 * JAS_IMAGE_MEBI)
108 
109 /*
110  * Component types
111  */
112 
113 #define JAS_IMAGE_CT_UNKNOWN 0x10000
114 #define JAS_IMAGE_CT_COLOR(n) ((n) & 0x7fff)
115 #define JAS_IMAGE_CT_OPACITY 0x08000
116 
117 #define JAS_IMAGE_CT_RGB_R 0
118 #define JAS_IMAGE_CT_RGB_G 1
119 #define JAS_IMAGE_CT_RGB_B 2
120 
121 #define JAS_IMAGE_CT_YCBCR_Y 0
122 #define JAS_IMAGE_CT_YCBCR_CB 1
123 #define JAS_IMAGE_CT_YCBCR_CR 2
124 
125 #define JAS_IMAGE_CT_GRAY_Y 0
126 
127 /******************************************************************************\
128 * Simple types.
129 \******************************************************************************/
130 
134 typedef int_fast32_t jas_image_coord_t;
135 #define JAS_IMAGE_COORD_MAX INT_FAST32_MAX
136 #define JAS_IMAGE_COORD_MIN INT_FAST32_MIN
137 
141 typedef int_fast16_t jas_image_colorspc_t;
142 
146 typedef int_fast32_t jas_image_cmpttype_t;
147 
152 typedef int_fast16_t jas_image_smpltype_t;
153 
154 /******************************************************************************\
155 * Image class and supporting classes.
156 \******************************************************************************/
157 
168 typedef struct {
169 
170  /* The x-coordinate of the top-left corner of the component. */
171  jas_image_coord_t tlx_;
172 
173  /* The y-coordinate of the top-left corner of the component. */
174  jas_image_coord_t tly_;
175 
176  /* The horizontal sampling period in units of the reference grid. */
177  jas_image_coord_t hstep_;
178 
179  /* The vertical sampling period in units of the reference grid. */
180  jas_image_coord_t vstep_;
181 
182  /* The component width in samples. */
183  jas_image_coord_t width_;
184 
185  /* The component height in samples. */
186  jas_image_coord_t height_;
187 
188  /* The precision of the sample data (i.e., the number of bits per sample).
189  If the samples are signed values, this quantity includes the sign bit. */
190  unsigned prec_;
191 
192  /* The signedness of the sample data. */
193  int sgnd_;
194 
195  /* The stream containing the component data. */
196  jas_stream_t *stream_;
197 
198  /* The number of characters per sample in the stream. */
199  unsigned cps_;
200 
201  /* The type of component (e.g., opacity, red, green, blue, luma). */
202  jas_image_cmpttype_t type_;
203 
205 
215 typedef struct {
216 
217  /* The x-coordinate of the top-left corner of the image bounding box. */
218  jas_image_coord_t tlx_;
219 
220  /* The y-coordinate of the top-left corner of the image bounding box. */
221  jas_image_coord_t tly_;
222 
223  /* The x-coordinate of the bottom-right corner of the image bounding
224  box (plus one). */
225  jas_image_coord_t brx_;
226 
227  /* The y-coordinate of the bottom-right corner of the image bounding
228  box (plus one). */
229  jas_image_coord_t bry_;
230 
231  /* The number of components. */
232  unsigned numcmpts_;
233 
234  /* The maximum number of components that this image can have (i.e., the
235  allocated size of the components array). */
236  unsigned maxcmpts_;
237 
238  /* Per-component information. */
239  jas_image_cmpt_t **cmpts_;
240 
241  /* The color space. */
242  jas_clrspc_t clrspc_;
243 
244  /* The CM profile. */
245  jas_cmprof_t *cmprof_;
246 
247  //bool inmem_;
248 
249 } jas_image_t;
250 
258 typedef struct {
259 
260  /* The x-coordinate of the top-left corner of the component. */
261  jas_image_coord_t tlx;
262 
263  /* The y-coordinate of the top-left corner of the component. */
264  jas_image_coord_t tly;
265 
266  /* The horizontal sampling period in units of the reference grid. */
267  jas_image_coord_t hstep;
268 
269  /* The vertical sampling period in units of the reference grid. */
270  jas_image_coord_t vstep;
271 
272  /* The width of the component in samples. */
273  jas_image_coord_t width;
274 
275  /* The height of the component in samples. */
276  jas_image_coord_t height;
277 
278  /* The precision of the component sample data. */
279  unsigned prec;
280 
281  /* The signedness of the component sample data. */
282  int sgnd;
283 
285 
286 /******************************************************************************\
287 * File format related classes.
288 \******************************************************************************/
289 
293 #define JAS_IMAGE_MAXFMTS 32
294 
298 typedef struct {
299 
301  jas_image_t *(*decode)(jas_stream_t *in, const char *opts);
302 
304  int (*encode)(jas_image_t *image, jas_stream_t *out, const char *opts);
305 
307  int (*validate)(jas_stream_t *in);
308 
310 
314 typedef struct {
315 
317  int id;
318 
320  char *name;
321 
322  /* The primary file name extension associated with this format. */
323  /* This member only exists for backward compatibility. */
324  char *ext;
325 
327  char **exts;
328  size_t max_exts;
329  size_t num_exts;
330 
332  int enabled;
333 
335  char *desc;
336 
339 
341 
342 /******************************************************************************\
343 * Image operations.
344 \******************************************************************************/
345 
349 JAS_EXPORT
350 jas_image_t *jas_image_create(unsigned numcmpts,
351  const jas_image_cmptparm_t *cmptparms, jas_clrspc_t clrspc);
352 
356 JAS_EXPORT
358 
362 JAS_EXPORT
364 
368 JAS_EXPORT
369 void jas_image_destroy(jas_image_t *image);
370 
374 #define jas_image_width(image) \
375  ((image)->brx_ - (image)->tlx_)
376 
380 #define jas_image_height(image) \
381  ((image)->bry_ - (image)->tly_)
382 
387 #define jas_image_tlx(image) \
388  ((image)->tlx_)
389 
394 #define jas_image_tly(image) \
395  ((image)->tly_)
396 
401 #define jas_image_brx(image) \
402  ((image)->brx_)
403 
408 #define jas_image_bry(image) \
409  ((image)->bry_)
410 
414 #define jas_image_numcmpts(image) \
415  ((image)->numcmpts_)
416 
420 #define jas_image_clrspc(image) \
421  ((image)->clrspc_)
422 
426 #define jas_image_setclrspc(image, clrspc) \
427  ((image)->clrspc_ = (clrspc))
428 
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))
433 
437 #define jas_image_cmptwidth(image, cmptno) \
438  ((image)->cmpts_[cmptno]->width_)
439 
443 #define jas_image_cmptheight(image, cmptno) \
444  ((image)->cmpts_[cmptno]->height_)
445 
449 #define jas_image_cmptsgnd(image, cmptno) \
450  ((image)->cmpts_[cmptno]->sgnd_)
451 
455 #define jas_image_cmptprec(image, cmptno) \
456  ((image)->cmpts_[cmptno]->prec_)
457 
461 #define jas_image_cmpthstep(image, cmptno) \
462  ((image)->cmpts_[cmptno]->hstep_)
463 
467 #define jas_image_cmptvstep(image, cmptno) \
468  ((image)->cmpts_[cmptno]->vstep_)
469 
473 #define jas_image_cmpttlx(image, cmptno) \
474  ((image)->cmpts_[cmptno]->tlx_)
475 
479 #define jas_image_cmpttly(image, cmptno) \
480  ((image)->cmpts_[cmptno]->tly_)
481 
486 #define jas_image_cmptbrx(image, cmptno) \
487  ((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \
488  (image)->cmpts_[cmptno]->hstep_)
489 
494 #define jas_image_cmptbry(image, cmptno) \
495  ((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \
496  (image)->cmpts_[cmptno]->vstep_)
497 
501 JAS_ATTRIBUTE_PURE
502 JAS_EXPORT
503 bool jas_image_cmpt_domains_same(const jas_image_t *image);
504 
509 JAS_ATTRIBUTE_PURE
510 JAS_EXPORT
511 uint_fast32_t jas_image_rawsize(const jas_image_t *image);
512 
516 JAS_EXPORT
517 jas_image_t *jas_image_decode(jas_stream_t *in, int fmt, const char *optstr);
518 
522 JAS_EXPORT
523 int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt,
524  const char *optstr);
525 
533 JAS_EXPORT
534 int jas_image_readcmpt(jas_image_t *image, unsigned cmptno,
536  jas_image_coord_t height, jas_matrix_t *data);
537 
541 JAS_EXPORT
542 int jas_image_writecmpt(jas_image_t *image, unsigned cmptno,
544  jas_image_coord_t height, const jas_matrix_t *data);
545 
549 JAS_EXPORT
550 void jas_image_delcmpt(jas_image_t *image, unsigned cmptno);
551 
555 JAS_EXPORT
556 int jas_image_addcmpt(jas_image_t *image, int cmptno,
557  const jas_image_cmptparm_t *cmptparm);
558 
562 JAS_EXPORT
563 int jas_image_copycmpt(jas_image_t *dstimage, unsigned dstcmptno,
564  jas_image_t *srcimage, unsigned srccmptno);
565 
566 JAS_ATTRIBUTE_CONST
567 static inline bool JAS_IMAGE_CDT_GETSGND(uint_least8_t dtype)
568 {
569  return (dtype >> 7) & 1;
570 }
571 
572 JAS_ATTRIBUTE_CONST
573 static inline uint_least8_t JAS_IMAGE_CDT_SETSGND(bool sgnd)
574 {
575  return (uint_least8_t)sgnd << 7;
576 }
577 
578 JAS_ATTRIBUTE_CONST
579 static inline uint_least8_t JAS_IMAGE_CDT_GETPREC(uint_least8_t dtype)
580 {
581  return dtype & 0x7f;
582 }
583 
584 JAS_ATTRIBUTE_CONST
585 static inline uint_least8_t JAS_IMAGE_CDT_SETPREC(uint_least8_t dtype)
586 {
587  return dtype & 0x7f;
588 }
589 
590 JAS_ATTRIBUTE_PURE
591 static inline uint_least8_t jas_image_cmptdtype(const jas_image_t *image,
592  unsigned cmptno)
593 {
594  return JAS_IMAGE_CDT_SETSGND(image->cmpts_[cmptno]->sgnd_) |
595  JAS_IMAGE_CDT_SETPREC(image->cmpts_[cmptno]->prec_);
596 }
597 
601 JAS_EXPORT
602 int jas_image_depalettize(jas_image_t *image, unsigned cmptno,
603  unsigned numlutents, const int_fast32_t *lutents, unsigned dtype,
604  unsigned newcmptno);
605 
609 JAS_EXPORT
610 int jas_image_readcmptsample(jas_image_t *image, unsigned cmptno, unsigned x,
611  unsigned y);
612 
616 JAS_EXPORT
617 void jas_image_writecmptsample(jas_image_t *image, unsigned cmptno,
618  unsigned x, unsigned y, int_fast32_t v);
619 
623 JAS_ATTRIBUTE_PURE
624 JAS_EXPORT
626 
627 /******************************************************************************\
628 * Image format-related operations.
629 \******************************************************************************/
630 
634 JAS_EXPORT
635 void jas_image_clearfmts(void);
636 
637 #if defined(JAS_FOR_INTERNAL_USE_ONLY)
638 void jas_image_clearfmts_internal(jas_image_fmtinfo_t *image_fmtinfos,
639  size_t *image_numfmts);
640 #endif
641 
645 JAS_EXPORT
647 
651 JAS_EXPORT
652 int jas_image_getnumfmts(void);
653 
654 #if 0
655 JAS_EXPORT
656 int jas_image_delfmtbyid(int id);
657 #endif
658 
666 JAS_EXPORT
667 int jas_image_setfmtenable(int index, int enabled);
668 
669 #if 0
670 // TODO: should this be added?
671 JAS_EXPORT
672 int jas_image_getfmtindbyname(const char* name);
673 #endif
674 
678 JAS_EXPORT
679 int jas_image_addfmt(int id, const char *name, const char *ext,
680  const char *desc, const jas_image_fmtops_t *ops);
681 
682 #if defined(JAS_FOR_INTERNAL_USE_ONLY)
683 int jas_image_addfmt_internal(jas_image_fmtinfo_t *image_fmtinfos,
684  size_t *image_numfmts, int id, const char *name, const char *ext,
685  const char *desc, const jas_image_fmtops_t *ops);
686 #endif
687 
691 JAS_ATTRIBUTE_PURE
692 JAS_EXPORT
693 int jas_image_strtofmt(const char *s);
694 
698 JAS_ATTRIBUTE_CONST
699 JAS_EXPORT
700 const char *jas_image_fmttostr(int fmt);
701 
705 JAS_ATTRIBUTE_CONST
706 JAS_EXPORT
708 
712 JAS_ATTRIBUTE_PURE
713 JAS_EXPORT
714 const jas_image_fmtinfo_t *jas_image_lookupfmtbyname(const char *name);
715 
719 JAS_ATTRIBUTE_PURE
720 JAS_EXPORT
721 int jas_image_fmtfromname(const char *filename);
722 
729 JAS_ATTRIBUTE_PURE
730 JAS_EXPORT
732 
736 #define jas_image_cmprof(image) ((image)->cmprof_)
737 
742 JAS_ATTRIBUTE_PURE
743 JAS_EXPORT
744 int jas_image_ishomosamp(const jas_image_t *image);
745 
749 JAS_EXPORT
750 int jas_image_sampcmpt(jas_image_t *image, unsigned cmptno, unsigned newcmptno,
752  jas_image_coord_t vs, int sgnd, unsigned prec);
753 
757 JAS_EXPORT
758 int jas_image_writecmpt2(jas_image_t *image, unsigned cmptno,
760  jas_image_coord_t height, const long *buf);
761 
765 JAS_EXPORT
766 int jas_image_readcmpt2(jas_image_t *image, unsigned cmptno,
768  jas_image_coord_t height, long *buf);
769 
773 #define jas_image_setcmprof(image, cmprof) ((image)->cmprof_ = cmprof)
774 
778 JAS_EXPORT
780  const jas_cmprof_t *outprof, jas_cmxform_intent_t intent);
781 
785 JAS_EXPORT
786 int jas_image_dump(jas_image_t *image, FILE *out);
787 
788 /******************************************************************************\
789 * Image format-dependent operations.
790 \******************************************************************************/
791 
792 #if defined(JAS_INCLUDE_JPG_CODEC)
793 /* Format-dependent operations for JPG support. */
794 //JAS_EXPORT
795 jas_image_t *jpg_decode(jas_stream_t *in, const char *optstr);
796 //JAS_EXPORT
797 int jpg_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
798 //JAS_EXPORT
799 int jpg_validate(jas_stream_t *in);
800 #endif
801 
802 #if defined(JAS_INCLUDE_HEIC_CODEC)
803 /* Format-dependent operations for HEIC support. */
804 //JAS_EXPORT
805 jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr);
806 //JAS_EXPORT
807 int jas_heic_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
808 //JAS_EXPORT
809 int jas_heic_validate(jas_stream_t *in);
810 #endif
811 
812 #if defined(JAS_INCLUDE_MIF_CODEC)
813 /* Format-dependent operations for MIF support. */
814 //JAS_EXPORT
815 jas_image_t *mif_decode(jas_stream_t *in, const char *optstr);
816 //JAS_EXPORT
817 int mif_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
818 //JAS_EXPORT
819 int mif_validate(jas_stream_t *in);
820 #endif
821 
822 #if defined(JAS_INCLUDE_PNM_CODEC)
823 /* Format-dependent operations for PNM support. */
824 //JAS_EXPORT
825 jas_image_t *pnm_decode(jas_stream_t *in, const char *optstr);
826 //JAS_EXPORT
827 int pnm_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
828 //JAS_EXPORT
829 int pnm_validate(jas_stream_t *in);
830 #endif
831 
832 #if defined(JAS_INCLUDE_RAS_CODEC)
833 /* Format-dependent operations for Sun Rasterfile support. */
834 //JAS_EXPORT
835 jas_image_t *ras_decode(jas_stream_t *in, const char *optstr);
836 //JAS_EXPORT
837 int ras_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
838 //JAS_EXPORT
839 int ras_validate(jas_stream_t *in);
840 #endif
841 
842 #if defined(JAS_INCLUDE_BMP_CODEC)
843 /* Format-dependent operations for BMP support. */
844 //JAS_EXPORT
845 jas_image_t *bmp_decode(jas_stream_t *in, const char *optstr);
846 //JAS_EXPORT
847 int bmp_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
848 //JAS_EXPORT
849 int bmp_validate(jas_stream_t *in);
850 #endif
851 
852 #if defined(JAS_INCLUDE_JP2_CODEC)
853 /* Format-dependent operations for JP2 support. */
854 //JAS_EXPORT
855 jas_image_t *jp2_decode(jas_stream_t *in, const char *optstr);
856 //JAS_EXPORT
857 int jp2_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
858 //JAS_EXPORT
859 int jp2_validate(jas_stream_t *in);
860 #endif
861 
862 #if defined(JAS_INCLUDE_JPC_CODEC)
863 /* Format-dependent operations for JPEG-2000 code stream support. */
864 //JAS_EXPORT
865 jas_image_t *jpc_decode(jas_stream_t *in, const char *optstr);
866 //JAS_EXPORT
867 int jpc_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
868 //JAS_EXPORT
869 int jpc_validate(jas_stream_t *in);
870 #endif
871 
872 #if defined(JAS_INCLUDE_PGX_CODEC)
873 /* Format-dependent operations for PGX support. */
874 //JAS_EXPORT
875 jas_image_t *pgx_decode(jas_stream_t *in, const char *optstr);
876 //JAS_EXPORT
877 int pgx_encode(jas_image_t *image, jas_stream_t *out, const char *optstr);
878 //JAS_EXPORT
879 int pgx_validate(jas_stream_t *in);
880 #endif
881 
886 #ifdef __cplusplus
887 }
888 #endif
889 
890 #endif
jas_init.h
JasPer Initialization/Cleanup Code.
jas_image_delcmpt
void jas_image_delcmpt(jas_image_t *image, unsigned cmptno)
Delete a component from an image.
Definition: jas_image.c:932
jas_logwarnf
JAS_EXPORT int jas_logwarnf(const char *fmt,...)
Generate a warning log message.
Definition: jas_debug.c:131
jas_stringtokenize
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
jas_cmprof_clrspc
#define jas_cmprof_clrspc(prof)
Get the color space associated with a color-management profile.
Definition: jas_cm.h:489
jas_malloc.h
JasPer Memory Allocator.
jas_image_getcmptbytype
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
jas_image_fmtops_t::validate
int(* validate)(jas_stream_t *in)
Definition: jas_image.h:307
jas_image_cmptvstep
#define jas_image_cmptvstep(image, cmptno)
Get the vertical subsampling factor for a component.
Definition: jas_image.h:467
jas_image_fmtinfo_t::id
int id
Definition: jas_image.h:317
jas_stream_putc
#define jas_stream_putc(stream, c)
jas_stream_putc Write a character to a stream.
Definition: jas_stream.h:575
jas_logerrorf
JAS_EXPORT int jas_logerrorf(const char *fmt,...)
Generate an error log message.
Definition: jas_debug.c:119
jas_image_lookupfmtbyname
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_copy
jas_image_t * jas_image_copy(jas_image_t *image)
Clone an image.
Definition: jas_image.c:223
jas_image_cmpttype_t
int_fast32_t jas_image_cmpttype_t
Component type (e.g., color, opacity).
Definition: jas_image.h:146
jas_cmprof_createfromclrspc
jas_cmprof_t * jas_cmprof_createfromclrspc(jas_clrspc_t clrspc)
Create a color-management profile from a color space.
Definition: jas_cm.c:169
jas_stream_copy
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
jas_image_cmpt_t
Image component class.
Definition: jas_image.h:168
jas_clrspc_numchans
unsigned jas_clrspc_numchans(jas_clrspc_t clrspc)
Get the number of channels associated with a particular color space.
Definition: jas_cm.c:1388
jas_image_cmptsgnd
#define jas_image_cmptsgnd(image, cmptno)
Get the signedness of the sample data for a component.
Definition: jas_image.h:449
jas_image_dump
int jas_image_dump(jas_image_t *image, FILE *out)
Dump the information for an image (for debugging).
Definition: jas_image.c:1102
jas_image_strtofmt
int jas_image_strtofmt(const char *name)
Get the ID for the image format with the specified name.
Definition: jas_image.c:835
jas_cmxform_t
Primitive transform class.
Definition: jas_cm.h:315
jas_realloc2
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
jas_image_rawsize
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
jas_image_readcmpt
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_eprintf
JAS_EXPORT int jas_eprintf(const char *fmt,...)
Print formatted text for the standard error stream (i.e., stderr).
Definition: jas_debug.c:96
jas_image_copycmpt
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
jas_cmxform_apply
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
jas_clrspc_isunknown
#define jas_clrspc_isunknown(clrspc)
Test if a color space is unknown.
Definition: jas_cm.h:166
jas_stream_t
I/O stream object.
Definition: jas_stream.h:206
jas_alloc2
void * jas_alloc2(size_t num_elements, size_t element_size)
Allocate array (with overflow checking).
Definition: jas_malloc.c:212
jas_image_writecmptsample
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
jas_clrspc_isgeneric
#define jas_clrspc_isgeneric(clrspc)
Test if a color space is generic.
Definition: jas_cm.h:160
jas_matrix_numcols
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
jas_image_fmtfromname
int jas_image_fmtfromname(const char *name)
Guess the format of an image file based on its name.
Definition: jas_image.c:875
jas_image_smpltype_t
int_fast16_t jas_image_smpltype_t
Component sample data format (e.g., real/integer, signedness, precision).
Definition: jas_image.h:152
jas_cmprof_copy
jas_cmprof_t * jas_cmprof_copy(const jas_cmprof_t *prof)
Copy a color-management profile.
Definition: jas_cm.c:395
JAS_CLRSPC_UNKNOWN
#define JAS_CLRSPC_UNKNOWN
Specific color spaces.
Definition: jas_cm.h:183
jas_cmcmptfmt_t
Component format.
Definition: jas_cm.h:218
jas_image_fmtinfo_t::ops
jas_image_fmtops_t ops
Definition: jas_image.h:338
jas_image_fmtinfo_t::desc
char * desc
Definition: jas_image.h:335
jas_image_sampcmpt
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_memopen
jas_stream_t * jas_stream_memopen(char *buf, size_t bufsize)
Open a memory buffer as a stream.
Definition: jas_stream.c:203
jas_image_writecmpt2
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
jas_image_fmtops_t::encode
int(* encode)(jas_image_t *image, jas_stream_t *out, const char *opts)
Definition: jas_image.h:304
jas_stream_rewind
int jas_stream_rewind(jas_stream_t *stream)
Seek to the beginning of a stream.
Definition: jas_stream.c:858
jas_image_cmpthstep
#define jas_image_cmpthstep(image, cmptno)
Get the horizontal subsampling factor for a component.
Definition: jas_image.h:461
jas_matrix_numrows
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_create
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
jas_image_fmtinfo_t::exts
char ** exts
Definition: jas_image.h:327
jas_image_fmtops_t::decode
jas_image_t *(* decode)(jas_stream_t *in, const char *opts)
Definition: jas_image.h:301
jas_stream_read
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_malloc
JAS_EXPORT void * jas_malloc(size_t size)
Allocate memory.
Definition: jas_malloc.c:136
JAS_IMAGE_MAXFMTS
#define JAS_IMAGE_MAXFMTS
The maximum number of image data formats supported.
Definition: jas_image.h:293
jas_stream_write
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
jas_cmprof_destroy
void jas_cmprof_destroy(jas_cmprof_t *prof)
Destroy a color-management profile.
Definition: jas_cm.c:381
jas_image_cmpt_domains_same
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
jas_image_cmptwidth
#define jas_image_cmptwidth(image, cmptno)
Get the width of a component.
Definition: jas_image.h:437
jas_cmpixmap_t
Pixmap (i.e., multicomponent) format.
Definition: jas_cm.h:230
jas_image_lookupfmtbyid
const jas_image_fmtinfo_t * jas_image_lookupfmtbyid(int id)
Lookup image format information by the format ID.
Definition: jas_image.c:978
jas_image_fmttostr
const char * jas_image_fmttostr(int fmt)
Get the name of the image format with the specified ID.
Definition: jas_image.c:844
jas_image_setcmprof
#define jas_image_setcmprof(image, cmprof)
Set the color management profile for an image.
Definition: jas_image.h:773
jas_image_readcmpt2
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
jas_image_setclrspc
#define jas_image_setclrspc(image, clrspc)
Set the color model for an image.
Definition: jas_image.h:426
jas_stream_tmpfile
jas_stream_t * jas_stream_tmpfile()
Open a temporary file as a stream.
Definition: jas_stream.c:471
jas_image_cmprof
#define jas_image_cmprof(image)
Get the color management profile of an image.
Definition: jas_image.h:736
jas_stream_seek
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_seq.h
Sequence/Matrix Library.
jas_image_getnumfmts
JAS_EXPORT int jas_image_getnumfmts(void)
Get the number of image format table entries.
Definition: jas_image.c:730
jas_image_create0
jas_image_t * jas_image_create0()
Create an "empty" image.
Definition: jas_image.c:201
jas_debug.h
JasPer Debugging-Related Functionality.
jas_image_getfmt
int jas_image_getfmt(jas_stream_t *in)
Get the format of image data in a stream.
Definition: jas_image.c:853
jas_strdup
char * jas_strdup(const char *s)
Create a copy of a null-terminated string.
Definition: jas_string.c:89
jas_stream_close
int jas_stream_close(jas_stream_t *stream)
Close a stream.
Definition: jas_stream.c:591
jas_image_fmtops_t
Image format-dependent operations.
Definition: jas_image.h:298
jas_image_writecmpt
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
jas_image_numcmpts
#define jas_image_numcmpts(image)
Get the number of image components.
Definition: jas_image.h:414
jas_image_addcmpt
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_free
JAS_EXPORT void jas_free(void *ptr)
Free memory.
Definition: jas_malloc.c:186
jas_image_getfmtbyind
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
jas_image_fmtinfo_t::enabled
int enabled
Definition: jas_image.h:332
jas_types.h
Primitive Types.
jas_matrix_getref
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
jas_cmxform_intent_t
Rendering intents.
Definition: jas_cm.h:114
jas_stream.h
I/O Stream Class.
jas_image_ishomosamp
int jas_image_ishomosamp(const jas_image_t *image)
Test if the sampling of the image is homogeneous.
Definition: jas_image.c:1416
jas_image_encode
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
jas_string.h
String Library.
jas_stream_getc
#define jas_stream_getc(stream)
jas_stream_getc Read a character from a stream.
Definition: jas_stream.h:554
jas_cm.h
JasPer Color Management.
jas_cmprof_t
Definition: jas_cm.h:329
jas_image_clearfmts
void jas_image_clearfmts()
Clear the table of image formats.
Definition: jas_image.c:755
jas_image_readcmptsample
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_chclrspc
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
jas_image_t
Image class.
Definition: jas_image.h:215
jas_math.h
Math-Related Code.
jas_cmxform_create
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
jas_image_destroy
void jas_image_destroy(jas_image_t *image)
Deallocate any resources associated with an image.
Definition: jas_image.c:304
jas_image_depalettize
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
jas_image_cmptprec
#define jas_image_cmptprec(image, cmptno)
Get the precision of the sample data for a component.
Definition: jas_image.h:455
jas_image_fmtinfo_t
Image format information.
Definition: jas_image.h:314
jas_image_setfmtenable
JAS_EXPORT int jas_image_setfmtenable(int index, int enabled)
Get the number of image format table entries.
Definition: jas_image.c:737
jas_image_addfmt
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
jas_clrspc_t
unsigned jas_clrspc_t
Color space.
Definition: jas_cm.h:97
jas_matrix_resize
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
jas_matrix_rowstep
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
jas_image_coord_t
int_fast32_t jas_image_coord_t
Image coordinate.
Definition: jas_image.h:134
jas_image.h
JasPer Image Class.
jas_image_colorspc_t
int_fast16_t jas_image_colorspc_t
Color space (e.g., RGB, YCbCr).
Definition: jas_image.h:141
jas_image_cmptparm_t
Component parameters class.
Definition: jas_image.h:258
jas_matrix_t
Matrix type.
Definition: jas_seq.h:129
jas_cmxform_destroy
void jas_cmxform_destroy(jas_cmxform_t *xform)
Destroy a transform.
Definition: jas_cm.c:649
jas_image_fmtinfo_t::name
char * name
Definition: jas_image.h:320
jas_image_decode
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
jas_image_clrspc
#define jas_image_clrspc(image)
Get the color model used by the image.
Definition: jas_image.h:420
jas_image_cmptheight
#define jas_image_cmptheight(image, cmptno)
Get the height of a component.
Definition: jas_image.h:443