1/*
2 * Copyright (c) 2000, 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 ByteGray_h_Included
27#define ByteGray_h_Included
28
29#include "IntDcm.h"
30
31/*
32 * This file contains macro and type definitions used by the macros in
33 * LoopMacros.h to manipulate a surface of type "ByteGray".
34 */
35
36typedef jubyte ByteGrayPixelType;
37typedef jubyte ByteGrayDataType;
38
39#define ByteGrayIsOpaque 1
40
41#define ByteGrayPixelStride 1
42#define ByteGrayBitsPerPixel 8
43
44#define DeclareByteGrayLoadVars(PREFIX)
45#define DeclareByteGrayStoreVars(PREFIX)
46#define SetByteGrayStoreVarsYPos(PREFIX, pRasInfo, y)
47#define SetByteGrayStoreVarsXPos(PREFIX, pRasInfo, x)
48#define InitByteGrayLoadVars(PREFIX, pRasInfo)
49#define InitByteGrayStoreVarsY(PREFIX, pRasInfo)
50#define InitByteGrayStoreVarsX(PREFIX, pRasInfo)
51#define NextByteGrayStoreVarsX(PREFIX)
52#define NextByteGrayStoreVarsY(PREFIX)
53#define DeclareByteGrayPixelData(PREFIX)
54#define ExtractByteGrayPixelData(PIXEL, PREFIX)
55
56#define ByteGrayXparLutEntry -1
57#define ByteGrayIsXparLutEntry(pix) (pix < 0)
58#define StoreByteGrayNonXparFromArgb StoreByteGrayFrom1IntArgb
59
60
61#define ComposeByteGrayFrom3ByteRgb(r, g, b) \
62 (ByteGrayDataType)(((77*(r)) + (150*(g)) + (29*(b)) + 128) / 256)
63
64
65#define StoreByteGrayPixel(pRas, x, pixel) \
66 ((pRas)[x] = (jubyte) (pixel))
67
68#define StoreByteGrayPixelData(pPix, x, pixel, PREFIX) \
69 StoreByteGrayPixel(pPix, x, pixel)
70
71#define ByteGrayPixelFromArgb(pixel, rgb, pRasInfo) \
72 do { \
73 jint r, g, b; \
74 ExtractIntDcmComponentsX123(rgb, r, g, b); \
75 (pixel) = ComposeByteGrayFrom3ByteRgb(r, g, b); \
76 } while (0)
77
78
79#define LoadByteGrayTo1IntRgb(pRas, PREFIX, x, rgb) \
80 do { \
81 int gray = (pRas)[x]; \
82 (rgb) = (((gray << 8) | gray) << 8) | gray; \
83 } while (0)
84
85#define LoadByteGrayTo1IntArgb(pRas, PREFIX, x, argb) \
86 do { \
87 int gray = (pRas)[x]; \
88 (argb) = (((((0xff << 8) | gray) << 8) | gray) << 8) | gray; \
89 } while (0)
90
91#define LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
92 ((r) = (g) = (b) = (pRas)[x])
93
94#define LoadByteGrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
95 do { \
96 LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
97 (a) = 0xff; \
98 } while (0)
99
100#define LoadByteGrayTo1ByteGray(pRas, PREFIX, x, gray) \
101 (gray) = (pRas)[x]
102
103#define StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, rgb) \
104 do { \
105 int r, g, b; \
106 ExtractIntDcmComponentsX123(rgb, r, g, b); \
107 StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
108 } while (0)
109
110#define StoreByteGrayFrom1IntArgb(pRas, PREFIX, x, argb) \
111 StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, argb)
112
113#define StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
114 (pRas)[x] = ComposeByteGrayFrom3ByteRgb(r, g, b)
115
116#define StoreByteGrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
117 StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
118
119#define StoreByteGrayFrom1ByteGray(pRas, PREFIX, x, gray) \
120 StoreByteGrayPixel(pRas, x, gray)
121
122#define CopyByteGrayToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
123 LoadByteGrayTo1IntArgb(pRow, PREFIX, x, pRGB[i])
124
125
126#define DeclareByteGrayAlphaLoadData(PREFIX)
127#define InitByteGrayAlphaLoadData(PREFIX, pRasInfo)
128
129#define LoadAlphaFromByteGrayFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \
130 COMP_PREFIX ## A = 0xff
131
132#define Postload1ByteGrayFromByteGray(pRas, PREFIX, COMP_PREFIX) \
133 COMP_PREFIX ## G = pRas[0]
134
135
136#define ByteGrayIsPremultiplied 0
137
138#define DeclareByteGrayBlendFillVars(PREFIX) \
139 jubyte PREFIX;
140
141#define ClearByteGrayBlendFillVars(PREFIX, argb) \
142 PREFIX = 0
143
144#define InitByteGrayBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
145 PREFIX = (jubyte) COMP_PREFIX ## G
146
147#define InitByteGrayBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
148
149#define StoreByteGrayBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
150 (pRas)[x] = PREFIX
151
152#define StoreByteGrayFrom1ByteGrayComps(pRas, PREFIX, x, COMP_PREFIX) \
153 StoreByteGrayPixel(pRas, x, COMP_PREFIX ## G)
154
155#endif /* ByteGray_h_Included */
156