update credits
[LibreOffice.git] / vcl / source / gdi / bmpacc2.cxx
blobbf1d54037b6ba0067103fdeadf45e748a4d091e3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vcl/salbtype.hxx>
21 #include <vcl/bmpacc.hxx>
23 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_MSB_PAL )
25 return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 );
28 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_MSB_PAL )
30 sal_uInt8& rByte = pScanline[ nX >> 3 ];
32 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( 7 - ( nX & 7 ) ) ) :
33 ( rByte &= ~( 1 << ( 7 - ( nX & 7 ) ) ) );
36 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_LSB_PAL )
38 return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( nX & 7 ) ) ? 1 : 0 );
41 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_LSB_PAL )
43 sal_uInt8& rByte = pScanline[ nX >> 3 ];
45 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( nX & 7 ) ) :
46 ( rByte &= ~( 1 << ( nX & 7 ) ) );
49 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_MSN_PAL )
51 return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f );
54 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_MSN_PAL )
56 sal_uInt8& rByte = pScanline[ nX >> 1 ];
58 ( nX & 1 ) ? ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) ) :
59 ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) );
62 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_LSN_PAL )
64 return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 4 : 0 ) ) & 0x0f );
67 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_LSN_PAL )
69 sal_uInt8& rByte = pScanline[ nX >> 1 ];
71 ( nX & 1 ) ? ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) ) :
72 ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) );
75 IMPL_FORMAT_GETPIXEL_NOMASK( _8BIT_PAL )
77 return BitmapColor( pScanline[ nX ] );
80 IMPL_FORMAT_SETPIXEL_NOMASK( _8BIT_PAL )
82 pScanline[ nX ] = rBitmapColor.GetIndex();
85 IMPL_FORMAT_GETPIXEL( _8BIT_TC_MASK )
87 BitmapColor aColor;
88 rMask.GetColorFor8Bit( aColor, pScanline + nX );
89 return aColor;
92 IMPL_FORMAT_SETPIXEL( _8BIT_TC_MASK )
94 rMask.SetColorFor8Bit( rBitmapColor, pScanline + nX );
97 IMPL_FORMAT_GETPIXEL( _16BIT_TC_MSB_MASK )
99 BitmapColor aColor;
100 rMask.GetColorFor16BitMSB( aColor, pScanline + ( nX << 1UL ) );
101 return aColor;
104 IMPL_FORMAT_SETPIXEL( _16BIT_TC_MSB_MASK )
106 rMask.SetColorFor16BitMSB( rBitmapColor, pScanline + ( nX << 1UL ) );
109 IMPL_FORMAT_GETPIXEL( _16BIT_TC_LSB_MASK )
111 BitmapColor aColor;
112 rMask.GetColorFor16BitLSB( aColor, pScanline + ( nX << 1UL ) );
113 return aColor;
116 IMPL_FORMAT_SETPIXEL( _16BIT_TC_LSB_MASK )
118 rMask.SetColorFor16BitLSB( rBitmapColor, pScanline + ( nX << 1UL ) );
121 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_BGR )
123 BitmapColor aBitmapColor;
125 aBitmapColor.SetBlue( *( pScanline = pScanline + nX * 3 )++ );
126 aBitmapColor.SetGreen( *pScanline++ );
127 aBitmapColor.SetRed( *pScanline );
129 return aBitmapColor;
132 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_BGR )
134 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetBlue();
135 *pScanline++ = rBitmapColor.GetGreen();
136 *pScanline = rBitmapColor.GetRed();
139 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_RGB )
141 BitmapColor aBitmapColor;
143 aBitmapColor.SetRed( *( pScanline = pScanline + nX * 3 )++ );
144 aBitmapColor.SetGreen( *pScanline++ );
145 aBitmapColor.SetBlue( *pScanline );
147 return aBitmapColor;
150 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_RGB )
152 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetRed();
153 *pScanline++ = rBitmapColor.GetGreen();
154 *pScanline = rBitmapColor.GetBlue();
157 IMPL_FORMAT_GETPIXEL( _24BIT_TC_MASK )
159 BitmapColor aColor;
160 rMask.GetColorFor24Bit( aColor, pScanline + nX * 3L );
161 return aColor;
164 IMPL_FORMAT_SETPIXEL( _24BIT_TC_MASK )
166 rMask.SetColorFor24Bit( rBitmapColor, pScanline + nX * 3L );
169 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR )
171 BitmapColor aBitmapColor;
173 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
174 aBitmapColor.SetGreen( *pScanline++ );
175 aBitmapColor.SetRed( *pScanline );
177 return aBitmapColor;
180 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
182 *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
183 *pScanline++ = rBitmapColor.GetBlue();
184 *pScanline++ = rBitmapColor.GetGreen();
185 *pScanline = rBitmapColor.GetRed();
188 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB )
190 BitmapColor aBitmapColor;
192 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
193 aBitmapColor.SetGreen( *pScanline++ );
194 aBitmapColor.SetBlue( *pScanline );
196 return aBitmapColor;
199 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
201 *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
202 *pScanline++ = rBitmapColor.GetRed();
203 *pScanline++ = rBitmapColor.GetGreen();
204 *pScanline = rBitmapColor.GetBlue();
207 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_BGRA )
209 BitmapColor aBitmapColor;
211 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) )++ );
212 aBitmapColor.SetGreen( *pScanline++ );
213 aBitmapColor.SetRed( *pScanline );
215 return aBitmapColor;
218 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA )
220 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
221 *pScanline++ = rBitmapColor.GetGreen();
222 *pScanline++ = rBitmapColor.GetRed();
223 *pScanline = 0;
226 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
228 BitmapColor aBitmapColor;
230 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) )++ );
231 aBitmapColor.SetGreen( *pScanline++ );
232 aBitmapColor.SetBlue( *pScanline );
234 return aBitmapColor;
237 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA )
239 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
240 *pScanline++ = rBitmapColor.GetGreen();
241 *pScanline++ = rBitmapColor.GetBlue();
242 *pScanline = 0;
245 IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
247 BitmapColor aColor;
248 rMask.GetColorFor32Bit( aColor, pScanline + ( nX << 2UL ) );
249 return aColor;
252 IMPL_FORMAT_SETPIXEL( _32BIT_TC_MASK )
254 rMask.SetColorFor32Bit( rBitmapColor, pScanline + ( nX << 2UL ) );
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */