1 | /* |
2 | * Copyright (c) 2001, 2008, 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 | #ifndef Index8Gray_h_Included |
27 | #define Index8Gray_h_Included |
28 | |
29 | #include "IntDcm.h" |
30 | #include "ByteGray.h" |
31 | |
32 | /* |
33 | * This file contains macro and type definitions used by the macros in |
34 | * LoopMacros.h to manipulate a surface of type "Index8Gray". |
35 | */ |
36 | |
37 | typedef jubyte Index8GrayPixelType; |
38 | typedef jubyte Index8GrayDataType; |
39 | |
40 | #define Index8GrayIsOpaque 1 |
41 | |
42 | #define Index8GrayPixelStride 1 |
43 | #define Index8GrayBitsPerPixel 8 |
44 | |
45 | #define DeclareIndex8GrayLoadVars(PREFIX) \ |
46 | jint *PREFIX ## Lut; |
47 | |
48 | #define DeclareIndex8GrayStoreVars(PREFIX) \ |
49 | jint *PREFIX ## InvGrayLut; |
50 | |
51 | #define SetIndex8GrayStoreVarsYPos(PREFIX, pRasInfo, LOC) |
52 | #define SetIndex8GrayStoreVarsXPos(PREFIX, pRasInfo, LOC) |
53 | #define InitIndex8GrayLoadVars(PREFIX, pRasInfo) \ |
54 | PREFIX ## Lut = (pRasInfo)->lutBase |
55 | |
56 | #define InitIndex8GrayStoreVarsY(PREFIX, pRasInfo) \ |
57 | PREFIX ## InvGrayLut = (pRasInfo)->invGrayTable; |
58 | |
59 | #define InitIndex8GrayStoreVarsX(PREFIX, pRasInfo) |
60 | #define NextIndex8GrayStoreVarsX(PREFIX) |
61 | #define NextIndex8GrayStoreVarsY(PREFIX) |
62 | |
63 | #define Index8GrayXparLutEntry -1 |
64 | #define Index8GrayIsXparLutEntry(pix) (pix < 0) |
65 | #define StoreIndex8GrayNonXparFromArgb StoreIndex8GrayFrom1IntArgb |
66 | |
67 | #define StoreIndex8GrayPixel(pRas, x, pixel) \ |
68 | ((pRas)[x] = (jubyte) (pixel)) |
69 | |
70 | #define DeclareIndex8GrayPixelData(PREFIX) |
71 | |
72 | #define (PIXEL, PREFIX) |
73 | |
74 | #define StoreIndex8GrayPixelData(pPix, x, pixel, PREFIX) \ |
75 | ((pPix)[x] = (jubyte)(pixel)) |
76 | |
77 | #define Index8GrayPixelFromArgb(pixel, rgb, pRasInfo) \ |
78 | do { \ |
79 | jint r, g, b, gray; \ |
80 | ExtractIntDcmComponentsX123(rgb, r, g, b); \ |
81 | gray = ComposeByteGrayFrom3ByteRgb(r, g, b); \ |
82 | (pixel) = (pRasInfo)->invGrayTable[gray]; \ |
83 | } while (0) |
84 | |
85 | #define LoadIndex8GrayTo1IntRgb(pRas, PREFIX, x, rgb) \ |
86 | (rgb) = PREFIX ## Lut[pRas[x]] |
87 | |
88 | #define LoadIndex8GrayTo1IntArgb(pRas, PREFIX, x, argb) \ |
89 | (argb) = PREFIX ## Lut[pRas[x]] |
90 | |
91 | #define LoadIndex8GrayTo1ByteGray(pRas, PREFIX, x, gray) \ |
92 | (gray) = (jubyte)PREFIX ## Lut[pRas[x]] |
93 | |
94 | #define LoadIndex8GrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
95 | r = g = b = (jubyte)PREFIX ## Lut[pRas[x]] |
96 | |
97 | #define LoadIndex8GrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
98 | do { \ |
99 | a = 0xff; \ |
100 | LoadIndex8GrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \ |
101 | } while (0) |
102 | |
103 | #define StoreIndex8GrayFrom1IntRgb(pRas, PREFIX, x, rgb) \ |
104 | do { \ |
105 | int r, g, b; \ |
106 | ExtractIntDcmComponentsX123(rgb, r, g, b); \ |
107 | StoreIndex8GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \ |
108 | } while (0) |
109 | |
110 | #define StoreIndex8GrayFrom1IntArgb(pRas, PREFIX, x, argb) \ |
111 | StoreIndex8GrayFrom1IntRgb(pRas, PREFIX, x, argb) |
112 | |
113 | #define StoreIndex8GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
114 | do { \ |
115 | int gray = ComposeByteGrayFrom3ByteRgb(r, g, b); \ |
116 | (pRas)[x] = (jubyte) (PREFIX ## InvGrayLut[gray]); \ |
117 | } while (0) |
118 | |
119 | #define StoreIndex8GrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
120 | StoreIndex8GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) |
121 | |
122 | #define StoreIndex8GrayFrom1ByteGray(pRas, PREFIX, x, gray) \ |
123 | (pRas)[x] = (jubyte) (PREFIX ## InvGrayLut[gray]); |
124 | |
125 | #define CopyIndex8GrayToIntArgbPre(pRGB, i, PREFIX, pRow, x) \ |
126 | (pRGB)[i] = PREFIX ## Lut[pRow[x]] |
127 | |
128 | |
129 | #define DeclareIndex8GrayAlphaLoadData(PREFIX) \ |
130 | jint *PREFIX ## Lut; |
131 | |
132 | #define InitIndex8GrayAlphaLoadData(PREFIX, pRasInfo) \ |
133 | PREFIX ## Lut = (pRasInfo)->lutBase |
134 | |
135 | #define LoadAlphaFromIndex8GrayFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \ |
136 | COMP_PREFIX ## A = 0xff |
137 | |
138 | #define Postload1ByteGrayFromIndex8Gray(pRas, PREFIX, COMP_PREFIX) \ |
139 | COMP_PREFIX ## G = (jubyte)PREFIX ## Lut[(pRas)[0]] |
140 | |
141 | #define StoreIndex8GrayFrom1ByteGrayComps(pRas, PREFIX, x, COMP_PREFIX) \ |
142 | StoreIndex8GrayFrom1ByteGray(pRas, PREFIX, x, COMP_PREFIX ## G) |
143 | |
144 | #define Index8GrayIsPremultiplied 0 |
145 | |
146 | #endif /* Index8Gray_h_Included */ |
147 | |