25 if( lineBitsCount / 8 > 0 )
27 if( extraBitsMask != 0 )
29 sal_uInt8 extraByte = bits[ lineBitsCount / 8 ] & extraBitsMask;
49 if( lineBitsCount % 8 != 0 )
51 const int extraBitsCount = lineBitsCount % 8;
56 static const sal_uInt8 mask1Bit[] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
57 extraBitsMask = mask1Bit[ extraBitsCount ];
97 virtual void StartLine(
const sal_uInt8* pLine ) { mpData = pLine; }
99 virtual ~ImplPixelFormat() { }
102class ImplPixelFormat8 :
public ImplPixelFormat
109 : mrPalette( rPalette )
115 return mrPalette[ *mpData++ ];
119class ImplPixelFormat4 :
public ImplPixelFormat
128 : mrPalette( rPalette )
133 virtual void StartLine(
const sal_uInt8* pLine )
override
141 sal_uInt32 nIdx = ( mpData[mnX >> 1] >> mnShift) & 0x0f;
150class ImplPixelFormat1 :
public ImplPixelFormat
158 : mrPalette(rPalette)
162 virtual void StartLine(
const sal_uInt8* pLine )
override
169 const BitmapColor& rColor = mrPalette[ (mpData[mnX >> 3 ] >> ( 7 - ( mnX & 7 ) )) & 1];
175ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits,
const BitmapPalette& rPalette )
179 case 1:
return new ImplPixelFormat1( rPalette );
180 case 4:
return new ImplPixelFormat4( rPalette );
181 case 8:
return new ImplPixelFormat8( rPalette );
192void writeColorRGBA(
sal_uInt8 color8Bit,
sal_uInt8*& dst ) { *dst++ = color8Bit; *dst++ = color8Bit; *dst++ = color8Bit; *dst++ = 0xff; };
193typedef void(*WriteBlackWhiteFunction)(
sal_uInt8*& dst,
int count );
194void writeBlackA8(
sal_uInt8*& dst,
int count ) { memset( dst, 0, count ); dst +=
count; };
195void writeWhiteA8(
sal_uInt8*& dst,
int count ) { memset( dst, 0xff, count ); dst +=
count; };
196void writeWhiteRGBA(
sal_uInt8*& dst,
int count ) { memset( dst, 0xff, count * 4 ); dst +=
count * 4; };
197void writeBlackRGBA(
sal_uInt8*& dst,
int count )
199 for(
int i = 0;
i <
count; ++
i )
209template< WriteColorFunction func, WriteBlackWhiteFunction funcBlack, WriteBlackWhiteFunction funcWhite >
210void writeBlackWhiteData(
const sal_uInt8* src,
sal_uInt8* dst,
int width,
int height,
int bytesPerRow )
212 for(
int y = 0;
y < height; ++
y )
219 const sal_uInt64* src64 =
reinterpret_cast< const sal_uInt64*
>( src );
221 funcBlack( dst, 64 );
222 else if( *src64 ==
static_cast< sal_uInt64
>( -1 ))
223 funcWhite( dst, 64 );
226 src +=
sizeof( sal_uInt64 );
233 else if( *src == 0xff )
236 for(
int bit = 7;
bit >= 0; --
bit )
237 func(( *src >> bit ) & 1 ? 0xff : 0, dst );
241 for(
int bit = 7;
bit > 7 - xsize; --
bit )
242 func(( *src >> bit ) & 1 ? 0xff : 0, dst );
244 src = srcLine + bytesPerRow;
253 assert( bitCount == 1 || bitCount == 4 || bitCount == 8 );
255 std::unique_ptr< sal_uInt8[] > data(
new sal_uInt8[width * height * bpp[
type ]] );
259 for(
int y = 0;
y < height; ++
y )
260 memcpy( data.get() +
y * width, src +
y * bytesPerRow, width );
269 writeBlackWhiteData< writeColorA8, writeBlackA8, writeWhiteA8 >
270 ( src, data.get(), width, height, bytesPerRow );
275 writeBlackWhiteData< writeColorRGBA, writeBlackRGBA, writeWhiteRGBA >
276 ( src, data.get(), width, height, bytesPerRow );
281 std::unique_ptr<ImplPixelFormat> pSrcFormat(ImplPixelFormat::GetFormat(bitCount, palette));
286 sal_uInt32 nY = height;
289 pSrcFormat->StartLine( pSrcData );
291 sal_uInt32 nX = width;
323 pSrcData += bytesPerRow;
ScanlineFormat RemoveScanline(ScanlineFormat nFormat)
sal_uInt64 BitmapChecksum
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
BitmapChecksum GetChecksum() const
sal_uInt16 GetEntryCount() const
bool IsGreyPalette8Bit() const
Returns true if the palette is 8-bit grey palette.
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
BitmapChecksum mnChecksum
void updateChecksum() const
virtual void ReleaseBuffer(BitmapBuffer *pBuffer, BitmapAccessMode nMode)=0
static std::unique_ptr< sal_uInt8[] > convertDataBitCount(const sal_uInt8 *src, int width, int height, int bitCount, int bytesPerRow, const BitmapPalette &palette, BitConvert type)
virtual const basegfx::SystemDependentDataHolder * accessSystemDependentDataHolder() const
virtual BitmapBuffer * AcquireBuffer(BitmapAccessMode nMode)=0
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
static BitmapChecksum scanlineChecksum(BitmapChecksum nCrc, const sal_uInt8 *bits, int lineBitsCount, sal_uInt8 extraBitsMask)
tools::Long mnScanlineSize