| 1 |
/* |
| 2 |
* Copyright (c) 1999-2000 Image Power, Inc. and the University of |
| 3 |
* British Columbia. |
| 4 |
* Copyright (c) 2001-2002 Michael David Adams. |
| 5 |
* All rights reserved. |
| 6 |
*/ |
| 7 |
|
| 8 |
/* __START_OF_JASPER_LICENSE__ |
| 9 |
* |
| 10 |
* JasPer Software License |
| 11 |
* |
| 12 |
* IMAGE POWER JPEG-2000 PUBLIC LICENSE |
| 13 |
* ************************************ |
| 14 |
* |
| 15 |
* GRANT: |
| 16 |
* |
| 17 |
* Permission is hereby granted, free of charge, to any person (the "User") |
| 18 |
* obtaining a copy of this software and associated documentation, to deal |
| 19 |
* in the JasPer Software without restriction, including without limitation |
| 20 |
* the right to use, copy, modify, merge, publish, distribute, sublicense, |
| 21 |
* and/or sell copies of the JasPer Software (in source and binary forms), |
| 22 |
* and to permit persons to whom the JasPer Software is furnished to do so, |
| 23 |
* provided further that the License Conditions below are met. |
| 24 |
* |
| 25 |
* License Conditions |
| 26 |
* ****************** |
| 27 |
* |
| 28 |
* A. Redistributions of source code must retain the above copyright notice, |
| 29 |
* and this list of conditions, and the following disclaimer. |
| 30 |
* |
| 31 |
* B. Redistributions in binary form must reproduce the above copyright |
| 32 |
* notice, and this list of conditions, and the following disclaimer in |
| 33 |
* the documentation and/or other materials provided with the distribution. |
| 34 |
* |
| 35 |
* C. Neither the name of Image Power, Inc. nor any other contributor |
| 36 |
* (including, but not limited to, the University of British Columbia and |
| 37 |
* Michael David Adams) may be used to endorse or promote products derived |
| 38 |
* from this software without specific prior written permission. |
| 39 |
* |
| 40 |
* D. User agrees that it shall not commence any action against Image Power, |
| 41 |
* Inc., the University of British Columbia, Michael David Adams, or any |
| 42 |
* other contributors (collectively "Licensors") for infringement of any |
| 43 |
* intellectual property rights ("IPR") held by the User in respect of any |
| 44 |
* technology that User owns or has a right to license or sublicense and |
| 45 |
* which is an element required in order to claim compliance with ISO/IEC |
| 46 |
* 15444-1 (i.e., JPEG-2000 Part 1). "IPR" means all intellectual property |
| 47 |
* rights worldwide arising under statutory or common law, and whether |
| 48 |
* or not perfected, including, without limitation, all (i) patents and |
| 49 |
* patent applications owned or licensable by User; (ii) rights associated |
| 50 |
* with works of authorship including copyrights, copyright applications, |
| 51 |
* copyright registrations, mask work rights, mask work applications, |
| 52 |
* mask work registrations; (iii) rights relating to the protection of |
| 53 |
* trade secrets and confidential information; (iv) any right analogous |
| 54 |
* to those set forth in subsections (i), (ii), or (iii) and any other |
| 55 |
* proprietary rights relating to intangible property (other than trademark, |
| 56 |
* trade dress, or service mark rights); and (v) divisions, continuations, |
| 57 |
* renewals, reissues and extensions of the foregoing (as and to the extent |
| 58 |
* applicable) now existing, hereafter filed, issued or acquired. |
| 59 |
* |
| 60 |
* E. If User commences an infringement action against any Licensor(s) then |
| 61 |
* such Licensor(s) shall have the right to terminate User's license and |
| 62 |
* all sublicenses that have been granted hereunder by User to other parties. |
| 63 |
* |
| 64 |
* F. This software is for use only in hardware or software products that |
| 65 |
* are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license |
| 66 |
* or right to this Software is granted for products that do not comply |
| 67 |
* with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased |
| 68 |
* from the ISO. |
| 69 |
* |
| 70 |
* THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. |
| 71 |
* NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER |
| 72 |
* THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND |
| 73 |
* CONTRIBUTORS UNDER THIS LICENSE ON AN ``AS-IS'' BASIS, WITHOUT WARRANTY |
| 74 |
* OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, |
| 75 |
* WARRANTIES THAT THE JASPER SOFTWARE IS FREE OF DEFECTS, IS MERCHANTABLE, |
| 76 |
* IS FIT FOR A PARTICULAR PURPOSE OR IS NON-INFRINGING. THOSE INTENDING |
| 77 |
* TO USE THE JASPER SOFTWARE OR MODIFICATIONS THEREOF FOR USE IN HARDWARE |
| 78 |
* OR SOFTWARE PRODUCTS ARE ADVISED THAT THEIR USE MAY INFRINGE EXISTING |
| 79 |
* PATENTS, COPYRIGHTS, TRADEMARKS, OR OTHER INTELLECTUAL PROPERTY RIGHTS. |
| 80 |
* THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE JASPER SOFTWARE |
| 81 |
* IS WITH THE USER. SHOULD ANY PART OF THE JASPER SOFTWARE PROVE DEFECTIVE |
| 82 |
* IN ANY RESPECT, THE USER (AND NOT THE INITIAL DEVELOPERS, THE UNIVERSITY |
| 83 |
* OF BRITISH COLUMBIA, IMAGE POWER, INC., MICHAEL DAVID ADAMS, OR ANY |
| 84 |
* OTHER CONTRIBUTOR) SHALL ASSUME THE COST OF ANY NECESSARY SERVICING, |
| 85 |
* REPAIR OR CORRECTION. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, |
| 86 |
* WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE |
| 87 |
* INITIAL DEVELOPER, THE UNIVERSITY OF BRITISH COLUMBIA, IMAGE POWER, INC., |
| 88 |
* MICHAEL DAVID ADAMS, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF THE |
| 89 |
* JASPER SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO |
| 90 |
* THE USER OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR |
| 91 |
* CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, |
| 92 |
* DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR |
| 93 |
* MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF |
| 94 |
* SUCH PARTY HAD BEEN INFORMED, OR OUGHT TO HAVE KNOWN, OF THE POSSIBILITY |
| 95 |
* OF SUCH DAMAGES. THE JASPER SOFTWARE AND UNDERLYING TECHNOLOGY ARE NOT |
| 96 |
* FAULT-TOLERANT AND ARE NOT DESIGNED, MANUFACTURED OR INTENDED FOR USE OR |
| 97 |
* RESALE AS ON-LINE CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING |
| 98 |
* FAIL-SAFE PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, |
| 99 |
* AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT |
| 100 |
* LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE |
| 101 |
* JASPER SOFTWARE OR UNDERLYING TECHNOLOGY OR PRODUCT COULD LEAD DIRECTLY |
| 102 |
* TO DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE |
| 103 |
* ("HIGH RISK ACTIVITIES"). LICENSOR SPECIFICALLY DISCLAIMS ANY EXPRESS |
| 104 |
* OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES. USER WILL NOT |
| 105 |
* KNOWINGLY USE, DISTRIBUTE OR RESELL THE JASPER SOFTWARE OR UNDERLYING |
| 106 |
* TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS |
| 107 |
* CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE |
| 108 |
* NOTICE SPECIFIED IN THIS SECTION. |
| 109 |
* |
| 110 |
* __END_OF_JASPER_LICENSE__ |
| 111 |
*/ |
| 112 |
|
| 113 |
/* |
| 114 |
* Image Class |
| 115 |
* |
| 116 |
* $Id$ |
| 117 |
*/ |
| 118 |
|
| 119 |
#ifndef JAS_IMAGE_H |
| 120 |
#define JAS_IMAGE_H |
| 121 |
|
| 122 |
/******************************************************************************\ |
| 123 |
* Includes. |
| 124 |
\******************************************************************************/ |
| 125 |
|
| 126 |
#include "netpbm/pm_c_util.h" |
| 127 |
#include <jasper/jas_stream.h> |
| 128 |
#include <jasper/jas_seq.h> |
| 129 |
|
| 130 |
#ifdef __cplusplus |
| 131 |
extern "C" { |
| 132 |
#endif |
| 133 |
|
| 134 |
/******************************************************************************\ |
| 135 |
* Constants. |
| 136 |
\******************************************************************************/ |
| 137 |
|
| 138 |
/* |
| 139 |
* Miscellaneous constants. |
| 140 |
*/ |
| 141 |
|
| 142 |
/* The threshold at which image data is no longer stored in memory. */ |
| 143 |
#define JAS_IMAGE_INMEMTHRESH (16 * 1024 * 1024) |
| 144 |
|
| 145 |
/* |
| 146 |
* Color models. |
| 147 |
*/ |
| 148 |
|
| 149 |
#define JAS_IMAGE_CS_UNKNOWN 0 /* Unknown */ |
| 150 |
#define JAS_IMAGE_CS_GRAY 1 /* Standard Gray */ |
| 151 |
#define JAS_IMAGE_CS_RGB 2 /* Standard RGB */ |
| 152 |
#define JAS_IMAGE_CS_YCBCR 3 /* Standard YCC */ |
| 153 |
#if 0 |
| 154 |
#define JAS_IMAGE_CM_ICC 4 /* ICC Profile */ |
| 155 |
#endif |
| 156 |
/* |
| 157 |
* Component types |
| 158 |
*/ |
| 159 |
|
| 160 |
#define JAS_IMAGE_CT_UNKNOWN 0x10000 |
| 161 |
#define JAS_IMAGE_CT_COLOR(n) ((n) & 0x7fff) |
| 162 |
#define JAS_IMAGE_CT_OPACITY 0x08000 |
| 163 |
|
| 164 |
#define JAS_IMAGE_CT_RGB_R 0 |
| 165 |
#define JAS_IMAGE_CT_RGB_G 1 |
| 166 |
#define JAS_IMAGE_CT_RGB_B 2 |
| 167 |
|
| 168 |
#define JAS_IMAGE_CT_YCBCR_Y 0 |
| 169 |
#define JAS_IMAGE_CT_YCBCR_CB 1 |
| 170 |
#define JAS_IMAGE_CT_YCBCR_CR 2 |
| 171 |
|
| 172 |
#define JAS_IMAGE_CT_GRAY_Y 0 |
| 173 |
|
| 174 |
/*****************************************************************************\ |
| 175 |
* Image class and supporting classes. |
| 176 |
\*****************************************************************************/ |
| 177 |
|
| 178 |
/* Image component class. */ |
| 179 |
|
| 180 |
typedef struct { |
| 181 |
|
| 182 |
uint_fast32_t tlx_; |
| 183 |
/* The x-coordinate of the top-left corner of the component. */ |
| 184 |
|
| 185 |
uint_fast32_t tly_; |
| 186 |
/* The y-coordinate of the top-left corner of the component. */ |
| 187 |
|
| 188 |
uint_fast32_t hstep_; |
| 189 |
/* The horizontal sampling period in units of the reference grid. */ |
| 190 |
|
| 191 |
uint_fast32_t vstep_; |
| 192 |
/* The vertical sampling period in units of the reference grid. */ |
| 193 |
|
| 194 |
uint_fast32_t width_; |
| 195 |
/* The component width in samples. */ |
| 196 |
|
| 197 |
uint_fast32_t height_; |
| 198 |
/* The component height in samples. */ |
| 199 |
|
| 200 |
uint_fast16_t prec_; |
| 201 |
/* The precision of the sample data (i.e., the number of bits per |
| 202 |
sample). If the samples are signed values, this quantity |
| 203 |
includes the sign bit. */ |
| 204 |
|
| 205 |
uint_fast8_t sgnd_; |
| 206 |
/* The signedness of the sample data. */ |
| 207 |
|
| 208 |
jas_stream_t *stream_; |
| 209 |
/* The stream containing the component data. */ |
| 210 |
|
| 211 |
int cps_; |
| 212 |
/* The number of characters per sample in the stream. */ |
| 213 |
|
| 214 |
uint_fast32_t type_; |
| 215 |
/* The type of component (e.g., opacity, red, green, blue, luma). */ |
| 216 |
|
| 217 |
} jas_image_cmpt_t; |
| 218 |
|
| 219 |
/* Image class. */ |
| 220 |
|
| 221 |
typedef struct { |
| 222 |
|
| 223 |
uint_fast32_t tlx_; |
| 224 |
/* The x-coordinate of the top-left corner of the image bounding box. */ |
| 225 |
|
| 226 |
uint_fast32_t tly_; |
| 227 |
/* The y-coordinate of the top-left corner of the image bounding box. */ |
| 228 |
|
| 229 |
uint_fast32_t brx_; |
| 230 |
/* The x-coordinate of the bottom-right corner of the image bounding |
| 231 |
box (plus one). */ |
| 232 |
|
| 233 |
uint_fast32_t bry_; |
| 234 |
/* The y-coordinate of the bottom-right corner of the image bounding |
| 235 |
box (plus one). */ |
| 236 |
|
| 237 |
uint_fast16_t numcmpts_; |
| 238 |
/* The number of components. */ |
| 239 |
|
| 240 |
uint_fast16_t maxcmpts_; |
| 241 |
/* The maximum number of components that this image can have (i.e., the |
| 242 |
allocated size of the components array). */ |
| 243 |
|
| 244 |
jas_image_cmpt_t **cmpts_; |
| 245 |
/* Per-component information. */ |
| 246 |
|
| 247 |
int colorspace_; |
| 248 |
/* The color space used (e.g., RGB, YCbCr, gray). This field is only |
| 249 |
of particular relevance in the case of a multi-component image. */ |
| 250 |
|
| 251 |
unsigned char *iccp_; |
| 252 |
/* ICC profile information. */ |
| 253 |
|
| 254 |
int iccplen_; |
| 255 |
|
| 256 |
bool inmem_; |
| 257 |
|
| 258 |
} jas_image_t; |
| 259 |
|
| 260 |
/* Component parameters class. */ |
| 261 |
/* This data type exists solely/mainly for the purposes of the |
| 262 |
jas_image_create function. */ |
| 263 |
|
| 264 |
typedef struct { |
| 265 |
|
| 266 |
uint_fast32_t tlx; |
| 267 |
/* The x-coordinate of the top-left corner of the component. */ |
| 268 |
|
| 269 |
uint_fast32_t tly; |
| 270 |
/* The y-coordinate of the top-left corner of the component. */ |
| 271 |
|
| 272 |
uint_fast32_t hstep; |
| 273 |
/* The horizontal sampling period in units of the reference grid. */ |
| 274 |
|
| 275 |
uint_fast32_t vstep; |
| 276 |
/* The vertical sampling period in units of the reference grid. */ |
| 277 |
|
| 278 |
uint_fast32_t width; |
| 279 |
/* The width of the component in samples. */ |
| 280 |
|
| 281 |
uint_fast32_t height; |
| 282 |
/* The height of the component in samples. */ |
| 283 |
|
| 284 |
uint_fast16_t prec; |
| 285 |
/* The precision of the component sample data. */ |
| 286 |
|
| 287 |
bool sgnd; |
| 288 |
/* The signedness of the component sample data. */ |
| 289 |
|
| 290 |
} jas_image_cmptparm_t; |
| 291 |
|
| 292 |
/******************************************************************************\ |
| 293 |
* File format related classes. |
| 294 |
\******************************************************************************/ |
| 295 |
|
| 296 |
#define JAS_IMAGE_MAXFMTS 32 |
| 297 |
/* The maximum number of image data formats we can handle. */ |
| 298 |
|
| 299 |
/* Image format-dependent operations. */ |
| 300 |
|
| 301 |
typedef struct { |
| 302 |
|
| 303 |
void (*decode)(jas_stream_t * const in, |
| 304 |
const char * const opts, |
| 305 |
jas_image_t ** const imagePP, |
| 306 |
const char ** const errorP); |
| 307 |
/* Decode image data from a stream. */ |
| 308 |
|
| 309 |
int (*encode)(jas_image_t *image, jas_stream_t *out, char *opts); |
| 310 |
/* Encode image data to a stream. */ |
| 311 |
|
| 312 |
int (*validate)(jas_stream_t *in); |
| 313 |
/* Determine if stream data is in a particular format. */ |
| 314 |
|
| 315 |
} jas_image_fmtops_t; |
| 316 |
|
| 317 |
/* Image format information. */ |
| 318 |
|
| 319 |
typedef struct { |
| 320 |
|
| 321 |
int id; |
| 322 |
/* The ID for this format. */ |
| 323 |
|
| 324 |
char *name; |
| 325 |
/* The name by which this format is identified. */ |
| 326 |
|
| 327 |
char *ext; |
| 328 |
/* The file name extension associated with this format. */ |
| 329 |
|
| 330 |
char *desc; |
| 331 |
/* A brief description of the format. */ |
| 332 |
|
| 333 |
jas_image_fmtops_t ops; |
| 334 |
/* The operations for this format. */ |
| 335 |
|
| 336 |
} jas_image_fmtinfo_t; |
| 337 |
|
| 338 |
/******************************************************************************\ |
| 339 |
* Image operations. |
| 340 |
\******************************************************************************/ |
| 341 |
|
| 342 |
/* Create an image. */ |
| 343 |
jas_image_t *jas_image_create(uint_fast16_t numcmpts, |
| 344 |
jas_image_cmptparm_t *cmptparms, int colorspace); |
| 345 |
|
| 346 |
/* Create an "empty" image. */ |
| 347 |
jas_image_t *jas_image_create0(void); |
| 348 |
|
| 349 |
/* Clone an image. */ |
| 350 |
jas_image_t *jas_image_copy(jas_image_t *image); |
| 351 |
|
| 352 |
/* Deallocate any resources associated with an image. */ |
| 353 |
void jas_image_destroy(jas_image_t *image); |
| 354 |
|
| 355 |
/* Get the width of the image in units of the image reference grid. */ |
| 356 |
#define jas_image_width(image) \ |
| 357 |
((image)->brx_ - (image)->tlx_) |
| 358 |
|
| 359 |
/* Get the height of the image in units of the image reference grid. */ |
| 360 |
#define jas_image_height(image) \ |
| 361 |
((image)->bry_ - (image)->tly_) |
| 362 |
|
| 363 |
/* Get the x-coordinate of the top-left corner of the image bounding box |
| 364 |
on the reference grid. */ |
| 365 |
#define jas_image_tlx(image) \ |
| 366 |
((image)->tlx_) |
| 367 |
|
| 368 |
/* Get the y-coordinate of the top-left corner of the image bounding box |
| 369 |
on the reference grid. */ |
| 370 |
#define jas_image_tly(image) \ |
| 371 |
((image)->tly_) |
| 372 |
|
| 373 |
/* Get the x-coordinate of the bottom-right corner of the image bounding box |
| 374 |
on the reference grid (plus one). */ |
| 375 |
#define jas_image_brx(image) \ |
| 376 |
((image)->brx_) |
| 377 |
|
| 378 |
/* Get the y-coordinate of the bottom-right corner of the image bounding box |
| 379 |
on the reference grid (plus one). */ |
| 380 |
#define jas_image_bry(image) \ |
| 381 |
((image)->bry_) |
| 382 |
|
| 383 |
/* Get the number of image components. */ |
| 384 |
#define jas_image_numcmpts(image) \ |
| 385 |
((image)->numcmpts_) |
| 386 |
|
| 387 |
/* Get the color model used by the image. */ |
| 388 |
#define jas_image_colorspace(image) \ |
| 389 |
((image)->colorspace_) |
| 390 |
|
| 391 |
/* Set the color model for an image. */ |
| 392 |
#define jas_image_setcolorspace(image, colorspace) \ |
| 393 |
((image)->colorspace_ = (colorspace)) |
| 394 |
|
| 395 |
#define jas_image_cmpttype(image, cmptno) \ |
| 396 |
((image)->cmpts_[(cmptno)]->type_) |
| 397 |
#define jas_image_setcmpttype(image, cmptno, type) \ |
| 398 |
((image)->cmpts_[(cmptno)]->type_ = (type)) |
| 399 |
|
| 400 |
/* Get the width of a component. */ |
| 401 |
#define jas_image_cmptwidth(image, cmptno) \ |
| 402 |
((image)->cmpts_[cmptno]->width_) |
| 403 |
|
| 404 |
/* Get the height of a component. */ |
| 405 |
#define jas_image_cmptheight(image, cmptno) \ |
| 406 |
((image)->cmpts_[cmptno]->height_) |
| 407 |
|
| 408 |
/* Get the signedness of the sample data for a component. */ |
| 409 |
#define jas_image_cmptsgnd(image, cmptno) \ |
| 410 |
((image)->cmpts_[cmptno]->sgnd_) |
| 411 |
|
| 412 |
/* Get the precision of the sample data for a component. */ |
| 413 |
#define jas_image_cmptprec(image, cmptno) \ |
| 414 |
((image)->cmpts_[cmptno]->prec_) |
| 415 |
|
| 416 |
/* Get the horizontal subsampling factor for a component. */ |
| 417 |
#define jas_image_cmpthstep(image, cmptno) \ |
| 418 |
((image)->cmpts_[cmptno]->hstep_) |
| 419 |
|
| 420 |
/* Get the vertical subsampling factor for a component. */ |
| 421 |
#define jas_image_cmptvstep(image, cmptno) \ |
| 422 |
((image)->cmpts_[cmptno]->vstep_) |
| 423 |
|
| 424 |
/* Get the x-coordinate of the top-left corner of a component. */ |
| 425 |
#define jas_image_cmpttlx(image, cmptno) \ |
| 426 |
((image)->cmpts_[cmptno]->tlx_) |
| 427 |
|
| 428 |
/* Get the y-coordinate of the top-left corner of a component. */ |
| 429 |
#define jas_image_cmpttly(image, cmptno) \ |
| 430 |
((image)->cmpts_[cmptno]->tly_) |
| 431 |
|
| 432 |
/* Get the x-coordinate of the bottom-right corner of a component |
| 433 |
(plus "one"). */ |
| 434 |
#define jas_image_cmptbrx(image, cmptno) \ |
| 435 |
((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \ |
| 436 |
(image)->cmpts_[cmptno]->hstep_) |
| 437 |
|
| 438 |
/* Get the y-coordinate of the bottom-right corner of a component |
| 439 |
(plus "one"). */ |
| 440 |
#define jas_image_cmptbry(image, cmptno) \ |
| 441 |
((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \ |
| 442 |
(image)->cmpts_[cmptno]->vstep_) |
| 443 |
|
| 444 |
/* Get the raw size of an image (i.e., the nominal size of the image without |
| 445 |
any compression. */ |
| 446 |
uint_fast32_t jas_image_rawsize(jas_image_t *image); |
| 447 |
|
| 448 |
#define JAS_HAVE_PMJAS_IMAGE_DECODE |
| 449 |
|
| 450 |
void |
| 451 |
pmjas_image_decode(jas_stream_t * const in, |
| 452 |
int const fmt, |
| 453 |
const char * const optstr, |
| 454 |
jas_image_t ** const imagePP, |
| 455 |
const char ** const errorP); |
| 456 |
|
| 457 |
/* Write an image to a stream in a specified format. */ |
| 458 |
int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt, |
| 459 |
char *optstr); |
| 460 |
|
| 461 |
/* Read a rectangular region of an image component. */ |
| 462 |
/* The position and size of the rectangular region to be read is specified |
| 463 |
relative to the component's coordinate system. */ |
| 464 |
int jas_image_readcmpt(jas_image_t *image, uint_fast16_t cmptno, |
| 465 |
uint_fast32_t x, uint_fast32_t y, uint_fast32_t width, uint_fast32_t height, |
| 466 |
jas_matrix_t *data); |
| 467 |
|
| 468 |
/* Write a rectangular region of an image component. */ |
| 469 |
int jas_image_writecmpt(jas_image_t *image, uint_fast16_t cmptno, |
| 470 |
uint_fast32_t x, uint_fast32_t y, uint_fast32_t width, uint_fast32_t height, |
| 471 |
jas_matrix_t *data); |
| 472 |
|
| 473 |
/* Delete a component from an image. */ |
| 474 |
void jas_image_delcmpt(jas_image_t *image, uint_fast16_t cmptno); |
| 475 |
|
| 476 |
/* Add a component to an image. */ |
| 477 |
int jas_image_addcmpt(jas_image_t *image, uint_fast16_t cmptno, |
| 478 |
jas_image_cmptparm_t *cmptparm); |
| 479 |
|
| 480 |
/* Copy a component from one image to another. */ |
| 481 |
int jas_image_copycmpt(jas_image_t *dstimage, int dstcmptno, |
| 482 |
jas_image_t *srcimage, int srccmptno); |
| 483 |
|
| 484 |
#if 0 |
| 485 |
int_fast64_t jas_image_readcmpt1(jas_image_t *image, uint_fast16_t cmptno, |
| 486 |
uint_fast32_t x, uint_fast32_t y); |
| 487 |
#endif |
| 488 |
|
| 489 |
#define JAS_IMAGE_CDT_GETSGND(dtype) (((dtype) >> 7) & 1) |
| 490 |
#define JAS_IMAGE_CDT_SETSGND(dtype) (((dtype) & 1) << 7) |
| 491 |
#define JAS_IMAGE_CDT_GETPREC(dtype) ((dtype) & 0x7f) |
| 492 |
#define JAS_IMAGE_CDT_SETPREC(dtype) ((dtype) & 0x7f) |
| 493 |
|
| 494 |
#define jas_image_cmptdtype(image, cmptno) \ |
| 495 |
(JAS_IMAGE_CDT_SETSGND((image)->cmpts_[cmptno]->sgnd_) | JAS_IMAGE_CDT_SETPREC((image)->cmpts_[cmptno]->prec_)) |
| 496 |
|
| 497 |
void jas_image_dump(jas_image_t *image, FILE *out); |
| 498 |
|
| 499 |
int jas_image_depalettize(jas_image_t *image, int cmptno, int numlutents, |
| 500 |
int_fast32_t *lutents, int dtype, int newcmptno); |
| 501 |
|
| 502 |
int jas_image_readcmptsample(jas_image_t *image, int cmptno, int x, int y); |
| 503 |
void jas_image_writecmptsample(jas_image_t *image, int cmptno, int x, int y, |
| 504 |
int_fast32_t v); |
| 505 |
|
| 506 |
int jas_image_getcmptbytype(jas_image_t *image, int ctype); |
| 507 |
|
| 508 |
/******************************************************************************\ |
| 509 |
* Image format-related operations. |
| 510 |
\******************************************************************************/ |
| 511 |
|
| 512 |
/* Clear the table of image formats. */ |
| 513 |
void jas_image_clearfmts(void); |
| 514 |
|
| 515 |
/* Add entry to table of image formats. */ |
| 516 |
int jas_image_addfmt(int id, const char *name, const char *ext, |
| 517 |
const char *desc, |
| 518 |
jas_image_fmtops_t *ops); |
| 519 |
|
| 520 |
/* Get the ID for the image format with the specified name. */ |
| 521 |
int jas_image_strtofmt(char *s); |
| 522 |
|
| 523 |
/* Get the name of the image format with the specified ID. */ |
| 524 |
char *jas_image_fmttostr(int fmt); |
| 525 |
|
| 526 |
/* Lookup image format information by the format ID. */ |
| 527 |
jas_image_fmtinfo_t *jas_image_lookupfmtbyid(int id); |
| 528 |
|
| 529 |
/* Lookup image format information by the format name. */ |
| 530 |
jas_image_fmtinfo_t *jas_image_lookupfmtbyname(const char *name); |
| 531 |
|
| 532 |
/* Guess the format of an image file based on its name. */ |
| 533 |
int jas_image_fmtfromname(char *filename); |
| 534 |
|
| 535 |
/* Get the format of image data in a stream. */ |
| 536 |
int jas_image_getfmt(jas_stream_t *in); |
| 537 |
|
| 538 |
/******************************************************************************\ |
| 539 |
* Image format-dependent operations. |
| 540 |
\******************************************************************************/ |
| 541 |
|
| 542 |
#if !defined(EXCLUDE_JPG_CAPABILITY) |
| 543 |
/* Format-dependent operations for JPG capability. */ |
| 544 |
jas_image_t *jpg_decode(jas_stream_t *in, char *optstr); |
| 545 |
int jpg_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 546 |
int jpg_validate(jas_stream_t *in); |
| 547 |
#endif |
| 548 |
|
| 549 |
#if !defined(EXCLUDE_MIF_CAPABILITY) |
| 550 |
/* Format-dependent operations for MIF capability. */ |
| 551 |
jas_image_t *mif_decode(jas_stream_t *in, char *optstr); |
| 552 |
int mif_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 553 |
int mif_validate(jas_stream_t *in); |
| 554 |
#endif |
| 555 |
|
| 556 |
#if !defined(EXCLUDE_PNM_CAPABILITY) |
| 557 |
/* Format-dependent operations for PNM capability. */ |
| 558 |
jas_image_t *pnm_decode(jas_stream_t *in, char *optstr); |
| 559 |
int pnm_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 560 |
int pnm_validate(jas_stream_t *in); |
| 561 |
#endif |
| 562 |
|
| 563 |
#if !defined(EXCLUDE_RAS_CAPABILITY) |
| 564 |
/* Format-dependent operations for Sun Rasterfile capability. */ |
| 565 |
jas_image_t *ras_decode(jas_stream_t *in, char *optstr); |
| 566 |
int ras_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 567 |
int ras_validate(jas_stream_t *in); |
| 568 |
#endif |
| 569 |
|
| 570 |
#if !defined(EXCLUDE_BMP_CAPABILITY) |
| 571 |
/* Format-dependent operations for BMP capability. */ |
| 572 |
jas_image_t *bmp_decode(jas_stream_t *in, char *optstr); |
| 573 |
int bmp_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 574 |
int bmp_validate(jas_stream_t *in); |
| 575 |
#endif |
| 576 |
|
| 577 |
#if !defined(EXCLUDE_JP2_CAPABILITY) |
| 578 |
/* Format-dependent operations for JP2 capability. */ |
| 579 |
void |
| 580 |
jp2_decode(jas_stream_t * const in, |
| 581 |
const char * const optstr, |
| 582 |
jas_image_t ** const imagePP, |
| 583 |
const char ** const errorP); |
| 584 |
int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 585 |
int jp2_validate(jas_stream_t *in); |
| 586 |
#endif |
| 587 |
|
| 588 |
#if !defined(EXCLUDE_JPC_CAPABILITY) |
| 589 |
/* Format-dependent operations for JPEG-2000 code stream capability. */ |
| 590 |
void |
| 591 |
jpc_decode(jas_stream_t * const in, |
| 592 |
const char * const optstr, |
| 593 |
jas_image_t ** const imagePP, |
| 594 |
const char ** const errorP); |
| 595 |
int jpc_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 596 |
int jpc_validate(jas_stream_t *in); |
| 597 |
#endif |
| 598 |
|
| 599 |
#if !defined(EXCLUDE_PGX_CAPABILITY) |
| 600 |
/* Format-dependent operations for PGX capability. */ |
| 601 |
jas_image_t *pgx_decode(jas_stream_t *in, char *optstr); |
| 602 |
int pgx_encode(jas_image_t *image, jas_stream_t *out, char *optstr); |
| 603 |
int pgx_validate(jas_stream_t *in); |
| 604 |
#endif |
| 605 |
|
| 606 |
#ifdef __cplusplus |
| 607 |
} |
| 608 |
#endif |
| 609 |
|
| 610 |
#endif |