Blame converter/other/jpeg2000/libjasper/include/jasper/jas_image.h

Packit 78deda
/*
Packit 78deda
 * Copyright (c) 1999-2000 Image Power, Inc. and the University of
Packit 78deda
 *   British Columbia.
Packit 78deda
 * Copyright (c) 2001-2002 Michael David Adams.
Packit 78deda
 * All rights reserved.
Packit 78deda
 */
Packit 78deda
Packit 78deda
/* __START_OF_JASPER_LICENSE__
Packit 78deda
 * 
Packit 78deda
 * JasPer Software License
Packit 78deda
 * 
Packit 78deda
 * IMAGE POWER JPEG-2000 PUBLIC LICENSE
Packit 78deda
 * ************************************
Packit 78deda
 * 
Packit 78deda
 * GRANT:
Packit 78deda
 * 
Packit 78deda
 * Permission is hereby granted, free of charge, to any person (the "User")
Packit 78deda
 * obtaining a copy of this software and associated documentation, to deal
Packit 78deda
 * in the JasPer Software without restriction, including without limitation
Packit 78deda
 * the right to use, copy, modify, merge, publish, distribute, sublicense,
Packit 78deda
 * and/or sell copies of the JasPer Software (in source and binary forms),
Packit 78deda
 * and to permit persons to whom the JasPer Software is furnished to do so,
Packit 78deda
 * provided further that the License Conditions below are met.
Packit 78deda
 * 
Packit 78deda
 * License Conditions
Packit 78deda
 * ******************
Packit 78deda
 * 
Packit 78deda
 * A.  Redistributions of source code must retain the above copyright notice,
Packit 78deda
 * and this list of conditions, and the following disclaimer.
Packit 78deda
 * 
Packit 78deda
 * B.  Redistributions in binary form must reproduce the above copyright
Packit 78deda
 * notice, and this list of conditions, and the following disclaimer in
Packit 78deda
 * the documentation and/or other materials provided with the distribution.
Packit 78deda
 * 
Packit 78deda
 * C.  Neither the name of Image Power, Inc. nor any other contributor
Packit 78deda
 * (including, but not limited to, the University of British Columbia and
Packit 78deda
 * Michael David Adams) may be used to endorse or promote products derived
Packit 78deda
 * from this software without specific prior written permission.
Packit 78deda
 * 
Packit 78deda
 * D.  User agrees that it shall not commence any action against Image Power,
Packit 78deda
 * Inc., the University of British Columbia, Michael David Adams, or any
Packit 78deda
 * other contributors (collectively "Licensors") for infringement of any
Packit 78deda
 * intellectual property rights ("IPR") held by the User in respect of any
Packit 78deda
 * technology that User owns or has a right to license or sublicense and
Packit 78deda
 * which is an element required in order to claim compliance with ISO/IEC
Packit 78deda
 * 15444-1 (i.e., JPEG-2000 Part 1).  "IPR" means all intellectual property
Packit 78deda
 * rights worldwide arising under statutory or common law, and whether
Packit 78deda
 * or not perfected, including, without limitation, all (i) patents and
Packit 78deda
 * patent applications owned or licensable by User; (ii) rights associated
Packit 78deda
 * with works of authorship including copyrights, copyright applications,
Packit 78deda
 * copyright registrations, mask work rights, mask work applications,
Packit 78deda
 * mask work registrations; (iii) rights relating to the protection of
Packit 78deda
 * trade secrets and confidential information; (iv) any right analogous
Packit 78deda
 * to those set forth in subsections (i), (ii), or (iii) and any other
Packit 78deda
 * proprietary rights relating to intangible property (other than trademark,
Packit 78deda
 * trade dress, or service mark rights); and (v) divisions, continuations,
Packit 78deda
 * renewals, reissues and extensions of the foregoing (as and to the extent
Packit 78deda
 * applicable) now existing, hereafter filed, issued or acquired.
Packit 78deda
 * 
Packit 78deda
 * E.  If User commences an infringement action against any Licensor(s) then
Packit 78deda
 * such Licensor(s) shall have the right to terminate User's license and
Packit 78deda
 * all sublicenses that have been granted hereunder by User to other parties.
Packit 78deda
 * 
Packit 78deda
 * F.  This software is for use only in hardware or software products that
Packit 78deda
 * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1).  No license
Packit 78deda
 * or right to this Software is granted for products that do not comply
Packit 78deda
 * with ISO/IEC 15444-1.  The JPEG-2000 Part 1 standard can be purchased
Packit 78deda
 * from the ISO.
Packit 78deda
 * 
Packit 78deda
 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
Packit 78deda
 * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
Packit 78deda
 * THIS DISCLAIMER.  THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND
Packit 78deda
 * CONTRIBUTORS UNDER THIS LICENSE ON AN ``AS-IS'' BASIS, WITHOUT WARRANTY
Packit 78deda
 * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
Packit 78deda
 * WARRANTIES THAT THE JASPER SOFTWARE IS FREE OF DEFECTS, IS MERCHANTABLE,
Packit 78deda
 * IS FIT FOR A PARTICULAR PURPOSE OR IS NON-INFRINGING.  THOSE INTENDING
Packit 78deda
 * TO USE THE JASPER SOFTWARE OR MODIFICATIONS THEREOF FOR USE IN HARDWARE
Packit 78deda
 * OR SOFTWARE PRODUCTS ARE ADVISED THAT THEIR USE MAY INFRINGE EXISTING
Packit 78deda
 * PATENTS, COPYRIGHTS, TRADEMARKS, OR OTHER INTELLECTUAL PROPERTY RIGHTS.
Packit 78deda
 * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE JASPER SOFTWARE
Packit 78deda
 * IS WITH THE USER.  SHOULD ANY PART OF THE JASPER SOFTWARE PROVE DEFECTIVE
Packit 78deda
 * IN ANY RESPECT, THE USER (AND NOT THE INITIAL DEVELOPERS, THE UNIVERSITY
Packit 78deda
 * OF BRITISH COLUMBIA, IMAGE POWER, INC., MICHAEL DAVID ADAMS, OR ANY
Packit 78deda
 * OTHER CONTRIBUTOR) SHALL ASSUME THE COST OF ANY NECESSARY SERVICING,
Packit 78deda
 * REPAIR OR CORRECTION.  UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY,
Packit 78deda
 * WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE
Packit 78deda
 * INITIAL DEVELOPER, THE UNIVERSITY OF BRITISH COLUMBIA, IMAGE POWER, INC.,
Packit 78deda
 * MICHAEL DAVID ADAMS, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF THE
Packit 78deda
 * JASPER SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO
Packit 78deda
 * THE USER OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
Packit 78deda
 * CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION,
Packit 78deda
 * DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR
Packit 78deda
 * MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF
Packit 78deda
 * SUCH PARTY HAD BEEN INFORMED, OR OUGHT TO HAVE KNOWN, OF THE POSSIBILITY
Packit 78deda
 * OF SUCH DAMAGES.  THE JASPER SOFTWARE AND UNDERLYING TECHNOLOGY ARE NOT
Packit 78deda
 * FAULT-TOLERANT AND ARE NOT DESIGNED, MANUFACTURED OR INTENDED FOR USE OR
Packit 78deda
 * RESALE AS ON-LINE CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING
Packit 78deda
 * FAIL-SAFE PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES,
Packit 78deda
 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT
Packit 78deda
 * LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
Packit 78deda
 * JASPER SOFTWARE OR UNDERLYING TECHNOLOGY OR PRODUCT COULD LEAD DIRECTLY
Packit 78deda
 * TO DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE
Packit 78deda
 * ("HIGH RISK ACTIVITIES").  LICENSOR SPECIFICALLY DISCLAIMS ANY EXPRESS
Packit 78deda
 * OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.  USER WILL NOT
Packit 78deda
 * KNOWINGLY USE, DISTRIBUTE OR RESELL THE JASPER SOFTWARE OR UNDERLYING
Packit 78deda
 * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS
Packit 78deda
 * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE
Packit 78deda
 * NOTICE SPECIFIED IN THIS SECTION.
Packit 78deda
 * 
Packit 78deda
 * __END_OF_JASPER_LICENSE__
Packit 78deda
 */
Packit 78deda
Packit 78deda
/*
Packit 78deda
 * Image Class
Packit 78deda
 *
Packit 78deda
 * $Id$
Packit 78deda
 */
Packit 78deda
Packit 78deda
#ifndef JAS_IMAGE_H
Packit 78deda
#define JAS_IMAGE_H
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Includes.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
#include "netpbm/pm_c_util.h"
Packit 78deda
#include <jasper/jas_stream.h>
Packit 78deda
#include <jasper/jas_seq.h>
Packit 78deda
Packit 78deda
#ifdef __cplusplus
Packit 78deda
extern "C" {
Packit 78deda
#endif
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Constants.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
/*
Packit 78deda
 * Miscellaneous constants.
Packit 78deda
 */
Packit 78deda
Packit 78deda
/* The threshold at which image data is no longer stored in memory. */
Packit 78deda
#define JAS_IMAGE_INMEMTHRESH	(16 * 1024 * 1024)
Packit 78deda
Packit 78deda
/*
Packit 78deda
 * Color models.
Packit 78deda
 */
Packit 78deda
Packit 78deda
#define JAS_IMAGE_CS_UNKNOWN	0	/* Unknown */
Packit 78deda
#define	JAS_IMAGE_CS_GRAY	1	/* Standard Gray */
Packit 78deda
#define	JAS_IMAGE_CS_RGB	2	/* Standard RGB */
Packit 78deda
#define	JAS_IMAGE_CS_YCBCR	3	/* Standard YCC */
Packit 78deda
#if 0
Packit 78deda
#define	JAS_IMAGE_CM_ICC	4	/* ICC Profile */
Packit 78deda
#endif
Packit 78deda
/*
Packit 78deda
 * Component types
Packit 78deda
 */
Packit 78deda
Packit 78deda
#define	JAS_IMAGE_CT_UNKNOWN	0x10000
Packit 78deda
#define	JAS_IMAGE_CT_COLOR(n)	((n) & 0x7fff)
Packit 78deda
#define	JAS_IMAGE_CT_OPACITY	0x08000
Packit 78deda
Packit 78deda
#define	JAS_IMAGE_CT_RGB_R	0
Packit 78deda
#define	JAS_IMAGE_CT_RGB_G	1
Packit 78deda
#define	JAS_IMAGE_CT_RGB_B	2
Packit 78deda
Packit 78deda
#define	JAS_IMAGE_CT_YCBCR_Y	0
Packit 78deda
#define	JAS_IMAGE_CT_YCBCR_CB	1
Packit 78deda
#define	JAS_IMAGE_CT_YCBCR_CR	2
Packit 78deda
Packit 78deda
#define	JAS_IMAGE_CT_GRAY_Y	0
Packit 78deda
Packit 78deda
/*****************************************************************************\
Packit 78deda
* Image class and supporting classes.
Packit 78deda
\*****************************************************************************/
Packit 78deda
Packit 78deda
/* Image component class. */
Packit 78deda
Packit 78deda
typedef struct {
Packit 78deda
Packit 78deda
	uint_fast32_t tlx_;
Packit 78deda
	/* The x-coordinate of the top-left corner of the component. */
Packit 78deda
Packit 78deda
	uint_fast32_t tly_;
Packit 78deda
	/* The y-coordinate of the top-left corner of the component. */
Packit 78deda
Packit 78deda
	uint_fast32_t hstep_;
Packit 78deda
	/* The horizontal sampling period in units of the reference grid. */
Packit 78deda
Packit 78deda
	uint_fast32_t vstep_;
Packit 78deda
	/* The vertical sampling period in units of the reference grid. */
Packit 78deda
Packit 78deda
	uint_fast32_t width_;
Packit 78deda
	/* The component width in samples. */
Packit 78deda
Packit 78deda
	uint_fast32_t height_;
Packit 78deda
	/* The component height in samples. */
Packit 78deda
Packit 78deda
	uint_fast16_t prec_;
Packit 78deda
	/* The precision of the sample data (i.e., the number of bits per
Packit 78deda
	sample).  If the samples are signed values, this quantity
Packit 78deda
	includes the sign bit. */
Packit 78deda
Packit 78deda
	uint_fast8_t sgnd_;
Packit 78deda
	/* The signedness of the sample data. */
Packit 78deda
Packit 78deda
	jas_stream_t *stream_;
Packit 78deda
	/* The stream containing the component data. */
Packit 78deda
Packit 78deda
	int cps_;
Packit 78deda
	/* The number of characters per sample in the stream. */
Packit 78deda
Packit 78deda
	uint_fast32_t type_;
Packit 78deda
	/* The type of component (e.g., opacity, red, green, blue, luma). */
Packit 78deda
Packit 78deda
} jas_image_cmpt_t;
Packit 78deda
Packit 78deda
/* Image class. */
Packit 78deda
Packit 78deda
typedef struct {
Packit 78deda
Packit 78deda
	uint_fast32_t tlx_;
Packit 78deda
	/* The x-coordinate of the top-left corner of the image bounding box. */
Packit 78deda
Packit 78deda
	uint_fast32_t tly_;
Packit 78deda
	/* The y-coordinate of the top-left corner of the image bounding box. */
Packit 78deda
Packit 78deda
	uint_fast32_t brx_;
Packit 78deda
	/* The x-coordinate of the bottom-right corner of the image bounding
Packit 78deda
	  box (plus one). */
Packit 78deda
Packit 78deda
	uint_fast32_t bry_;
Packit 78deda
	/* The y-coordinate of the bottom-right corner of the image bounding
Packit 78deda
	  box (plus one). */
Packit 78deda
Packit 78deda
	uint_fast16_t numcmpts_;
Packit 78deda
	/* The number of components. */
Packit 78deda
Packit 78deda
	uint_fast16_t maxcmpts_;
Packit 78deda
	/* The maximum number of components that this image can have (i.e., the
Packit 78deda
	  allocated size of the components array). */
Packit 78deda
Packit 78deda
	jas_image_cmpt_t **cmpts_;
Packit 78deda
	/* Per-component information. */
Packit 78deda
Packit 78deda
	int colorspace_;
Packit 78deda
	/* The color space used (e.g., RGB, YCbCr, gray).  This field is only
Packit 78deda
	of particular relevance in the case of a multi-component image. */
Packit 78deda
Packit 78deda
	unsigned char *iccp_;
Packit 78deda
	/* ICC profile information. */
Packit 78deda
Packit 78deda
	int iccplen_;
Packit 78deda
Packit 78deda
	bool inmem_;
Packit 78deda
Packit 78deda
} jas_image_t;
Packit 78deda
Packit 78deda
/* Component parameters class. */
Packit 78deda
/* This data type exists solely/mainly for the purposes of the
Packit 78deda
  jas_image_create function. */
Packit 78deda
Packit 78deda
typedef struct {
Packit 78deda
Packit 78deda
	uint_fast32_t tlx;
Packit 78deda
	/* The x-coordinate of the top-left corner of the component. */
Packit 78deda
Packit 78deda
	uint_fast32_t tly;
Packit 78deda
	/* The y-coordinate of the top-left corner of the component. */
Packit 78deda
Packit 78deda
	uint_fast32_t hstep;
Packit 78deda
	/* The horizontal sampling period in units of the reference grid. */
Packit 78deda
Packit 78deda
	uint_fast32_t vstep;
Packit 78deda
	/* The vertical sampling period in units of the reference grid. */
Packit 78deda
Packit 78deda
	uint_fast32_t width;
Packit 78deda
	/* The width of the component in samples. */
Packit 78deda
Packit 78deda
	uint_fast32_t height;
Packit 78deda
	/* The height of the component in samples. */
Packit 78deda
Packit 78deda
	uint_fast16_t prec;
Packit 78deda
	/* The precision of the component sample data. */
Packit 78deda
Packit 78deda
	bool sgnd;
Packit 78deda
	/* The signedness of the component sample data. */
Packit 78deda
Packit 78deda
} jas_image_cmptparm_t;
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* File format related classes.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
#define	JAS_IMAGE_MAXFMTS	32
Packit 78deda
/* The maximum number of image data formats we can handle. */
Packit 78deda
Packit 78deda
/* Image format-dependent operations. */
Packit 78deda
Packit 78deda
typedef struct {
Packit 78deda
Packit 78deda
	jas_image_t *(*decode)(jas_stream_t *in, char *opts);
Packit 78deda
	/* Decode image data from a stream. */
Packit 78deda
Packit 78deda
	int (*encode)(jas_image_t *image, jas_stream_t *out, char *opts);
Packit 78deda
	/* Encode image data to a stream. */
Packit 78deda
Packit 78deda
	int (*validate)(jas_stream_t *in);
Packit 78deda
	/* Determine if stream data is in a particular format. */
Packit 78deda
Packit 78deda
} jas_image_fmtops_t;
Packit 78deda
Packit 78deda
/* Image format information. */
Packit 78deda
Packit 78deda
typedef struct {
Packit 78deda
Packit 78deda
	int id;
Packit 78deda
	/* The ID for this format. */
Packit 78deda
Packit 78deda
	char *name;
Packit 78deda
	/* The name by which this format is identified. */
Packit 78deda
Packit 78deda
	char *ext;
Packit 78deda
	/* The file name extension associated with this format. */
Packit 78deda
Packit 78deda
	char *desc;
Packit 78deda
	/* A brief description of the format. */
Packit 78deda
Packit 78deda
	jas_image_fmtops_t ops;
Packit 78deda
	/* The operations for this format. */
Packit 78deda
Packit 78deda
} jas_image_fmtinfo_t;
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Image operations.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
/* Create an image. */
Packit 78deda
jas_image_t *jas_image_create(uint_fast16_t numcmpts,
Packit 78deda
  jas_image_cmptparm_t *cmptparms, int colorspace);
Packit 78deda
Packit 78deda
/* Create an "empty" image. */
Packit 78deda
jas_image_t *jas_image_create0(void);
Packit 78deda
Packit 78deda
/* Clone an image. */
Packit 78deda
jas_image_t *jas_image_copy(jas_image_t *image);
Packit 78deda
Packit 78deda
/* Deallocate any resources associated with an image. */
Packit 78deda
void jas_image_destroy(jas_image_t *image);
Packit 78deda
Packit 78deda
/* Get the width of the image in units of the image reference grid. */
Packit 78deda
#define jas_image_width(image) \
Packit 78deda
	((image)->brx_ - (image)->tlx_)
Packit 78deda
Packit 78deda
/* Get the height of the image in units of the image reference grid. */
Packit 78deda
#define	jas_image_height(image) \
Packit 78deda
	((image)->bry_ - (image)->tly_)
Packit 78deda
Packit 78deda
/* Get the x-coordinate of the top-left corner of the image bounding box
Packit 78deda
  on the reference grid. */
Packit 78deda
#define jas_image_tlx(image) \
Packit 78deda
	((image)->tlx_)
Packit 78deda
Packit 78deda
/* Get the y-coordinate of the top-left corner of the image bounding box
Packit 78deda
  on the reference grid. */
Packit 78deda
#define jas_image_tly(image) \
Packit 78deda
	((image)->tly_)
Packit 78deda
Packit 78deda
/* Get the x-coordinate of the bottom-right corner of the image bounding box
Packit 78deda
  on the reference grid (plus one). */
Packit 78deda
#define jas_image_brx(image) \
Packit 78deda
	((image)->brx_)
Packit 78deda
Packit 78deda
/* Get the y-coordinate of the bottom-right corner of the image bounding box
Packit 78deda
  on the reference grid (plus one). */
Packit 78deda
#define jas_image_bry(image) \
Packit 78deda
	((image)->bry_)
Packit 78deda
Packit 78deda
/* Get the number of image components. */
Packit 78deda
#define	jas_image_numcmpts(image) \
Packit 78deda
	((image)->numcmpts_)
Packit 78deda
Packit 78deda
/* Get the color model used by the image. */
Packit 78deda
#define	jas_image_colorspace(image) \
Packit 78deda
	((image)->colorspace_)
Packit 78deda
Packit 78deda
/* Set the color model for an image. */
Packit 78deda
#define jas_image_setcolorspace(image, colorspace) \
Packit 78deda
	((image)->colorspace_ = (colorspace))
Packit 78deda
Packit 78deda
#define jas_image_cmpttype(image, cmptno) \
Packit 78deda
	((image)->cmpts_[(cmptno)]->type_)
Packit 78deda
#define jas_image_setcmpttype(image, cmptno, type) \
Packit 78deda
	((image)->cmpts_[(cmptno)]->type_ = (type))
Packit 78deda
Packit 78deda
/* Get the width of a component. */
Packit 78deda
#define	jas_image_cmptwidth(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->width_)
Packit 78deda
Packit 78deda
/* Get the height of a component. */
Packit 78deda
#define	jas_image_cmptheight(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->height_)
Packit 78deda
Packit 78deda
/* Get the signedness of the sample data for a component. */
Packit 78deda
#define	jas_image_cmptsgnd(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->sgnd_)
Packit 78deda
Packit 78deda
/* Get the precision of the sample data for a component. */
Packit 78deda
#define	jas_image_cmptprec(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->prec_)
Packit 78deda
Packit 78deda
/* Get the horizontal subsampling factor for a component. */
Packit 78deda
#define	jas_image_cmpthstep(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->hstep_)
Packit 78deda
Packit 78deda
/* Get the vertical subsampling factor for a component. */
Packit 78deda
#define	jas_image_cmptvstep(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->vstep_)
Packit 78deda
Packit 78deda
/* Get the x-coordinate of the top-left corner of a component. */
Packit 78deda
#define	jas_image_cmpttlx(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->tlx_)
Packit 78deda
Packit 78deda
/* Get the y-coordinate of the top-left corner of a component. */
Packit 78deda
#define	jas_image_cmpttly(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->tly_)
Packit 78deda
Packit 78deda
/* Get the x-coordinate of the bottom-right corner of a component
Packit 78deda
  (plus "one"). */
Packit 78deda
#define	jas_image_cmptbrx(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->tlx_ + (image)->cmpts_[cmptno]->width_ * \
Packit 78deda
	  (image)->cmpts_[cmptno]->hstep_)
Packit 78deda
Packit 78deda
/* Get the y-coordinate of the bottom-right corner of a component
Packit 78deda
  (plus "one"). */
Packit 78deda
#define	jas_image_cmptbry(image, cmptno) \
Packit 78deda
	((image)->cmpts_[cmptno]->tly_ + (image)->cmpts_[cmptno]->height_ * \
Packit 78deda
	  (image)->cmpts_[cmptno]->vstep_)
Packit 78deda
Packit 78deda
/* Get the raw size of an image (i.e., the nominal size of the image without
Packit 78deda
  any compression. */
Packit 78deda
uint_fast32_t jas_image_rawsize(jas_image_t *image);
Packit 78deda
Packit 78deda
/* Create an image from a stream in some specified format. */
Packit 78deda
jas_image_t *jas_image_decode(jas_stream_t *in, int fmt, char *optstr);
Packit 78deda
Packit 78deda
/* Write an image to a stream in a specified format. */
Packit 78deda
int jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt,
Packit 78deda
  char *optstr);
Packit 78deda
Packit 78deda
/* Read a rectangular region of an image component. */
Packit 78deda
/* The position and size of the rectangular region to be read is specified
Packit 78deda
relative to the component's coordinate system. */
Packit 78deda
int jas_image_readcmpt(jas_image_t *image, uint_fast16_t cmptno,
Packit 78deda
  uint_fast32_t x, uint_fast32_t y, uint_fast32_t width, uint_fast32_t height,
Packit 78deda
  jas_matrix_t *data);
Packit 78deda
Packit 78deda
/* Write a rectangular region of an image component. */
Packit 78deda
int jas_image_writecmpt(jas_image_t *image, uint_fast16_t cmptno,
Packit 78deda
  uint_fast32_t x, uint_fast32_t y, uint_fast32_t width, uint_fast32_t height,
Packit 78deda
  jas_matrix_t *data);
Packit 78deda
Packit 78deda
/* Delete a component from an image. */
Packit 78deda
void jas_image_delcmpt(jas_image_t *image, uint_fast16_t cmptno);
Packit 78deda
Packit 78deda
/* Add a component to an image. */
Packit 78deda
int jas_image_addcmpt(jas_image_t *image, uint_fast16_t cmptno,
Packit 78deda
  jas_image_cmptparm_t *cmptparm);
Packit 78deda
Packit 78deda
/* Copy a component from one image to another. */
Packit 78deda
int jas_image_copycmpt(jas_image_t *dstimage, int dstcmptno,
Packit 78deda
  jas_image_t *srcimage, int srccmptno);
Packit 78deda
Packit 78deda
#if 0
Packit 78deda
int_fast64_t jas_image_readcmpt1(jas_image_t *image, uint_fast16_t cmptno,
Packit 78deda
  uint_fast32_t x, uint_fast32_t y);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#define	JAS_IMAGE_CDT_GETSGND(dtype) (((dtype) >> 7) & 1)
Packit 78deda
#define	JAS_IMAGE_CDT_SETSGND(dtype) (((dtype) & 1) << 7)
Packit 78deda
#define	JAS_IMAGE_CDT_GETPREC(dtype) ((dtype) & 0x7f)
Packit 78deda
#define	JAS_IMAGE_CDT_SETPREC(dtype) ((dtype) & 0x7f)
Packit 78deda
Packit 78deda
#define	jas_image_cmptdtype(image, cmptno) \
Packit 78deda
	(JAS_IMAGE_CDT_SETSGND((image)->cmpts_[cmptno]->sgnd_) | JAS_IMAGE_CDT_SETPREC((image)->cmpts_[cmptno]->prec_))
Packit 78deda
Packit 78deda
void jas_image_dump(jas_image_t *image, FILE *out);
Packit 78deda
Packit 78deda
int jas_image_depalettize(jas_image_t *image, int cmptno, int numlutents,
Packit 78deda
  int_fast32_t *lutents, int dtype, int newcmptno);
Packit 78deda
Packit 78deda
int jas_image_readcmptsample(jas_image_t *image, int cmptno, int x, int y);
Packit 78deda
void jas_image_writecmptsample(jas_image_t *image, int cmptno, int x, int y,
Packit 78deda
  int_fast32_t v);
Packit 78deda
Packit 78deda
int jas_image_getcmptbytype(jas_image_t *image, int ctype);
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Image format-related operations.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
/* Clear the table of image formats. */
Packit 78deda
void jas_image_clearfmts(void);
Packit 78deda
Packit 78deda
/* Add entry to table of image formats. */
Packit 78deda
int jas_image_addfmt(int id, const char *name, const char *ext, 
Packit 78deda
  const char *desc,
Packit 78deda
  jas_image_fmtops_t *ops);
Packit 78deda
Packit 78deda
/* Get the ID for the image format with the specified name. */
Packit 78deda
int jas_image_strtofmt(char *s);
Packit 78deda
Packit 78deda
/* Get the name of the image format with the specified ID. */
Packit 78deda
char *jas_image_fmttostr(int fmt);
Packit 78deda
Packit 78deda
/* Lookup image format information by the format ID. */
Packit 78deda
jas_image_fmtinfo_t *jas_image_lookupfmtbyid(int id);
Packit 78deda
Packit 78deda
/* Lookup image format information by the format name. */
Packit 78deda
jas_image_fmtinfo_t *jas_image_lookupfmtbyname(const char *name);
Packit 78deda
Packit 78deda
/* Guess the format of an image file based on its name. */
Packit 78deda
int jas_image_fmtfromname(char *filename);
Packit 78deda
Packit 78deda
/* Get the format of image data in a stream. */
Packit 78deda
int jas_image_getfmt(jas_stream_t *in);
Packit 78deda
Packit 78deda
/******************************************************************************\
Packit 78deda
* Image format-dependent operations.
Packit 78deda
\******************************************************************************/
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_JPG_CAPABILITY)
Packit 78deda
/* Format-dependent operations for JPG capability. */
Packit 78deda
jas_image_t *jpg_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int jpg_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int jpg_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_MIF_CAPABILITY)
Packit 78deda
/* Format-dependent operations for MIF capability. */
Packit 78deda
jas_image_t *mif_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int mif_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int mif_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_PNM_CAPABILITY)
Packit 78deda
/* Format-dependent operations for PNM capability. */
Packit 78deda
jas_image_t *pnm_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int pnm_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int pnm_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_RAS_CAPABILITY)
Packit 78deda
/* Format-dependent operations for Sun Rasterfile capability. */
Packit 78deda
jas_image_t *ras_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int ras_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int ras_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_BMP_CAPABILITY)
Packit 78deda
/* Format-dependent operations for BMP capability. */
Packit 78deda
jas_image_t *bmp_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int bmp_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int bmp_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_JP2_CAPABILITY)
Packit 78deda
/* Format-dependent operations for JP2 capability. */
Packit 78deda
jas_image_t *jp2_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int jp2_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_JPC_CAPABILITY)
Packit 78deda
/* Format-dependent operations for JPEG-2000 code stream capability. */
Packit 78deda
jas_image_t *jpc_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int jpc_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int jpc_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#if !defined(EXCLUDE_PGX_CAPABILITY)
Packit 78deda
/* Format-dependent operations for PGX capability. */
Packit 78deda
jas_image_t *pgx_decode(jas_stream_t *in, char *optstr);
Packit 78deda
int pgx_encode(jas_image_t *image, jas_stream_t *out, char *optstr);
Packit 78deda
int pgx_validate(jas_stream_t *in);
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#ifdef __cplusplus
Packit 78deda
}
Packit 78deda
#endif
Packit 78deda
Packit 78deda
#endif