1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_vcl.hxx" 30 #include <vcl/salbtype.hxx> 31 #include <vcl/bmpacc.hxx> 32 33 // ---------------- 34 // - BitmapAccess - 35 // ---------------- 36 37 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_MSB_PAL ) 38 { 39 return( pScanline[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 ); 40 } 41 42 // ------------------------------------------------------------------ 43 44 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_MSB_PAL ) 45 { 46 sal_uInt8& rByte = pScanline[ nX >> 3 ]; 47 48 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( 7 - ( nX & 7 ) ) ) : 49 ( rByte &= ~( 1 << ( 7 - ( nX & 7 ) ) ) ); 50 } 51 52 // ------------------------------------------------------------------ 53 54 IMPL_FORMAT_GETPIXEL_NOMASK( _1BIT_LSB_PAL ) 55 { 56 return( pScanline[ nX >> 3 ] & ( 1 << ( nX & 7 ) ) ? 1 : 0 ); 57 } 58 59 // ------------------------------------------------------------------ 60 61 IMPL_FORMAT_SETPIXEL_NOMASK( _1BIT_LSB_PAL ) 62 { 63 sal_uInt8& rByte = pScanline[ nX >> 3 ]; 64 65 ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( nX & 7 ) ) : 66 ( rByte &= ~( 1 << ( nX & 7 ) ) ); 67 } 68 69 // ------------------------------------------------------------------ 70 71 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_MSN_PAL ) 72 { 73 return( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f ); 74 } 75 76 // ------------------------------------------------------------------ 77 78 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_MSN_PAL ) 79 { 80 sal_uInt8& rByte = pScanline[ nX >> 1 ]; 81 82 ( nX & 1 ) ? ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) ) : 83 ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) ); 84 } 85 86 // ------------------------------------------------------------------ 87 88 IMPL_FORMAT_GETPIXEL_NOMASK( _4BIT_LSN_PAL ) 89 { 90 return( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 4 : 0 ) ) & 0x0f ); 91 } 92 93 // ------------------------------------------------------------------ 94 95 IMPL_FORMAT_SETPIXEL_NOMASK( _4BIT_LSN_PAL ) 96 { 97 sal_uInt8& rByte = pScanline[ nX >> 1 ]; 98 99 ( nX & 1 ) ? ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) ) : 100 ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) ); 101 } 102 103 // ------------------------------------------------------------------ 104 105 IMPL_FORMAT_GETPIXEL_NOMASK( _8BIT_PAL ) 106 { 107 return pScanline[ nX ]; 108 } 109 110 // ------------------------------------------------------------------ 111 112 IMPL_FORMAT_SETPIXEL_NOMASK( _8BIT_PAL ) 113 { 114 pScanline[ nX ] = rBitmapColor.GetIndex(); 115 } 116 117 // ------------------------------------------------------------------ 118 119 IMPL_FORMAT_GETPIXEL( _8BIT_TC_MASK ) 120 { 121 BitmapColor aColor; 122 rMask.GetColorFor8Bit( aColor, pScanline + nX ); 123 return aColor; 124 } 125 126 // ------------------------------------------------------------------ 127 128 IMPL_FORMAT_SETPIXEL( _8BIT_TC_MASK ) 129 { 130 rMask.SetColorFor8Bit( rBitmapColor, pScanline + nX ); 131 } 132 133 // ------------------------------------------------------------------ 134 135 IMPL_FORMAT_GETPIXEL( _16BIT_TC_MSB_MASK ) 136 { 137 BitmapColor aColor; 138 rMask.GetColorFor16BitMSB( aColor, pScanline + ( nX << 1UL ) ); 139 return aColor; 140 } 141 142 // ------------------------------------------------------------------ 143 144 IMPL_FORMAT_SETPIXEL( _16BIT_TC_MSB_MASK ) 145 { 146 rMask.SetColorFor16BitMSB( rBitmapColor, pScanline + ( nX << 1UL ) ); 147 } 148 149 // ------------------------------------------------------------------ 150 151 IMPL_FORMAT_GETPIXEL( _16BIT_TC_LSB_MASK ) 152 { 153 BitmapColor aColor; 154 rMask.GetColorFor16BitLSB( aColor, pScanline + ( nX << 1UL ) ); 155 return aColor; 156 } 157 158 // ------------------------------------------------------------------ 159 160 IMPL_FORMAT_SETPIXEL( _16BIT_TC_LSB_MASK ) 161 { 162 rMask.SetColorFor16BitLSB( rBitmapColor, pScanline + ( nX << 1UL ) ); 163 } 164 165 // ------------------------------------------------------------------ 166 167 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_BGR ) 168 { 169 BitmapColor aBitmapColor; 170 171 aBitmapColor.SetBlue( *( pScanline = pScanline + nX * 3 )++ ); 172 aBitmapColor.SetGreen( *pScanline++ ); 173 aBitmapColor.SetRed( *pScanline ); 174 175 return aBitmapColor; 176 } 177 178 // ------------------------------------------------------------------ 179 180 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_BGR ) 181 { 182 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetBlue(); 183 *pScanline++ = rBitmapColor.GetGreen(); 184 *pScanline = rBitmapColor.GetRed(); 185 } 186 187 // ------------------------------------------------------------------ 188 189 IMPL_FORMAT_GETPIXEL_NOMASK( _24BIT_TC_RGB ) 190 { 191 BitmapColor aBitmapColor; 192 193 aBitmapColor.SetRed( *( pScanline = pScanline + nX * 3 )++ ); 194 aBitmapColor.SetGreen( *pScanline++ ); 195 aBitmapColor.SetBlue( *pScanline ); 196 197 return aBitmapColor; 198 } 199 200 // ------------------------------------------------------------------ 201 202 IMPL_FORMAT_SETPIXEL_NOMASK( _24BIT_TC_RGB ) 203 { 204 *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetRed(); 205 *pScanline++ = rBitmapColor.GetGreen(); 206 *pScanline = rBitmapColor.GetBlue(); 207 } 208 209 // ------------------------------------------------------------------ 210 211 IMPL_FORMAT_GETPIXEL( _24BIT_TC_MASK ) 212 { 213 BitmapColor aColor; 214 rMask.GetColorFor24Bit( aColor, pScanline + nX * 3L ); 215 return aColor; 216 } 217 218 // ------------------------------------------------------------------ 219 220 IMPL_FORMAT_SETPIXEL( _24BIT_TC_MASK ) 221 { 222 rMask.SetColorFor24Bit( rBitmapColor, pScanline + nX * 3L ); 223 } 224 225 // ------------------------------------------------------------------ 226 227 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR ) 228 { 229 BitmapColor aBitmapColor; 230 231 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ ); 232 aBitmapColor.SetGreen( *pScanline++ ); 233 aBitmapColor.SetRed( *pScanline ); 234 235 return aBitmapColor; 236 } 237 238 // ------------------------------------------------------------------ 239 240 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR ) 241 { 242 *( pScanline = pScanline + ( nX << 2 ) )++ = 0; 243 *pScanline++ = rBitmapColor.GetBlue(); 244 *pScanline++ = rBitmapColor.GetGreen(); 245 *pScanline = rBitmapColor.GetRed(); 246 } 247 248 // ------------------------------------------------------------------ 249 250 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB ) 251 { 252 BitmapColor aBitmapColor; 253 254 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ ); 255 aBitmapColor.SetGreen( *pScanline++ ); 256 aBitmapColor.SetBlue( *pScanline ); 257 258 return aBitmapColor; 259 } 260 261 // ------------------------------------------------------------------ 262 263 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB ) 264 { 265 *( pScanline = pScanline + ( nX << 2 ) )++ = 0; 266 *pScanline++ = rBitmapColor.GetRed(); 267 *pScanline++ = rBitmapColor.GetGreen(); 268 *pScanline = rBitmapColor.GetBlue(); 269 } 270 271 // ------------------------------------------------------------------ 272 273 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_BGRA ) 274 { 275 BitmapColor aBitmapColor; 276 277 aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) )++ ); 278 aBitmapColor.SetGreen( *pScanline++ ); 279 aBitmapColor.SetRed( *pScanline ); 280 281 return aBitmapColor; 282 } 283 284 // ------------------------------------------------------------------ 285 286 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA ) 287 { 288 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue(); 289 *pScanline++ = rBitmapColor.GetGreen(); 290 *pScanline++ = rBitmapColor.GetRed(); 291 *pScanline = 0; 292 } 293 294 // ------------------------------------------------------------------ 295 296 IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA ) 297 { 298 BitmapColor aBitmapColor; 299 300 aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) )++ ); 301 aBitmapColor.SetGreen( *pScanline++ ); 302 aBitmapColor.SetBlue( *pScanline ); 303 304 return aBitmapColor; 305 } 306 307 // ------------------------------------------------------------------ 308 309 IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA ) 310 { 311 *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed(); 312 *pScanline++ = rBitmapColor.GetGreen(); 313 *pScanline++ = rBitmapColor.GetBlue(); 314 *pScanline = 0; 315 } 316 317 // ------------------------------------------------------------------ 318 319 IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK ) 320 { 321 BitmapColor aColor; 322 rMask.GetColorFor32Bit( aColor, pScanline + ( nX << 2UL ) ); 323 return aColor; 324 } 325 326 // ------------------------------------------------------------------ 327 328 IMPL_FORMAT_SETPIXEL( _32BIT_TC_MASK ) 329 { 330 rMask.SetColorFor32Bit( rBitmapColor, pScanline + ( nX << 2UL ) ); 331 } 332