1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bmpacc2.cxx,v $
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>
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
)
125 rMask
.GetColorFor8Bit( aColor
, pScanline
+ nX
);
129 // ------------------------------------------------------------------
131 IMPL_FORMAT_SETPIXEL( _8BIT_TC_MASK
)
133 rMask
.SetColorFor8Bit( rBitmapColor
, pScanline
+ nX
);
136 // ------------------------------------------------------------------
138 IMPL_FORMAT_GETPIXEL( _16BIT_TC_MSB_MASK
)
141 rMask
.GetColorFor16BitMSB( aColor
, pScanline
+ ( nX
<< 1UL ) );
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
)
157 rMask
.GetColorFor16BitLSB( aColor
, pScanline
+ ( nX
<< 1UL ) );
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
);
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
);
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
)
217 rMask
.GetColorFor24Bit( aColor
, pScanline
+ nX
* 3L );
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
);
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
);
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
);
287 // ------------------------------------------------------------------
289 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA
)
291 *( pScanline
= pScanline
+ ( nX
<< 2 ) )++ = rBitmapColor
.GetBlue();
292 *pScanline
++ = rBitmapColor
.GetGreen();
293 *pScanline
++ = rBitmapColor
.GetRed();
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
);
310 // ------------------------------------------------------------------
312 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA
)
314 *( pScanline
= pScanline
+ ( nX
<< 2 ) )++ = rBitmapColor
.GetRed();
315 *pScanline
++ = rBitmapColor
.GetGreen();
316 *pScanline
++ = rBitmapColor
.GetBlue();
320 // ------------------------------------------------------------------
322 IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK
)
325 rMask
.GetColorFor32Bit( aColor
, pScanline
+ ( nX
<< 2UL ) );
329 // ------------------------------------------------------------------
331 IMPL_FORMAT_SETPIXEL( _32BIT_TC_MASK
)
333 rMask
.SetColorFor32Bit( rBitmapColor
, pScanline
+ ( nX
<< 2UL ) );