1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 #include <vcl/salbtype.hxx>
27 #include <vcl/bmpacc.hxx>
28
29 // ----------------
30 // - BitmapAccess -
31 // ----------------
32
IMPL_FORMAT_GETPIXEL_NOMASK(_1BIT_MSB_PAL)33 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_MSB_PAL )
34 {
35 return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 );
36 }
37
38 // ------------------------------------------------------------------
39
IMPL_FORMAT_SETPIXEL_NOMASK(_1BIT_MSB_PAL)40 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_MSB_PAL )
41 {
42 sal_uInt8& rByte = pScanline[ nX >> 3 ];
43
44 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( 7 - ( nX & 7 ) ) ) :
45 ( rByte &= ~( 1 << ( 7 - ( nX & 7 ) ) ) );
46 }
47
48 // ------------------------------------------------------------------
49
IMPL_FORMAT_GETPIXEL_NOMASK(_1BIT_LSB_PAL)50 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_LSB_PAL )
51 {
52 return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( nX & 7 ) ) ? 1 : 0 );
53 }
54
55 // ------------------------------------------------------------------
56
IMPL_FORMAT_SETPIXEL_NOMASK(_1BIT_LSB_PAL)57 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_LSB_PAL )
58 {
59 sal_uInt8& rByte = pScanline[ nX >> 3 ];
60
61 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( nX & 7 ) ) :
62 ( rByte &= ~( 1 << ( nX & 7 ) ) );
63 }
64
65 // ------------------------------------------------------------------
66
IMPL_FORMAT_GETPIXEL_NOMASK(_4BIT_MSN_PAL)67 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_MSN_PAL )
68 {
69 return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f );
70 }
71
72 // ------------------------------------------------------------------
73
IMPL_FORMAT_SETPIXEL_NOMASK(_4BIT_MSN_PAL)74 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_MSN_PAL )
75 {
76 sal_uInt8& rByte = pScanline[ nX >> 1 ];
77
78 ( nX & 1 ) ? ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) ) :
79 ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) );
80 }
81
82 // ------------------------------------------------------------------
83
IMPL_FORMAT_GETPIXEL_NOMASK(_4BIT_LSN_PAL)84 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_LSN_PAL )
85 {
86 return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 4 : 0 ) ) & 0x0f );
87 }
88
89 // ------------------------------------------------------------------
90
IMPL_FORMAT_SETPIXEL_NOMASK(_4BIT_LSN_PAL)91 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_LSN_PAL )
92 {
93 sal_uInt8& rByte = pScanline[ nX >> 1 ];
94
95 ( nX & 1 ) ? ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) ) :
96 ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) );
97 }
98
99 // ------------------------------------------------------------------
100
IMPL_FORMAT_GETPIXEL_NOMASK(_8BIT_PAL)101 IMPL_FORMAT_GETPIXEL_NOMASK( _8BIT_PAL )
102 {
103 return BitmapColor( pScanline[ nX ] );
104 }
105
106 // ------------------------------------------------------------------
107
IMPL_FORMAT_SETPIXEL_NOMASK(_8BIT_PAL)108 IMPL_FORMAT_SETPIXEL_NOMASK( _8BIT_PAL )
109 {
110 pScanline[ nX ] = rBitmapColor.GetIndex();
111 }
112
113 // ------------------------------------------------------------------
114
IMPL_FORMAT_GETPIXEL(_8BIT_TC_MASK)115 IMPL_FORMAT_GETPIXEL( _8BIT_TC_MASK )
116 {
117 BitmapColor aColor;
118 rMask.GetColorFor8Bit( aColor, pScanline + nX );
119 return aColor;
120 }
121
122 // ------------------------------------------------------------------
123
IMPL_FORMAT_SETPIXEL(_8BIT_TC_MASK)124 IMPL_FORMAT_SETPIXEL( _8BIT_TC_MASK )
125 {
126 rMask.SetColorFor8Bit( rBitmapColor, pScanline + nX );
127 }
128
129 // ------------------------------------------------------------------
130
IMPL_FORMAT_GETPIXEL(_16BIT_TC_MSB_MASK)131 IMPL_FORMAT_GETPIXEL( _16BIT_TC_MSB_MASK )
132 {
133 BitmapColor aColor;
134 rMask.GetColorFor16BitMSB( aColor, pScanline + ( nX << 1UL ) );
135 return aColor;
136 }
137
138 // ------------------------------------------------------------------
139
IMPL_FORMAT_SETPIXEL(_16BIT_TC_MSB_MASK)140 IMPL_FORMAT_SETPIXEL( _16BIT_TC_MSB_MASK )
141 {
142 rMask.SetColorFor16BitMSB( rBitmapColor, pScanline + ( nX << 1UL ) );
143 }
144
145 // ------------------------------------------------------------------
146
IMPL_FORMAT_GETPIXEL(_16BIT_TC_LSB_MASK)147 IMPL_FORMAT_GETPIXEL( _16BIT_TC_LSB_MASK )
148 {
149 BitmapColor aColor;
150 rMask.GetColorFor16BitLSB( aColor, pScanline + ( nX << 1UL ) );
151 return aColor;
152 }
153
154 // ------------------------------------------------------------------
155
IMPL_FORMAT_SETPIXEL(_16BIT_TC_LSB_MASK)156 IMPL_FORMAT_SETPIXEL( _16BIT_TC_LSB_MASK )
157 {
158 rMask.SetColorFor16BitLSB( rBitmapColor, pScanline + ( nX << 1UL ) );
159 }
160
161 // ------------------------------------------------------------------
162
IMPL_FORMAT_GETPIXEL_NOMASK(_24BIT_TC_BGR)163 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_BGR )
164 {
165 BitmapColor aBitmapColor;
166
167 aBitmapColor.SetBlue( *( pScanline = pScanline + nX * 3 )++ );
168 aBitmapColor.SetGreen( *pScanline++ );
169 aBitmapColor.SetRed( *pScanline );
170
171 return aBitmapColor;
172 }
173
174 // ------------------------------------------------------------------
175
IMPL_FORMAT_SETPIXEL_NOMASK(_24BIT_TC_BGR)176 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_BGR )
177 {
178 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetBlue();
179 *pScanline++ = rBitmapColor.GetGreen();
180 *pScanline = rBitmapColor.GetRed();
181 }
182
183 // ------------------------------------------------------------------
184
IMPL_FORMAT_GETPIXEL_NOMASK(_24BIT_TC_RGB)185 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_RGB )
186 {
187 BitmapColor aBitmapColor;
188
189 aBitmapColor.SetRed( *( pScanline = pScanline + nX * 3 )++ );
190 aBitmapColor.SetGreen( *pScanline++ );
191 aBitmapColor.SetBlue( *pScanline );
192
193 return aBitmapColor;
194 }
195
196 // ------------------------------------------------------------------
197
IMPL_FORMAT_SETPIXEL_NOMASK(_24BIT_TC_RGB)198 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_RGB )
199 {
200 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetRed();
201 *pScanline++ = rBitmapColor.GetGreen();
202 *pScanline = rBitmapColor.GetBlue();
203 }
204
205 // ------------------------------------------------------------------
206
IMPL_FORMAT_GETPIXEL(_24BIT_TC_MASK)207 IMPL_FORMAT_GETPIXEL( _24BIT_TC_MASK )
208 {
209 BitmapColor aColor;
210 rMask.GetColorFor24Bit( aColor, pScanline + nX * 3L );
211 return aColor;
212 }
213
214 // ------------------------------------------------------------------
215
IMPL_FORMAT_SETPIXEL(_24BIT_TC_MASK)216 IMPL_FORMAT_SETPIXEL( _24BIT_TC_MASK )
217 {
218 rMask.SetColorFor24Bit( rBitmapColor, pScanline + nX * 3L );
219 }
220
221 // ------------------------------------------------------------------
222
IMPL_FORMAT_GETPIXEL_NOMASK(_32BIT_TC_ABGR)223 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR )
224 {
225 BitmapColor aBitmapColor;
226
227 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
228 aBitmapColor.SetGreen( *pScanline++ );
229 aBitmapColor.SetRed( *pScanline );
230
231 return aBitmapColor;
232 }
233
234 // ------------------------------------------------------------------
235
IMPL_FORMAT_SETPIXEL_NOMASK(_32BIT_TC_ABGR)236 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
237 {
238 *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
239 *pScanline++ = rBitmapColor.GetBlue();
240 *pScanline++ = rBitmapColor.GetGreen();
241 *pScanline = rBitmapColor.GetRed();
242 }
243
244 // ------------------------------------------------------------------
245
IMPL_FORMAT_GETPIXEL_NOMASK(_32BIT_TC_ARGB)246 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB )
247 {
248 BitmapColor aBitmapColor;
249
250 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
251 aBitmapColor.SetGreen( *pScanline++ );
252 aBitmapColor.SetBlue( *pScanline );
253
254 return aBitmapColor;
255 }
256
257 // ------------------------------------------------------------------
258
IMPL_FORMAT_SETPIXEL_NOMASK(_32BIT_TC_ARGB)259 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
260 {
261 *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
262 *pScanline++ = rBitmapColor.GetRed();
263 *pScanline++ = rBitmapColor.GetGreen();
264 *pScanline = rBitmapColor.GetBlue();
265 }
266
267 // ------------------------------------------------------------------
268
IMPL_FORMAT_GETPIXEL_NOMASK(_32BIT_TC_BGRA)269 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_BGRA )
270 {
271 BitmapColor aBitmapColor;
272
273 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) )++ );
274 aBitmapColor.SetGreen( *pScanline++ );
275 aBitmapColor.SetRed( *pScanline );
276
277 return aBitmapColor;
278 }
279
280 // ------------------------------------------------------------------
281
IMPL_FORMAT_SETPIXEL_NOMASK(_32BIT_TC_BGRA)282 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA )
283 {
284 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
285 *pScanline++ = rBitmapColor.GetGreen();
286 *pScanline++ = rBitmapColor.GetRed();
287 *pScanline = 0;
288 }
289
290 // ------------------------------------------------------------------
291
IMPL_FORMAT_GETPIXEL_NOMASK(_32BIT_TC_RGBA)292 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
293 {
294 BitmapColor aBitmapColor;
295
296 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) )++ );
297 aBitmapColor.SetGreen( *pScanline++ );
298 aBitmapColor.SetBlue( *pScanline );
299
300 return aBitmapColor;
301 }
302
303 // ------------------------------------------------------------------
304
IMPL_FORMAT_SETPIXEL_NOMASK(_32BIT_TC_RGBA)305 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA )
306 {
307 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
308 *pScanline++ = rBitmapColor.GetGreen();
309 *pScanline++ = rBitmapColor.GetBlue();
310 *pScanline = 0;
311 }
312
313 // ------------------------------------------------------------------
314
IMPL_FORMAT_GETPIXEL(_32BIT_TC_MASK)315 IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
316 {
317 BitmapColor aColor;
318 rMask.GetColorFor32Bit( aColor, pScanline + ( nX << 2UL ) );
319 return aColor;
320 }
321
322 // ------------------------------------------------------------------
323
IMPL_FORMAT_SETPIXEL(_32BIT_TC_MASK)324 IMPL_FORMAT_SETPIXEL( _32BIT_TC_MASK )
325 {
326 rMask.SetColorFor32Bit( rBitmapColor, pScanline + ( nX << 2UL ) );
327 }
328