blob: 335a47b7a89ccf0ead6ba0774a801b7c35911444 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2004 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any 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 ByteGrayPixelStride 1
40#define ByteGrayBitsPerPixel 8
41
42#define DeclareByteGrayLoadVars(PREFIX)
43#define DeclareByteGrayStoreVars(PREFIX)
44#define SetByteGrayStoreVarsYPos(PREFIX, pRasInfo, y)
45#define SetByteGrayStoreVarsXPos(PREFIX, pRasInfo, x)
46#define InitByteGrayLoadVars(PREFIX, pRasInfo)
47#define InitByteGrayStoreVarsY(PREFIX, pRasInfo)
48#define InitByteGrayStoreVarsX(PREFIX, pRasInfo)
49#define NextByteGrayStoreVarsX(PREFIX)
50#define NextByteGrayStoreVarsY(PREFIX)
51#define DeclareByteGrayPixelData(PREFIX)
52#define ExtractByteGrayPixelData(PIXEL, PREFIX)
53
54#define ByteGrayXparLutEntry -1
55#define ByteGrayIsXparLutEntry(pix) (pix < 0)
56#define StoreByteGrayNonXparFromArgb StoreByteGrayFrom1IntArgb
57
58
59#define ComposeByteGrayFrom3ByteRgb(r, g, b) \
60 (ByteGrayDataType)(((77*(r)) + (150*(g)) + (29*(b)) + 128) / 256)
61
62
63#define StoreByteGrayPixel(pRas, x, pixel) \
64 ((pRas)[x] = (jubyte) (pixel))
65
66#define StoreByteGrayPixelData(pPix, x, pixel, PREFIX) \
67 StoreByteGrayPixel(pPix, x, pixel)
68
69#define ByteGrayPixelFromArgb(pixel, rgb, pRasInfo) \
70 do { \
71 jint r, g, b; \
72 ExtractIntDcmComponentsX123(rgb, r, g, b); \
73 (pixel) = ComposeByteGrayFrom3ByteRgb(r, g, b); \
74 } while (0)
75
76
77#define LoadByteGrayTo1IntRgb(pRas, PREFIX, x, rgb) \
78 do { \
79 int gray = (pRas)[x]; \
80 (rgb) = (((gray << 8) | gray) << 8) | gray; \
81 } while (0)
82
83#define LoadByteGrayTo1IntArgb(pRas, PREFIX, x, argb) \
84 do { \
85 int gray = (pRas)[x]; \
86 (argb) = (((((0xff << 8) | gray) << 8) | gray) << 8) | gray; \
87 } while (0)
88
89#define LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
90 ((r) = (g) = (b) = (pRas)[x])
91
92#define LoadByteGrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
93 do { \
94 LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
95 (a) = 0xff; \
96 } while (0)
97
98#define LoadByteGrayTo1ByteGray(pRas, PREFIX, x, gray) \
99 (gray) = (pRas)[x]
100
101#define StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, rgb) \
102 do { \
103 int r, g, b; \
104 ExtractIntDcmComponentsX123(rgb, r, g, b); \
105 StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
106 } while (0)
107
108#define StoreByteGrayFrom1IntArgb(pRas, PREFIX, x, argb) \
109 StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, argb)
110
111#define StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
112 (pRas)[x] = ComposeByteGrayFrom3ByteRgb(r, g, b)
113
114#define StoreByteGrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
115 StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
116
117#define StoreByteGrayFrom1ByteGray(pRas, PREFIX, x, gray) \
118 StoreByteGrayPixel(pRas, x, gray)
119
120#define CopyByteGrayToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
121 LoadByteGrayTo1IntArgb(pRow, PREFIX, x, pRGB[i])
122
123
124#define DeclareByteGrayAlphaLoadData(PREFIX)
125#define InitByteGrayAlphaLoadData(PREFIX, pRasInfo)
126
127#define LoadAlphaFromByteGrayFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \
128 COMP_PREFIX ## A = 0xff
129
130#define Postload1ByteGrayFromByteGray(pRas, PREFIX, COMP_PREFIX) \
131 COMP_PREFIX ## G = pRas[0]
132
133
134#define ByteGrayIsPremultiplied 0
135
136#define DeclareByteGrayBlendFillVars(PREFIX) \
137 jubyte PREFIX;
138
139#define ClearByteGrayBlendFillVars(PREFIX, argb) \
140 PREFIX = 0
141
142#define InitByteGrayBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
143 PREFIX = (jubyte) COMP_PREFIX ## G
144
145#define InitByteGrayBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
146
147#define StoreByteGrayBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
148 (pRas)[x] = PREFIX
149
150#define StoreByteGrayFrom1ByteGrayComps(pRas, PREFIX, x, COMP_PREFIX) \
151 StoreByteGrayPixel(pRas, x, COMP_PREFIX ## G)
152
153#endif /* ByteGray_h_Included */