0N/A/*
2362N/A * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef AWT_PARSE_IMAGE_H
0N/A#define AWT_PARSE_IMAGE_H
0N/A
0N/A#include <jni.h>
0N/A#include <jni_util.h>
0N/A
0N/A/***************************************************************************
0N/A * Definitions *
0N/A ***************************************************************************/
0N/A
0N/A#ifndef TRUE
0N/A#define TRUE (1)
0N/A#endif
0N/A
0N/A#ifndef FALSE
0N/A#define FALSE (0)
0N/A#endif
0N/A
0N/Atypedef enum {
0N/A IMG_SUCCESS=0,
0N/A IMG_FAILURE=-1
0N/A} ImgStatus_t;
0N/A
0N/A#define UNKNOWN_DATA_TYPE 0
0N/A#define BYTE_DATA_TYPE 1
0N/A#define SHORT_DATA_TYPE 2
0N/A#define INT_DATA_TYPE 3
0N/A
0N/A#define UNKNOWN_RASTER_TYPE 0
0N/A#define COMPONENT_RASTER_TYPE 1
0N/A#define BANDED_RASTER_TYPE 2
0N/A#define PACKED_RASTER_TYPE 3
0N/A
0N/A#define UNKNOWN_CM_TYPE 0
0N/A#define COMPONENT_CM_TYPE 1
0N/A#define DIRECT_CM_TYPE 2
0N/A#define INDEX_CM_TYPE 3
0N/A#define PACKED_CM_TYPE 4
0N/A
0N/A/* Packing types */
0N/A#define UNKNOWN_PACKING 0
0N/A#define BYTE_COMPONENTS 0x1
0N/A#define SHORT_COMPONENTS 0x2
0N/A#define PACKED_INT 0x3
0N/A#define PACKED_SHORT 0x4
0N/A#define PACKED_BYTE 0x5
0N/A
0N/A/* Interleaving */
0N/A#define INTERLEAVED 0x10
0N/A#define BANDED 0x20
0N/A#define SINGLE_BAND 0x30
0N/A#define PACKED_BAND 0x40
0N/A
0N/A#define BYTE_INTERLEAVED (BYTE_COMPONENTS | INTERLEAVED)
0N/A#define SHORT_INTERLEAVED (SHORT_COMPONENTS | INTERLEAVED)
0N/A#define BYTE_SINGLE_BAND (BYTE_COMPONENTS | SINGLE_BAND)
0N/A#define BYTE_PACKED_BAND (BYTE_COMPONENTS | PACKED_BAND)
0N/A#define SHORT_SINGLE_BAND (SHORT_COMPONENTS | SINGLE_BAND)
0N/A#define BYTE_BANDED (BYTE_COMPONENTS | BANDED)
0N/A#define SHORT_BANDED (SHORT_COMPONENTS | BANDED)
0N/A#define PACKED_BYTE_INTER (PACKED_BYTE | INTERLEAVED)
0N/A#define PACKED_SHORT_INTER (PACKED_SHORT | INTERLEAVED)
0N/A#define PACKED_INT_INTER (PACKED_INT | INTERLEAVED)
0N/A
0N/A#define MAX_NUMBANDS 32
0N/A
0N/A/* Struct that holds information about a SinglePixelPackedModel object */
0N/Atypedef struct {
0N/A jint maskArray[MAX_NUMBANDS];
0N/A jint offsets[MAX_NUMBANDS];
0N/A jint nBits[MAX_NUMBANDS];
0N/A jint maxBitSize;
5710N/A jint isUsed; // flag to indicate whether the raster sample model is SPPSM
0N/A} SPPSampleModelS_t;
0N/A
0N/A/* Struct that holds information for the Raster object */
0N/Atypedef struct {
0N/A jobject jraster; /* The raster object */
0N/A jobject jdata; /* Data storage object */
0N/A jobject jsampleModel; /* The sample model */
0N/A SPPSampleModelS_t sppsm; /* SinglePixelPackedSampleModel mask/offsets */
0N/A
0N/A jint *chanOffsets; /* Array of channel offsets (or bit offsets) */
0N/A
0N/A int width; /* Width of the raster */
0N/A int height; /* Height of the raster */
0N/A int minX; /* origin of this raster x */
0N/A int minY; /* origin of this raster x */
0N/A
0N/A int baseOriginX; /* origin of base raster */
0N/A int baseOriginY; /* origin of base raster x */
0N/A int baseRasterWidth; /* size of baseRaster */
0N/A int baseRasterHeight; /* size of baseRaster */
0N/A int numDataElements; /* Number of data bands in raster */
0N/A int numBands; /* Number of bands in the raster */
0N/A int scanlineStride; /* Scanline Stride */
0N/A int pixelStride; /* Pixel stride (or pixel bit stride) */
0N/A int dataIsShared; /* If TRUE, data is shared */
0N/A int rasterType; /* Type of raster */
0N/A int dataType; /* Data type of the raster data */
0N/A int dataSize; /* Number of bytes per data element */
0N/A int type; /* Raster type */
0N/A} RasterS_t;
0N/A
0N/A
0N/A/* Struct that holds information about the ColorModel object */
0N/Atypedef struct {
0N/A jobject jrgb; /* For ICM, rgb lut object */
0N/A jobject jcmodel;
0N/A jobject jcspace;
0N/A jint *nBits; /* Number of bits per component */
0N/A
0N/A int cmType; /* Type of color model */
0N/A int isDefaultCM; /* If TRUE, it is the default color model */
0N/A int isDefaultCompatCM; /* If TRUE, it is compatible with the default CM */
0N/A /* Might be 4 byte and band order different */
0N/A int is_sRGB; /* If TRUE, the color space is sRGB */
0N/A int numComponents; /* Total number of components */
0N/A int supportsAlpha; /* If it supports alpha */
0N/A int isAlphaPre; /* If TRUE, alpha is premultiplied */
0N/A int csType; /* Type of ColorSpace */
0N/A int transparency;
0N/A int maxNbits;
0N/A int transIdx; /* For ICM, transparent pixel */
0N/A int mapSize; /* For ICM, size of the lut */
0N/A} ColorModelS_t;
0N/A
0N/Atypedef struct {
0N/A int *colorOrder;
0N/A
0N/A int channelOffset;
0N/A int dataOffset; /* # bytes into the data array */
0N/A int sStride;
0N/A int pStride;
0N/A int packing;
0N/A int numChans;
0N/A int alphaIndex; /* -1 if no alpha */
0N/A int needToExpand; /* If true, the pixels are packed */
0N/A int expandToNbits; /* If needToExpand, how many bits to allocate */
0N/A} HintS_t;
0N/A
0N/A/* Struct that holds information for the BufferedImage object */
0N/Atypedef struct {
0N/A jobject jimage; /* The BufferedImage object */
0N/A RasterS_t raster; /* The raster structure */
0N/A ColorModelS_t cmodel; /* The color model structure */
0N/A HintS_t hints; /* Hint structure */
0N/A int imageType; /* Type of image */
0N/A} BufImageS_t;
0N/A
0N/A/***************************************************************************
0N/A * Function Prototypes *
0N/A ***************************************************************************/
0N/Aint awt_parseImage(JNIEnv *env, jobject jimage, BufImageS_t **imagePP,
0N/A int handleCustom);
0N/A
0N/Aint awt_parseRaster(JNIEnv *env, jobject jraster, RasterS_t *rasterP);
0N/A
0N/Aint awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType,
0N/A ColorModelS_t *cmP);
0N/A
0N/Avoid awt_freeParsedRaster(RasterS_t *rasterP, int freeRasterP);
0N/A
0N/Avoid awt_freeParsedImage(BufImageS_t *imageP, int freeImageP);
0N/A
0N/Aint awt_getPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
0N/A unsigned char *bufferP);
0N/Aint awt_setPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
0N/A unsigned char *bufferP);
0N/Aint awt_getPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
0N/A unsigned short *bufferP);
0N/Aint awt_setPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
0N/A unsigned short *bufferP);
0N/A
0N/A#endif /* AWT_PARSE_IMAGE_H */