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 Index12Gray_h_Included
27#define Index12Gray_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 "Index12Gray".
35 */
36
37typedef jushort Index12GrayPixelType;
38typedef jushort Index12GrayDataType;
39
40#define Index12GrayIsOpaque 1
41
42#define Index12GrayPixelStride 2
43#define Index12GrayBitsPerPixel 12
44
45#define DeclareIndex12GrayLoadVars(PREFIX) \
46 jint *PREFIX ## Lut;
47
48#define DeclareIndex12GrayStoreVars(PREFIX) \
49 jint *PREFIX ## InvGrayLut;
50
51#define SetIndex12GrayStoreVarsYPos(PREFIX, pRasInfo, LOC)
52#define SetIndex12GrayStoreVarsXPos(PREFIX, pRasInfo, LOC)
53#define InitIndex12GrayLoadVars(PREFIX, pRasInfo) \
54 PREFIX ## Lut = (pRasInfo)->lutBase
55
56#define InitIndex12GrayStoreVarsY(PREFIX, pRasInfo) \
57 PREFIX ## InvGrayLut = (pRasInfo)->invGrayTable;
58
59#define InitIndex12GrayStoreVarsX(PREFIX, pRasInfo)
60#define NextIndex12GrayStoreVarsX(PREFIX)
61#define NextIndex12GrayStoreVarsY(PREFIX)
62
63#define Index12GrayXparLutEntry -1
64#define Index12GrayIsXparLutEntry(pix) (pix < 0)
65#define StoreIndex12GrayNonXparFromArgb StoreIndex12GrayFrom1IntArgb
66
67#define StoreIndex12GrayPixel(pRas, x, pixel) \
68 ((pRas)[x] = (jushort) (pixel))
69
70#define DeclareIndex12GrayPixelData(PREFIX)
71
72#define ExtractIndex12GrayPixelData(PIXEL, PREFIX)
73
74#define StoreIndex12GrayPixelData(pPix, x, pixel, PREFIX) \
75 ((pPix)[x] = (jushort) (pixel))
76
77#define Index12GrayPixelFromArgb(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 LoadIndex12GrayTo1IntRgb(pRas, PREFIX, x, rgb) \
86 (rgb) = PREFIX ## Lut[pRas[x] & 0xfff]
87
88#define LoadIndex12GrayTo1IntArgb(pRas, PREFIX, x, argb) \
89 (argb) = PREFIX ## Lut[pRas[x] & 0xfff]
90
91#define LoadIndex12GrayTo1ByteGray(pRas, PREFIX, x, gray) \
92 (gray) = (jubyte)PREFIX ## Lut[pRas[x] & 0xfff]
93
94#define LoadIndex12GrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
95 r = g = b = (jubyte)PREFIX ## Lut[pRas[x] & 0xfff]
96
97#define LoadIndex12GrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
98 do { \
99 a = 0xff; \
100 LoadIndex12GrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
101 } while (0)
102
103#define StoreIndex12GrayFrom1IntRgb(pRas, PREFIX, x, rgb) \
104 do { \
105 int r, g, b; \
106 ExtractIntDcmComponentsX123(rgb, r, g, b); \
107 StoreIndex12GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
108 } while (0)
109
110#define StoreIndex12GrayFrom1IntArgb(pRas, PREFIX, x, argb) \
111 StoreIndex12GrayFrom1IntRgb(pRas, PREFIX, x, argb)
112
113#define StoreIndex12GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
114 do { \
115 int gray = ComposeByteGrayFrom3ByteRgb(r, g, b); \
116 (pRas)[x] = (jushort) (PREFIX ## InvGrayLut[gray]); \
117 } while (0)
118
119#define StoreIndex12GrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
120 StoreIndex12GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
121
122#define StoreIndex12GrayFrom1ByteGray(pRas, PREFIX, x, gray) \
123 (pRas)[x] = (jushort) (PREFIX ## InvGrayLut[gray]);
124
125#define CopyIndex12GrayToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
126 (pRGB)[i] = PREFIX ## Lut[(pRow)[x] & 0xfff]
127
128
129#define DeclareIndex12GrayAlphaLoadData(PREFIX) \
130 jint *PREFIX ## Lut;
131
132#define InitIndex12GrayAlphaLoadData(PREFIX, pRasInfo) \
133 PREFIX ## Lut = (pRasInfo)->lutBase
134
135#define LoadAlphaFromIndex12GrayFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \
136 COMP_PREFIX ## A = 0xff
137
138#define Postload1ByteGrayFromIndex12Gray(pRas, PREFIX, COMP_PREFIX) \
139 COMP_PREFIX ## G = (jubyte)PREFIX ## Lut[(pRas)[0] & 0xfff]
140
141#define StoreIndex12GrayFrom1ByteGrayComps(pRas, PREFIX, x, COMP_PREFIX) \
142 StoreIndex12GrayFrom1ByteGray(pRas, PREFIX, x, COMP_PREFIX ## G)
143
144#define Index12GrayIsPremultiplied 0
145
146#endif /* Index12Gray_h_Included */
147