img_globals.h revision 10731:e66f69113b89
1/* 2 * Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26/* 27 * This file provides some global definitions needed by the image 28 * conversion package. 29 */ 30 31#ifndef IMAGE_GLOBALS_H 32#define IMAGE_GLOBALS_H 33 34 35/* Image Conversion function return codes. */ 36#define SCALEFAILURE -1 37#define SCALENOOP 0 38#define SCALESUCCESS 1 39 40/* 41 * The constants needed to choose from among the many variants of image 42 * conversion functions that can be constructed with the standard header 43 * files. The types of input for the image conversion functions are 44 * broken down into 5 different attributes each with 2 to 4 different 45 * variants: 46 * 47 * SCALING: SCALED or UNSCALED 48 * INPUT SIZE: BYTEIN (8-bit) or INTIN (32-bit) 49 * ALPHA: OPAQUE or ALPHA 50 * ORDER: TDLR or RANDOM 51 * COLORMODEL: ICM, DCM, DCM8 (8-bits for each component) or ANY 52 * 53 * For each attribute, a mask is defined with the "BITS" suffix which 54 * identifies which bits contain the variation information for that 55 * particular attribute. The input information should be analyzed and 56 * characterized for each of the above categories and the appropriate 57 * bit constants OR'd together to produce a unique constant that 58 * identifies which conversion function is needed. The reason that 59 * attributes of the output space are not indicated in the masks is 60 * that typically only a single output device type needs to be supported 61 * at a time and so a vector of the functions specific to the necessary 62 * output device can be constructed at AWT initialization time and then 63 * indexed into with the constant identifier that characterizes the 64 * input data, which is only known and constantly varies at run-time. 65 */ 66#define IMGCV_UNSCALED (0 << 0) 67#define IMGCV_SCALED (1 << 0) 68#define IMGCV_SCALEBITS (1 << 0) 69#define IMGCV_BYTEIN (0 << 1) 70#define IMGCV_INTIN (1 << 1) 71#define IMGCV_INSIZEBITS (1 << 1) 72#define IMGCV_OPAQUE (0 << 2) 73#define IMGCV_ALPHA (1 << 2) 74#define IMGCV_ALPHABITS (1 << 2) 75#define IMGCV_TDLRORDER (0 << 3) 76#define IMGCV_RANDORDER (1 << 3) 77#define IMGCV_ORDERBITS (1 << 3) 78#define IMGCV_ICM (0 << 4) 79#define IMGCV_DCM (1 << 4) 80#define IMGCV_DCM8 (2 << 4) 81#define IMGCV_ANYCM (3 << 4) 82#define IMGCV_CMBITS (3 << 4) 83 84#define NUM_IMGCV (1 << 6) /* total # of IMGCV variants */ 85 86/* 87 * The structure which holds the image conversion data. 88 */ 89typedef struct { 90 void *outbuf; 91 void *maskbuf; 92 void *fserrors; 93} ImgConvertData; 94 95/* 96 * The standard structure which holds information about the pixels 97 * used in the output device. 98 */ 99typedef struct { 100 int grayscale; 101 int bitsperpixel; 102 int rOff; 103 int gOff; 104 int bOff; 105 int rScale; 106 int gScale; 107 int bScale; 108} ImgColorData; 109 110/* 111 * The private data member attached to a ColorModel which caches 112 * the information needed to characterize and use a ColorModel 113 * object on the fly. 114 */ 115typedef struct { 116 int type; 117 struct methodblock *mb; 118} ImgCMData; 119 120/* 121 * The standard signature of all of the image conversion functions 122 * that can be produced with this package of include files. 123 */ 124 125/* 126 * FIXME! 127 */ 128typedef int ImgConvertFcn(void *colormodel, 129 int srcOX, int srcOY, int srcW, int srcH, 130 void *srcpix, int srcOff, int srcBPP, int srcScan, 131 int srcTotalWidth, int srcTotalHeight, 132 int dstTotalWidth, int dstTotalHeight, 133 ImgConvertData *cvdata, ImgColorData *clrdata); 134 135/* 136 * The type of the error matrix used in the ordered dithering code. 137 */ 138typedef unsigned char uns_ordered_dither_array[8][8]; 139typedef char sgn_ordered_dither_array[8][8]; 140 141/* 142 * The function provided for constructing the ordered dithering error 143 * matrices based on a given quantum (i.e. the amplitude of the maximum 144 * error values appearing in the matrix which should be the same as the 145 * distance between adjacent allocated component values in the color cube). 146 */ 147extern void make_uns_ordered_dither_array(uns_ordered_dither_array oda, 148 int quantum); 149extern void make_sgn_ordered_dither_array(char* oda, int errmin, int errmax); 150 151/* 152 * The function provided for calculating the contents of the ImgCMData 153 * structure which can be attached to ColorModels to simplify the 154 * work of characterizing their data. 155 */ 156extern ImgCMData *img_getCMData(void *cmh); 157 158#endif /* IMAGE_GLOBALS_H */ 159