Path: blob/master/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.h
41159 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef AWT_PARSE_IMAGE_H26#define AWT_PARSE_IMAGE_H2728#include <jni.h>29#include <jni_util.h>3031/***************************************************************************32* Definitions *33***************************************************************************/3435#ifndef TRUE36#define TRUE (1)37#endif3839#ifndef FALSE40#define FALSE (0)41#endif4243typedef enum {44IMG_SUCCESS=0,45IMG_FAILURE=-146} ImgStatus_t;4748#define UNKNOWN_DATA_TYPE 049#define BYTE_DATA_TYPE 150#define SHORT_DATA_TYPE 251#define INT_DATA_TYPE 35253#define UNKNOWN_RASTER_TYPE 054#define COMPONENT_RASTER_TYPE 155#define BANDED_RASTER_TYPE 256#define PACKED_RASTER_TYPE 35758#define UNKNOWN_CM_TYPE 059#define COMPONENT_CM_TYPE 160#define DIRECT_CM_TYPE 261#define INDEX_CM_TYPE 362#define PACKED_CM_TYPE 46364/* Packing types */65#define UNKNOWN_PACKING 066#define BYTE_COMPONENTS 0x167#define SHORT_COMPONENTS 0x268#define PACKED_INT 0x369#define PACKED_SHORT 0x470#define PACKED_BYTE 0x57172/* Interleaving */73#define INTERLEAVED 0x1074#define BANDED 0x2075#define SINGLE_BAND 0x3076#define PACKED_BAND 0x407778#define BYTE_INTERLEAVED (BYTE_COMPONENTS | INTERLEAVED)79#define SHORT_INTERLEAVED (SHORT_COMPONENTS | INTERLEAVED)80#define BYTE_SINGLE_BAND (BYTE_COMPONENTS | SINGLE_BAND)81#define BYTE_PACKED_BAND (BYTE_COMPONENTS | PACKED_BAND)82#define SHORT_SINGLE_BAND (SHORT_COMPONENTS | SINGLE_BAND)83#define BYTE_BANDED (BYTE_COMPONENTS | BANDED)84#define SHORT_BANDED (SHORT_COMPONENTS | BANDED)85#define PACKED_BYTE_INTER (PACKED_BYTE | INTERLEAVED)86#define PACKED_SHORT_INTER (PACKED_SHORT | INTERLEAVED)87#define PACKED_INT_INTER (PACKED_INT | INTERLEAVED)8889#define MAX_NUMBANDS 329091/* Struct that holds information about a SinglePixelPackedModel object */92typedef struct {93jint maskArray[MAX_NUMBANDS];94jint offsets[MAX_NUMBANDS];95jint nBits[MAX_NUMBANDS];96jint maxBitSize;97jint isUsed; // flag to indicate whether the raster sample model is SPPSM98} SPPSampleModelS_t;99100/* Struct that holds information for the Raster object */101typedef struct {102jobject jraster; /* The raster object */103jobject jdata; /* Data storage object */104jobject jsampleModel; /* The sample model */105SPPSampleModelS_t sppsm; /* SinglePixelPackedSampleModel mask/offsets */106107jint *chanOffsets; /* Array of channel offsets (or bit offsets) */108109int width; /* Width of the raster */110int height; /* Height of the raster */111int minX; /* origin of this raster x */112int minY; /* origin of this raster x */113114int baseOriginX; /* origin of base raster */115int baseOriginY; /* origin of base raster x */116int baseRasterWidth; /* size of baseRaster */117int baseRasterHeight; /* size of baseRaster */118int numDataElements; /* Number of data bands in raster */119int numBands; /* Number of bands in the raster */120int scanlineStride; /* Scanline Stride */121int pixelStride; /* Pixel stride (or pixel bit stride) */122int dataIsShared; /* If TRUE, data is shared */123int rasterType; /* Type of raster */124int dataType; /* Data type of the raster data */125int dataSize; /* Number of bytes per data element */126int type; /* Raster type */127} RasterS_t;128129130/* Struct that holds information about the ColorModel object */131typedef struct {132jobject jrgb; /* For ICM, rgb lut object */133jobject jcmodel;134jobject jcspace;135jint *nBits; /* Number of bits per component */136137int cmType; /* Type of color model */138int isDefaultCM; /* If TRUE, it is the default color model */139int isDefaultCompatCM; /* If TRUE, it is compatible with the default CM */140/* Might be 4 byte and band order different */141int is_sRGB; /* If TRUE, the color space is sRGB */142int numComponents; /* Total number of components */143int supportsAlpha; /* If it supports alpha */144int isAlphaPre; /* If TRUE, alpha is premultiplied */145int csType; /* Type of ColorSpace */146int transparency;147int maxNbits;148int transIdx; /* For ICM, transparent pixel */149int mapSize; /* For ICM, size of the lut */150} ColorModelS_t;151152typedef struct {153int *colorOrder;154155int channelOffset;156int dataOffset; /* # bytes into the data array */157int sStride;158int pStride;159int packing;160int numChans;161int alphaIndex; /* -1 if no alpha */162int needToExpand; /* If true, the pixels are packed */163int expandToNbits; /* If needToExpand, how many bits to allocate */164} HintS_t;165166/* Struct that holds information for the BufferedImage object */167typedef struct {168jobject jimage; /* The BufferedImage object */169RasterS_t raster; /* The raster structure */170ColorModelS_t cmodel; /* The color model structure */171HintS_t hints; /* Hint structure */172int imageType; /* Type of image */173} BufImageS_t;174175/***************************************************************************176* Function Prototypes *177***************************************************************************/178int awt_parseImage(JNIEnv *env, jobject jimage, BufImageS_t **imagePP,179int handleCustom);180181int awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP);182183int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType,184ColorModelS_t *cmP);185186void awt_freeParsedRaster(RasterS_t *rasterP, int freeRasterP);187188void awt_freeParsedImage(BufImageS_t *imageP, int freeImageP);189190int awt_getPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);191192int awt_setPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);193194#endif /* AWT_PARSE_IMAGE_H */195196197