update dev300-m58
[ooovba.git] / vcl / source / gdi / bmpacc2.cxx
blob6be4e894a63ce362f9987cac0e1f772f53b27f85
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bmpacc2.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <vcl/salbtype.hxx>
34 #include <vcl/bmpacc.hxx>
36 // ----------------
37 // - BitmapAccess -
38 // ----------------
40 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_MSB_PAL )
42 return( pScanline[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 );
45 // ------------------------------------------------------------------
47 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_MSB_PAL )
49 BYTE& rByte = pScanline[ nX >> 3 ];
51 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( 7 - ( nX & 7 ) ) ) :
52 ( rByte &= ~( 1 << ( 7 - ( nX & 7 ) ) ) );
55 // ------------------------------------------------------------------
57 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_LSB_PAL )
59 return( pScanline[ nX >> 3 ] & ( 1 << ( nX & 7 ) ) ? 1 : 0 );
62 // ------------------------------------------------------------------
64 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_LSB_PAL )
66 BYTE& rByte = pScanline[ nX >> 3 ];
68 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( nX & 7 ) ) :
69 ( rByte &= ~( 1 << ( nX & 7 ) ) );
72 // ------------------------------------------------------------------
74 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_MSN_PAL )
76 return( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f );
79 // ------------------------------------------------------------------
81 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_MSN_PAL )
83 BYTE& rByte = pScanline[ nX >> 1 ];
85 ( nX & 1 ) ? ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) ) :
86 ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) );
89 // ------------------------------------------------------------------
91 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_LSN_PAL )
93 return( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 4 : 0 ) ) & 0x0f );
96 // ------------------------------------------------------------------
98 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_LSN_PAL )
100 BYTE& rByte = pScanline[ nX >> 1 ];
102 ( nX & 1 ) ? ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) ) :
103 ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) );
106 // ------------------------------------------------------------------
108 IMPL_FORMAT_GETPIXEL_NOMASK( _8BIT_PAL )
110 return pScanline[ nX ];
113 // ------------------------------------------------------------------
115 IMPL_FORMAT_SETPIXEL_NOMASK( _8BIT_PAL )
117 pScanline[ nX ] = rBitmapColor.GetIndex();
120 // ------------------------------------------------------------------
122 IMPL_FORMAT_GETPIXEL( _8BIT_TC_MASK )
124 BitmapColor aColor;
125 rMask.GetColorFor8Bit( aColor, pScanline + nX );
126 return aColor;
129 // ------------------------------------------------------------------
131 IMPL_FORMAT_SETPIXEL( _8BIT_TC_MASK )
133 rMask.SetColorFor8Bit( rBitmapColor, pScanline + nX );
136 // ------------------------------------------------------------------
138 IMPL_FORMAT_GETPIXEL( _16BIT_TC_MSB_MASK )
140 BitmapColor aColor;
141 rMask.GetColorFor16BitMSB( aColor, pScanline + ( nX << 1UL ) );
142 return aColor;
145 // ------------------------------------------------------------------
147 IMPL_FORMAT_SETPIXEL( _16BIT_TC_MSB_MASK )
149 rMask.SetColorFor16BitMSB( rBitmapColor, pScanline + ( nX << 1UL ) );
152 // ------------------------------------------------------------------
154 IMPL_FORMAT_GETPIXEL( _16BIT_TC_LSB_MASK )
156 BitmapColor aColor;
157 rMask.GetColorFor16BitLSB( aColor, pScanline + ( nX << 1UL ) );
158 return aColor;
161 // ------------------------------------------------------------------
163 IMPL_FORMAT_SETPIXEL( _16BIT_TC_LSB_MASK )
165 rMask.SetColorFor16BitLSB( rBitmapColor, pScanline + ( nX << 1UL ) );
168 // ------------------------------------------------------------------
170 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_BGR )
172 BitmapColor aBitmapColor;
174 aBitmapColor.SetBlue( *( pScanline = pScanline + nX * 3 )++ );
175 aBitmapColor.SetGreen( *pScanline++ );
176 aBitmapColor.SetRed( *pScanline );
178 return aBitmapColor;
181 // ------------------------------------------------------------------
183 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_BGR )
185 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetBlue();
186 *pScanline++ = rBitmapColor.GetGreen();
187 *pScanline = rBitmapColor.GetRed();
190 // ------------------------------------------------------------------
192 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_RGB )
194 BitmapColor aBitmapColor;
196 aBitmapColor.SetRed( *( pScanline = pScanline + nX * 3 )++ );
197 aBitmapColor.SetGreen( *pScanline++ );
198 aBitmapColor.SetBlue( *pScanline );
200 return aBitmapColor;
203 // ------------------------------------------------------------------
205 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_RGB )
207 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetRed();
208 *pScanline++ = rBitmapColor.GetGreen();
209 *pScanline = rBitmapColor.GetBlue();
212 // ------------------------------------------------------------------
214 IMPL_FORMAT_GETPIXEL( _24BIT_TC_MASK )
216 BitmapColor aColor;
217 rMask.GetColorFor24Bit( aColor, pScanline + nX * 3L );
218 return aColor;
221 // ------------------------------------------------------------------
223 IMPL_FORMAT_SETPIXEL( _24BIT_TC_MASK )
225 rMask.SetColorFor24Bit( rBitmapColor, pScanline + nX * 3L );
228 // ------------------------------------------------------------------
230 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR )
232 BitmapColor aBitmapColor;
234 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
235 aBitmapColor.SetGreen( *pScanline++ );
236 aBitmapColor.SetRed( *pScanline );
238 return aBitmapColor;
241 // ------------------------------------------------------------------
243 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
245 *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
246 *pScanline++ = rBitmapColor.GetBlue();
247 *pScanline++ = rBitmapColor.GetGreen();
248 *pScanline = rBitmapColor.GetRed();
251 // ------------------------------------------------------------------
253 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB )
255 BitmapColor aBitmapColor;
257 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
258 aBitmapColor.SetGreen( *pScanline++ );
259 aBitmapColor.SetBlue( *pScanline );
261 return aBitmapColor;
264 // ------------------------------------------------------------------
266 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
268 *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
269 *pScanline++ = rBitmapColor.GetRed();
270 *pScanline++ = rBitmapColor.GetGreen();
271 *pScanline = rBitmapColor.GetBlue();
274 // ------------------------------------------------------------------
276 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_BGRA )
278 BitmapColor aBitmapColor;
280 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) )++ );
281 aBitmapColor.SetGreen( *pScanline++ );
282 aBitmapColor.SetRed( *pScanline );
284 return aBitmapColor;
287 // ------------------------------------------------------------------
289 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA )
291 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
292 *pScanline++ = rBitmapColor.GetGreen();
293 *pScanline++ = rBitmapColor.GetRed();
294 *pScanline = 0;
297 // ------------------------------------------------------------------
299 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
301 BitmapColor aBitmapColor;
303 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) )++ );
304 aBitmapColor.SetGreen( *pScanline++ );
305 aBitmapColor.SetBlue( *pScanline );
307 return aBitmapColor;
310 // ------------------------------------------------------------------
312 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA )
314 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
315 *pScanline++ = rBitmapColor.GetGreen();
316 *pScanline++ = rBitmapColor.GetBlue();
317 *pScanline = 0;
320 // ------------------------------------------------------------------
322 IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
324 BitmapColor aColor;
325 rMask.GetColorFor32Bit( aColor, pScanline + ( nX << 2UL ) );
326 return aColor;
329 // ------------------------------------------------------------------
331 IMPL_FORMAT_SETPIXEL( _32BIT_TC_MASK )
333 rMask.SetColorFor32Bit( rBitmapColor, pScanline + ( nX << 2UL ) );