Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <vcl/salbtype.hxx>
21 : #include <vcl/bmpacc.hxx>
22 :
23 9310339 : BitmapColor BitmapReadAccess::GetPixelFor_1BIT_MSB_PAL(ConstScanline pScanline, long nX, const ColorMask&)
24 : {
25 9310339 : return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( 7 - ( nX & 7 ) ) ) ? 1 : 0 );
26 : }
27 :
28 15921981 : void BitmapReadAccess::SetPixelFor_1BIT_MSB_PAL(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
29 : {
30 15921981 : sal_uInt8& rByte = pScanline[ nX >> 3 ];
31 :
32 19828528 : ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( 7 - ( nX & 7 ) ) ) :
33 19828528 : ( rByte &= ~( 1 << ( 7 - ( nX & 7 ) ) ) );
34 15921981 : }
35 :
36 0 : BitmapColor BitmapReadAccess::GetPixelFor_1BIT_LSB_PAL(ConstScanline pScanline, long nX, const ColorMask&)
37 : {
38 0 : return BitmapColor( pScanline[ nX >> 3 ] & ( 1 << ( nX & 7 ) ) ? 1 : 0 );
39 : }
40 :
41 0 : void BitmapReadAccess::SetPixelFor_1BIT_LSB_PAL(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
42 : {
43 0 : sal_uInt8& rByte = pScanline[ nX >> 3 ];
44 :
45 0 : ( rBitmapColor.GetIndex() & 1 ) ? ( rByte |= 1 << ( nX & 7 ) ) :
46 0 : ( rByte &= ~( 1 << ( nX & 7 ) ) );
47 0 : }
48 :
49 1054533 : BitmapColor BitmapReadAccess::GetPixelFor_4BIT_MSN_PAL(ConstScanline pScanline, long nX, const ColorMask&)
50 : {
51 1054533 : return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 0 : 4 ) ) & 0x0f );
52 : }
53 :
54 835836 : void BitmapReadAccess::SetPixelFor_4BIT_MSN_PAL(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
55 : {
56 835836 : sal_uInt8& rByte = pScanline[ nX >> 1 ];
57 :
58 1253233 : ( nX & 1 ) ? ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) ) :
59 1253233 : ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) );
60 835836 : }
61 :
62 0 : BitmapColor BitmapReadAccess::GetPixelFor_4BIT_LSN_PAL(ConstScanline pScanline, long nX, const ColorMask&)
63 : {
64 0 : return BitmapColor( ( pScanline[ nX >> 1 ] >> ( nX & 1 ? 4 : 0 ) ) & 0x0f );
65 : }
66 :
67 0 : void BitmapReadAccess::SetPixelFor_4BIT_LSN_PAL(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
68 : {
69 0 : sal_uInt8& rByte = pScanline[ nX >> 1 ];
70 :
71 0 : ( nX & 1 ) ? ( rByte &= 0x0f, rByte |= ( rBitmapColor.GetIndex() << 4 ) ) :
72 0 : ( rByte &= 0xf0, rByte |= ( rBitmapColor.GetIndex() & 0x0f ) );
73 0 : }
74 :
75 366487602 : BitmapColor BitmapReadAccess::GetPixelFor_8BIT_PAL(ConstScanline pScanline, long nX, const ColorMask&)
76 : {
77 366487602 : return BitmapColor( pScanline[ nX ] );
78 : }
79 :
80 274306896 : void BitmapReadAccess::SetPixelFor_8BIT_PAL(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
81 : {
82 274306896 : pScanline[ nX ] = rBitmapColor.GetIndex();
83 274306896 : }
84 :
85 0 : BitmapColor BitmapReadAccess::GetPixelFor_8BIT_TC_MASK(ConstScanline pScanline, long nX, const ColorMask& rMask)
86 : {
87 0 : BitmapColor aColor;
88 0 : rMask.GetColorFor8Bit( aColor, pScanline + nX );
89 0 : return aColor;
90 : }
91 :
92 0 : void BitmapReadAccess::SetPixelFor_8BIT_TC_MASK(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask)
93 : {
94 0 : rMask.SetColorFor8Bit( rBitmapColor, pScanline + nX );
95 0 : }
96 :
97 :
98 0 : BitmapColor BitmapReadAccess::GetPixelFor_16BIT_TC_MSB_MASK(ConstScanline pScanline, long nX, const ColorMask& rMask)
99 : {
100 0 : BitmapColor aColor;
101 0 : rMask.GetColorFor16BitMSB( aColor, pScanline + ( nX << 1UL ) );
102 0 : return aColor;
103 : }
104 :
105 0 : void BitmapReadAccess::SetPixelFor_16BIT_TC_MSB_MASK(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask)
106 : {
107 0 : rMask.SetColorFor16BitMSB( rBitmapColor, pScanline + ( nX << 1UL ) );
108 0 : }
109 :
110 1501200 : BitmapColor BitmapReadAccess::GetPixelFor_16BIT_TC_LSB_MASK(ConstScanline pScanline, long nX, const ColorMask& rMask)
111 : {
112 1501200 : BitmapColor aColor;
113 1501200 : rMask.GetColorFor16BitLSB( aColor, pScanline + ( nX << 1UL ) );
114 1501200 : return aColor;
115 : }
116 :
117 50208 : void BitmapReadAccess::SetPixelFor_16BIT_TC_LSB_MASK(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask)
118 : {
119 50208 : rMask.SetColorFor16BitLSB( rBitmapColor, pScanline + ( nX << 1UL ) );
120 50208 : }
121 :
122 203827421 : BitmapColor BitmapReadAccess::GetPixelFor_24BIT_TC_BGR(ConstScanline pScanline, long nX, const ColorMask&)
123 : {
124 203827421 : BitmapColor aBitmapColor;
125 :
126 203827421 : aBitmapColor.SetBlue( *( pScanline = pScanline + nX * 3 )++ );
127 203827421 : aBitmapColor.SetGreen( *pScanline++ );
128 203827421 : aBitmapColor.SetRed( *pScanline );
129 :
130 203827421 : return aBitmapColor;
131 : }
132 :
133 1006409 : void BitmapReadAccess::SetPixelFor_24BIT_TC_BGR(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
134 : {
135 1006409 : *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetBlue();
136 1006409 : *pScanline++ = rBitmapColor.GetGreen();
137 1006409 : *pScanline = rBitmapColor.GetRed();
138 1006409 : }
139 :
140 0 : BitmapColor BitmapReadAccess::GetPixelFor_24BIT_TC_RGB(ConstScanline pScanline, long nX, const ColorMask&)
141 : {
142 0 : BitmapColor aBitmapColor;
143 :
144 0 : aBitmapColor.SetRed( *( pScanline = pScanline + nX * 3 )++ );
145 0 : aBitmapColor.SetGreen( *pScanline++ );
146 0 : aBitmapColor.SetBlue( *pScanline );
147 :
148 0 : return aBitmapColor;
149 : }
150 :
151 0 : void BitmapReadAccess::SetPixelFor_24BIT_TC_RGB(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
152 : {
153 0 : *( pScanline = pScanline + nX * 3 )++ = rBitmapColor.GetRed();
154 0 : *pScanline++ = rBitmapColor.GetGreen();
155 0 : *pScanline = rBitmapColor.GetBlue();
156 0 : }
157 :
158 0 : BitmapColor BitmapReadAccess::GetPixelFor_24BIT_TC_MASK(ConstScanline pScanline, long nX, const ColorMask& rMask)
159 : {
160 0 : BitmapColor aColor;
161 0 : rMask.GetColorFor24Bit( aColor, pScanline + nX * 3L );
162 0 : return aColor;
163 : }
164 :
165 0 : void BitmapReadAccess::SetPixelFor_24BIT_TC_MASK(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask)
166 : {
167 0 : rMask.SetColorFor24Bit( rBitmapColor, pScanline + nX * 3L );
168 0 : }
169 :
170 0 : BitmapColor BitmapReadAccess::GetPixelFor_32BIT_TC_ABGR(ConstScanline pScanline, long nX, const ColorMask&)
171 : {
172 0 : BitmapColor aBitmapColor;
173 :
174 0 : aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
175 0 : aBitmapColor.SetGreen( *pScanline++ );
176 0 : aBitmapColor.SetRed( *pScanline );
177 :
178 0 : return aBitmapColor;
179 : }
180 :
181 0 : void BitmapReadAccess::SetPixelFor_32BIT_TC_ABGR(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
182 : {
183 0 : *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
184 0 : *pScanline++ = rBitmapColor.GetBlue();
185 0 : *pScanline++ = rBitmapColor.GetGreen();
186 0 : *pScanline = rBitmapColor.GetRed();
187 0 : }
188 :
189 0 : BitmapColor BitmapReadAccess::GetPixelFor_32BIT_TC_ARGB(ConstScanline pScanline, long nX, const ColorMask&)
190 : {
191 0 : BitmapColor aBitmapColor;
192 :
193 0 : aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) + 1 )++ );
194 0 : aBitmapColor.SetGreen( *pScanline++ );
195 0 : aBitmapColor.SetBlue( *pScanline );
196 :
197 0 : return aBitmapColor;
198 : }
199 :
200 0 : void BitmapReadAccess::SetPixelFor_32BIT_TC_ARGB(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
201 : {
202 0 : *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
203 0 : *pScanline++ = rBitmapColor.GetRed();
204 0 : *pScanline++ = rBitmapColor.GetGreen();
205 0 : *pScanline = rBitmapColor.GetBlue();
206 0 : }
207 :
208 8858610 : BitmapColor BitmapReadAccess::GetPixelFor_32BIT_TC_BGRA(ConstScanline pScanline, long nX, const ColorMask&)
209 : {
210 8858610 : BitmapColor aBitmapColor;
211 :
212 8858610 : aBitmapColor.SetBlue( *( pScanline = pScanline + ( nX << 2 ) )++ );
213 8858610 : aBitmapColor.SetGreen( *pScanline++ );
214 8858610 : aBitmapColor.SetRed( *pScanline );
215 :
216 8858610 : return aBitmapColor;
217 : }
218 :
219 0 : void BitmapReadAccess::SetPixelFor_32BIT_TC_BGRA(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
220 : {
221 0 : *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
222 0 : *pScanline++ = rBitmapColor.GetGreen();
223 0 : *pScanline++ = rBitmapColor.GetRed();
224 0 : *pScanline = 0xFF;
225 0 : }
226 :
227 0 : BitmapColor BitmapReadAccess::GetPixelFor_32BIT_TC_RGBA(ConstScanline pScanline, long nX, const ColorMask&)
228 : {
229 0 : BitmapColor aBitmapColor;
230 :
231 0 : aBitmapColor.SetRed( *( pScanline = pScanline + ( nX << 2 ) )++ );
232 0 : aBitmapColor.SetGreen( *pScanline++ );
233 0 : aBitmapColor.SetBlue( *pScanline );
234 :
235 0 : return aBitmapColor;
236 : }
237 :
238 0 : void BitmapReadAccess::SetPixelFor_32BIT_TC_RGBA(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask&)
239 : {
240 0 : *( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
241 0 : *pScanline++ = rBitmapColor.GetGreen();
242 0 : *pScanline++ = rBitmapColor.GetBlue();
243 0 : *pScanline = 0xFF;
244 0 : }
245 :
246 1390911412 : BitmapColor BitmapReadAccess::GetPixelFor_32BIT_TC_MASK(ConstScanline pScanline, long nX, const ColorMask& rMask)
247 : {
248 1390911412 : BitmapColor aColor;
249 1390911412 : rMask.GetColorFor32Bit( aColor, pScanline + ( nX << 2UL ) );
250 1390911412 : return aColor;
251 : }
252 :
253 585503196 : void BitmapReadAccess::SetPixelFor_32BIT_TC_MASK(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask)
254 : {
255 585503196 : rMask.SetColorFor32Bit( rBitmapColor, pScanline + ( nX << 2UL ) );
256 585503196 : }
257 :
258 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|