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 ];
62 static const sal_uInt8 mask1Bit[] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
63 extraBitsMask = mask1Bit[ extraBitsCount ];
103 virtual void StartLine(
const sal_uInt8* pLine ) { mpData = pLine; }
105 virtual ~ImplPixelFormat() { }
108class ImplPixelFormat8 :
public ImplPixelFormat
115 : mrPalette( rPalette )
121 return mrPalette[ *mpData++ ];
125class ImplPixelFormat4 :
public ImplPixelFormat
134 : mrPalette( rPalette )
139 virtual void StartLine(
const sal_uInt8* pLine )
override
147 sal_uInt32 nIdx = ( mpData[mnX >> 1] >> mnShift) & 0x0f;
156class ImplPixelFormat1 :
public ImplPixelFormat
164 : mrPalette(rPalette)
168 virtual void StartLine(
const sal_uInt8* pLine )
override
175 const BitmapColor& rColor = mrPalette[ (mpData[mnX >> 3 ] >> ( 7 - ( mnX & 7 ) )) & 1];
181ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits,
const BitmapPalette& rPalette )
185 case 1:
return new ImplPixelFormat1( rPalette );
186 case 4:
return new ImplPixelFormat4( rPalette );
187 case 8:
return new ImplPixelFormat8( rPalette );
198void writeColorRGBA(
sal_uInt8 color8Bit,
sal_uInt8*& dst ) { *dst++ = color8Bit; *dst++ = color8Bit; *dst++ = color8Bit; *dst++ = 0xff; };
199typedef void(*WriteBlackWhiteFunction)(
sal_uInt8*& dst,
int count );
200void writeBlackA8(
sal_uInt8*& dst,
int count ) { memset( dst, 0, count ); dst +=
count; };
201void writeWhiteA8(
sal_uInt8*& dst,
int count ) { memset( dst, 0xff, count ); dst +=
count; };
202void writeWhiteRGBA(
sal_uInt8*& dst,
int count ) { memset( dst, 0xff, count * 4 ); dst +=
count * 4; };
203void writeBlackRGBA(
sal_uInt8*& dst,
int count )
205 for(
int i = 0;
i <
count; ++
i )
215template< WriteColorFunction func, WriteBlackWhiteFunction funcBlack, WriteBlackWhiteFunction funcWhite >
216void writeBlackWhiteData(
const sal_uInt8* src,
sal_uInt8* dst,
int width,
int height,
int bytesPerRow )
218 for(
int y = 0;
y < height; ++
y )
225 const sal_uInt64* src64 =
reinterpret_cast< const sal_uInt64*
>( src );
227 funcBlack( dst, 64 );
228 else if( *src64 ==
static_cast< sal_uInt64
>( -1 ))
229 funcWhite( dst, 64 );
232 src +=
sizeof( sal_uInt64 );
239 else if( *src == 0xff )
242 for(
int bit = 7;
bit >= 0; --
bit )
243 func(( *src >> bit ) & 1 ? 0xff : 0, dst );
247 for(
int bit = 7;
bit > 7 - xsize; --
bit )
248 func(( *src >> bit ) & 1 ? 0xff : 0, dst );
250 src = srcLine + bytesPerRow;
259 assert( bitCount == 1 || bitCount == 4 || bitCount == 8 );
261 std::unique_ptr< sal_uInt8[] > data(
new sal_uInt8[width * height * bpp[
type ]] );
265 for(
int y = 0;
y < height; ++
y )
266 memcpy( data.get() +
y * width, src +
y * bytesPerRow, width );
275 writeBlackWhiteData< writeColorA8, writeBlackA8, writeWhiteA8 >
276 ( src, data.get(), width, height, bytesPerRow );
281 writeBlackWhiteData< writeColorRGBA, writeBlackRGBA, writeWhiteRGBA >
282 ( src, data.get(), width, height, bytesPerRow );
287 std::unique_ptr<ImplPixelFormat> pSrcFormat(ImplPixelFormat::GetFormat(bitCount, palette));
292 sal_uInt32 nY = height;
295 pSrcFormat->StartLine( pSrcData );
297 sal_uInt32 nX = width;
329 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