LibreOffice Module vcl (master)  1
bitmapex.cxx
Go to the documentation of this file.
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 <sal/log.hxx>
21 #include <rtl/math.hxx>
23 #include <osl/diagnose.h>
26 
27 #include <vcl/ImageTree.hxx>
28 #include <vcl/outdev.hxx>
29 #include <vcl/alpha.hxx>
30 #include <vcl/bitmapex.hxx>
31 #include <vcl/svapp.hxx>
32 #include <vcl/bitmapaccess.hxx>
33 #include <vcl/virdev.hxx>
34 #include <vcl/settings.hxx>
36 
37 // BitmapEx::Create
38 #include <salbmp.hxx>
39 #include <salinst.hxx>
40 #include <svdata.hxx>
41 #include <bitmapwriteaccess.hxx>
42 
43 #include <o3tl/any.hxx>
44 
45 #include <com/sun/star/beans/XFastPropertySet.hpp>
46 
47 #include <memory>
48 
49 using namespace ::com::sun::star;
50 
52  : meTransparent(TransparentType::NONE)
53  , mbAlpha(false)
54 {
55 }
56 
57 BitmapEx::BitmapEx( const BitmapEx& ) = default;
58 
59 BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize )
60  : meTransparent(TransparentType::NONE)
61  , mbAlpha(false)
62 {
63  if( rBitmapEx.IsEmpty() )
64  return;
65 
66  maBitmap = Bitmap( aSize, rBitmapEx.maBitmap.GetBitCount() );
67  SetSizePixel(aSize);
68  if( rBitmapEx.IsAlpha() )
69  {
70  mbAlpha = true;
71  maMask = AlphaMask( aSize ).ImplGetBitmap();
72  }
73  else if( rBitmapEx.IsTransparent() )
74  maMask = Bitmap( aSize, rBitmapEx.maMask.GetBitCount() );
75 
76  tools::Rectangle aDestRect( Point( 0, 0 ), aSize );
77  tools::Rectangle aSrcRect( aSrc, aSize );
78  CopyPixel( aDestRect, aSrcRect, &rBitmapEx );
79 }
80 
81 BitmapEx::BitmapEx( Size aSize, sal_uInt16 nBitCount )
82  : meTransparent(TransparentType::NONE)
83  , mbAlpha(false)
84 {
85  maBitmap = Bitmap( aSize, nBitCount );
86  SetSizePixel(aSize);
87 }
88 
89 BitmapEx::BitmapEx( const OUString& rIconName )
90  : meTransparent(TransparentType::NONE)
91  , mbAlpha(false)
92 {
93  loadFromIconTheme( rIconName );
94 }
95 
96 void BitmapEx::loadFromIconTheme( const OUString& rIconName )
97 {
98  bool bSuccess;
99  OUString aIconTheme;
100 
101  try
102  {
104  bSuccess = ImageTree::get().loadImage(rIconName, aIconTheme, *this, true);
105  }
106  catch (...)
107  {
108  bSuccess = false;
109  }
110 
111  SAL_WARN_IF( !bSuccess, "vcl", "BitmapEx::BitmapEx(): could not load image " << rIconName << " via icon theme " << aIconTheme);
112 }
113 
114 BitmapEx::BitmapEx( const Bitmap& rBmp ) :
115  maBitmap ( rBmp ),
116  maBitmapSize ( maBitmap.GetSizePixel() ),
117  meTransparent( TransparentType::NONE ),
118  mbAlpha ( false )
119 {
120 }
121 
122 BitmapEx::BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ) :
123  maBitmap ( rBmp ),
124  maMask ( rMask ),
125  maBitmapSize ( maBitmap.GetSizePixel() ),
126  meTransparent ( !rMask ? TransparentType::NONE : TransparentType::Bitmap ),
127  mbAlpha ( false )
128 {
129  // Ensure a mask is exactly one bit deep,
130  // alternatively also allow 8bpp masks.
131  if( !!maMask && maMask.GetBitCount() != 1 && !(maMask.GetBitCount() == 8 && maMask.HasGreyPalette8Bit()))
132  {
133  SAL_WARN( "vcl", "BitmapEx: forced mask to monochrome");
134  BitmapEx aMaskEx(maMask);
136  maMask = aMaskEx.GetBitmap();
137  }
138 
140  {
141  OSL_ENSURE(false, "Mask size differs from Bitmap size, corrected Mask (!)");
143  }
144 }
145 
146 BitmapEx::BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask ) :
147  maBitmap ( rBmp ),
148  maMask ( rAlphaMask.ImplGetBitmap() ),
149  maBitmapSize ( maBitmap.GetSizePixel() ),
150  meTransparent ( !rAlphaMask ? TransparentType::NONE : TransparentType::Bitmap ),
151  mbAlpha ( !rAlphaMask.IsEmpty() )
152 {
154  {
155  OSL_ENSURE(false, "Alpha size differs from Bitmap size, corrected Mask (!)");
156  maMask.Scale(rBmp.GetSizePixel());
157  }
158 }
159 
160 BitmapEx::BitmapEx( const Bitmap& rBmp, const Color& rTransparentColor ) :
161  maBitmap ( rBmp ),
162  maBitmapSize ( maBitmap.GetSizePixel() ),
163  maTransparentColor ( rTransparentColor ),
164  meTransparent ( TransparentType::Bitmap ),
165  mbAlpha ( false )
166 {
168 
169  SAL_WARN_IF(rBmp.GetSizePixel() != maMask.GetSizePixel(), "vcl",
170  "BitmapEx::BitmapEx(): size mismatch for bitmap and alpha mask.");
171 }
172 
173 BitmapEx& BitmapEx::operator=( const BitmapEx& ) = default;
174 
175 bool BitmapEx::operator==( const BitmapEx& rBitmapEx ) const
176 {
177  if (meTransparent != rBitmapEx.meTransparent)
178  return false;
179 
180  if (GetSizePixel() != rBitmapEx.GetSizePixel())
181  return false;
182 
183  if (meTransparent != rBitmapEx.meTransparent)
184  return false;
185 
187  && maTransparentColor != rBitmapEx.maTransparentColor)
188  return false;
189 
190  if (mbAlpha != rBitmapEx.mbAlpha)
191  return false;
192 
193  if (maBitmap != rBitmapEx.maBitmap)
194  return false;
195 
196  return maMask == rBitmapEx.maMask;
197 }
198 
199 bool BitmapEx::IsEmpty() const
200 {
201  return( maBitmap.IsEmpty() && maMask.IsEmpty() );
202 }
203 
205 {
206  maBitmap.SetEmpty();
207  maMask.SetEmpty();
209  mbAlpha = false;
210 }
211 
213 {
214  SetEmpty();
215 }
216 
218 {
220 }
221 
222 bool BitmapEx::IsAlpha() const
223 {
224  return( IsTransparent() && mbAlpha );
225 }
226 
228 {
229  return maBitmap;
230 }
231 
232 Bitmap BitmapEx::GetBitmap( Color aTransparentReplaceColor ) const
233 {
234  Bitmap aRetBmp( maBitmap );
235 
237  {
238  Bitmap aTempMask;
239 
241  aTempMask = maBitmap.CreateMask( maTransparentColor );
242  else
243  aTempMask = maMask;
244 
245  if( !IsAlpha() )
246  aRetBmp.Replace( aTempMask, aTransparentReplaceColor );
247  else
248  aRetBmp.Replace( GetAlpha(), aTransparentReplaceColor );
249  }
250 
251  return aRetBmp;
252 }
253 
255 {
256  if (!IsAlpha())
257  return maMask;
258 
259  BitmapEx aMaskEx(maMask);
261  return aMaskEx.GetBitmap();
262 }
263 
265 {
266  if( IsAlpha() )
267  {
268  AlphaMask aAlpha;
269  aAlpha.ImplSetBitmap( maMask );
270  return aAlpha;
271  }
272  else
273  {
274  return AlphaMask(maMask);
275  }
276 }
277 
279 {
280  sal_uLong nSizeBytes = maBitmap.GetSizeBytes();
281 
283  nSizeBytes += maMask.GetSizeBytes();
284 
285  return nSizeBytes;
286 }
287 
289 {
291  SVBT32 aBT32;
293 
294  UInt32ToSVBT32( o3tl::underlyingEnumValue(meTransparent), aBT32 );
295  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
296 
297  UInt32ToSVBT32( sal_uInt32(mbAlpha), aBT32 );
298  nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
299 
301  {
302  BCToBCOA( maMask.GetChecksum(), aBCOA );
303  nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
304  }
305 
306  return nCrc;
307 }
308 
309 void BitmapEx::SetSizePixel(const Size& rNewSize)
310 {
311  maBitmapSize = rNewSize;
312 }
313 
315 {
316  bool bRet = false;
317 
318  if (!!maBitmap)
319  {
320  bRet = maBitmap.Invert();
321 
322  if (bRet && (meTransparent == TransparentType::Color))
324  }
325 
326  return bRet;
327 }
328 
329 bool BitmapEx::Mirror( BmpMirrorFlags nMirrorFlags )
330 {
331  bool bRet = false;
332 
333  if( !!maBitmap )
334  {
335  bRet = maBitmap.Mirror( nMirrorFlags );
336 
337  if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask )
338  maMask.Mirror( nMirrorFlags );
339  }
340 
341  return bRet;
342 }
343 
344 bool BitmapEx::Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag )
345 {
346  bool bRet = false;
347 
348  if( !!maBitmap )
349  {
350  bRet = maBitmap.Scale( rScaleX, rScaleY, nScaleFlag );
351 
352  if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask )
353  {
354  maMask.Scale( rScaleX, rScaleY, nScaleFlag );
355  }
356 
358 
360  "BitmapEx::Scale(): size mismatch for bitmap and alpha mask." );
361  }
362 
363  return bRet;
364 }
365 
366 bool BitmapEx::Scale( const Size& rNewSize, BmpScaleFlag nScaleFlag )
367 {
368  bool bRet;
369 
370  if (GetSizePixel().Width() && GetSizePixel().Height()
371  && (rNewSize.Width() != GetSizePixel().Width()
372  || rNewSize.Height() != GetSizePixel().Height() ) )
373  {
374  bRet = Scale( static_cast<double>(rNewSize.Width()) / GetSizePixel().Width(),
375  static_cast<double>(rNewSize.Height()) / GetSizePixel().Height(),
376  nScaleFlag );
377  }
378  else
379  {
380  bRet = true;
381  }
382 
383  return bRet;
384 }
385 
386 bool BitmapEx::Rotate( long nAngle10, const Color& rFillColor )
387 {
388  bool bRet = false;
389 
390  if( !!maBitmap )
391  {
392  const bool bTransRotate = ( COL_TRANSPARENT == rFillColor );
393 
394  if( bTransRotate )
395  {
397  bRet = maBitmap.Rotate( nAngle10, maTransparentColor );
398  else
399  {
400  bRet = maBitmap.Rotate( nAngle10, COL_BLACK );
401 
403  {
404  maMask = Bitmap(GetSizePixel(), 1);
407  }
408 
409  if( bRet && !!maMask )
410  maMask.Rotate( nAngle10, COL_WHITE );
411  }
412  }
413  else
414  {
415  bRet = maBitmap.Rotate( nAngle10, rFillColor );
416 
417  if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask )
418  maMask.Rotate( nAngle10, COL_WHITE );
419  }
420 
422 
424  "BitmapEx::Rotate(): size mismatch for bitmap and alpha mask.");
425  }
426 
427  return bRet;
428 }
429 
430 bool BitmapEx::Crop( const tools::Rectangle& rRectPixel )
431 {
432  bool bRet = false;
433 
434  if( !!maBitmap )
435  {
436  bRet = maBitmap.Crop( rRectPixel );
437 
438  if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask )
439  maMask.Crop( rRectPixel );
440 
442 
444  "BitmapEx::Crop(): size mismatch for bitmap and alpha mask.");
445  }
446 
447  return bRet;
448 }
449 
450 bool BitmapEx::Convert( BmpConversion eConversion )
451 {
452  return !!maBitmap && maBitmap.Convert( eConversion );
453 }
454 
455 void BitmapEx::Expand( sal_uLong nDX, sal_uLong nDY, bool bExpandTransparent )
456 {
457  bool bRet = false;
458 
459  if( !!maBitmap )
460  {
461  bRet = maBitmap.Expand( nDX, nDY );
462 
463  if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask )
464  {
465  Color aColor( bExpandTransparent ? COL_WHITE : COL_BLACK );
466  maMask.Expand( nDX, nDY, &aColor );
467  }
468 
470 
472  "BitmapEx::Expand(): size mismatch for bitmap and alpha mask.");
473  }
474 }
475 
476 bool BitmapEx::CopyPixel( const tools::Rectangle& rRectDst, const tools::Rectangle& rRectSrc,
477  const BitmapEx* pBmpExSrc )
478 {
479  bool bRet = false;
480 
481  if( !pBmpExSrc || pBmpExSrc->IsEmpty() )
482  {
483  if( !maBitmap.IsEmpty() )
484  {
485  bRet = maBitmap.CopyPixel( rRectDst, rRectSrc );
486 
487  if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask )
488  maMask.CopyPixel( rRectDst, rRectSrc );
489  }
490  }
491  else
492  {
493  if( !maBitmap.IsEmpty() )
494  {
495  bRet = maBitmap.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maBitmap );
496 
497  if( bRet )
498  {
499  if( pBmpExSrc->IsAlpha() )
500  {
501  if( IsAlpha() )
502  // cast to use the optimized AlphaMask::CopyPixel
503  maMask.CopyPixel_AlphaOptimized( rRectDst, rRectSrc, &pBmpExSrc->maMask );
504  else if( IsTransparent() )
505  {
506  std::unique_ptr<AlphaMask> pAlpha(new AlphaMask( maMask ));
507 
508  maMask = pAlpha->ImplGetBitmap();
509  pAlpha.reset();
510  mbAlpha = true;
511  maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
512  }
513  else
514  {
515  sal_uInt8 cBlack = 0;
516  std::unique_ptr<AlphaMask> pAlpha(new AlphaMask(GetSizePixel(), &cBlack));
517 
518  maMask = pAlpha->ImplGetBitmap();
519  pAlpha.reset();
521  mbAlpha = true;
522  maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
523  }
524  }
525  else if( pBmpExSrc->IsTransparent() )
526  {
527  if (IsAlpha())
528  {
529  AlphaMask aAlpha( pBmpExSrc->maMask );
530  maMask.CopyPixel( rRectDst, rRectSrc, &aAlpha.ImplGetBitmap() );
531  }
532  else if (IsTransparent())
533  {
534  maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
535  }
536  else
537  {
538  maMask = Bitmap(GetSizePixel(), 1);
541  maMask.CopyPixel( rRectDst, rRectSrc, &pBmpExSrc->maMask );
542  }
543  }
544  else if (IsAlpha())
545  {
546  sal_uInt8 cBlack = 0;
547  const AlphaMask aAlphaSrc(pBmpExSrc->GetSizePixel(), &cBlack);
548 
549  maMask.CopyPixel( rRectDst, rRectSrc, &aAlphaSrc.ImplGetBitmap() );
550  }
551  else if (IsTransparent())
552  {
553  Bitmap aMaskSrc(pBmpExSrc->GetSizePixel(), 1);
554 
555  aMaskSrc.Erase( COL_BLACK );
556  maMask.CopyPixel( rRectDst, rRectSrc, &aMaskSrc );
557  }
558  }
559  }
560  }
561 
562  return bRet;
563 }
564 
565 bool BitmapEx::Erase( const Color& rFillColor )
566 {
567  bool bRet = false;
568 
569  if( !!maBitmap )
570  {
571  bRet = maBitmap.Erase( rFillColor );
572 
573  if( bRet && ( meTransparent == TransparentType::Bitmap ) && !!maMask )
574  {
575  // Respect transparency on fill color
576  if( rFillColor.GetTransparency() )
577  {
578  const Color aFill( rFillColor.GetTransparency(), rFillColor.GetTransparency(), rFillColor.GetTransparency() );
579  maMask.Erase( aFill );
580  }
581  else
582  {
583  const Color aBlack( COL_BLACK );
584  maMask.Erase( aBlack );
585  }
586  }
587  }
588 
589  return bRet;
590 }
591 
592 void BitmapEx::Replace( const Color& rSearchColor, const Color& rReplaceColor )
593 {
594  if (!!maBitmap)
595  maBitmap.Replace( rSearchColor, rReplaceColor );
596 }
597 
598 void BitmapEx::Replace( const Color* pSearchColors, const Color* pReplaceColors, sal_uLong nColorCount )
599 {
600  if (!!maBitmap)
601  maBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, /*pTols*/nullptr );
602 }
603 
604 bool BitmapEx::Adjust( short nLuminancePercent, short nContrastPercent,
605  short nChannelRPercent, short nChannelGPercent, short nChannelBPercent,
606  double fGamma, bool bInvert, bool msoBrightness )
607 {
608  return !!maBitmap && maBitmap.Adjust( nLuminancePercent, nContrastPercent,
609  nChannelRPercent, nChannelGPercent, nChannelBPercent,
610  fGamma, bInvert, msoBrightness );
611 }
612 
613 void BitmapEx::Draw( OutputDevice* pOutDev, const Point& rDestPt ) const
614 {
615  pOutDev->DrawBitmapEx( rDestPt, *this );
616 }
617 
619  const Point& rDestPt, const Size& rDestSize ) const
620 {
621  pOutDev->DrawBitmapEx( rDestPt, rDestSize, *this );
622 }
623 
624 BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx const & aBitmap, const long aStandardSize)
625 {
626  Point aEmptyPoint(0,0);
627  double imgposX = 0;
628  double imgposY = 0;
629  BitmapEx aRet = aBitmap;
630  double imgOldWidth = aRet.GetSizePixel().Width();
631  double imgOldHeight = aRet.GetSizePixel().Height();
632 
633  Size aScaledSize;
634  if (imgOldWidth >= aStandardSize || imgOldHeight >= aStandardSize)
635  {
636  sal_Int32 imgNewWidth = 0;
637  sal_Int32 imgNewHeight = 0;
638  if (imgOldWidth >= imgOldHeight)
639  {
640  imgNewWidth = aStandardSize;
641  imgNewHeight = sal_Int32(imgOldHeight / (imgOldWidth / aStandardSize) + 0.5);
642  imgposX = 0;
643  imgposY = (aStandardSize - (imgOldHeight / (imgOldWidth / aStandardSize) + 0.5)) / 2 + 0.5;
644  }
645  else
646  {
647  imgNewHeight = aStandardSize;
648  imgNewWidth = sal_Int32(imgOldWidth / (imgOldHeight / aStandardSize) + 0.5);
649  imgposY = 0;
650  imgposX = (aStandardSize - (imgOldWidth / (imgOldHeight / aStandardSize) + 0.5)) / 2 + 0.5;
651  }
652 
653  aScaledSize = Size( imgNewWidth, imgNewHeight );
654  aRet.Scale( aScaledSize, BmpScaleFlag::BestQuality );
655  }
656  else
657  {
658  imgposX = (aStandardSize - imgOldWidth) / 2 + 0.5;
659  imgposY = (aStandardSize - imgOldHeight) / 2 + 0.5;
660  }
661 
662  Size aStdSize( aStandardSize, aStandardSize );
663  tools::Rectangle aRect(aEmptyPoint, aStdSize );
664 
667  aVirDevice->SetOutputSizePixel( aStdSize );
668  aVirDevice->SetFillColor( COL_TRANSPARENT );
669  aVirDevice->SetLineColor( COL_TRANSPARENT );
670 
671  // Draw a rect into virDevice
672  aVirDevice->DrawRect( aRect );
673  Point aPointPixel( static_cast<long>(imgposX), static_cast<long>(imgposY) );
674  aVirDevice->DrawBitmapEx( aPointPixel, aRet );
675  aRet = aVirDevice->GetBitmapEx( aEmptyPoint, aStdSize );
676 
677  return aRet;
678 }
679 
680 sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const
681 {
682  sal_uInt8 nTransparency(0xff);
683 
684  if(!maBitmap.IsEmpty())
685  {
686  if (nX >= 0 && nX < GetSizePixel().Width() && nY >= 0 && nY < GetSizePixel().Height())
687  {
688  if (maBitmap.GetBitCount() == 32)
689  return GetPixelColor(nX, nY).GetTransparency();
690  switch(meTransparent)
691  {
693  {
694  // Not transparent, ergo all covered
695  nTransparency = 0x00;
696  break;
697  }
699  {
700  Bitmap aTestBitmap(maBitmap);
701  Bitmap::ScopedReadAccess pRead(aTestBitmap);
702 
703  if(pRead)
704  {
705  const BitmapColor aBmpColor = pRead->GetColor(nY, nX);
706 
707  // If color is not equal to TransparentColor, we are not transparent
708  if (aBmpColor != maTransparentColor)
709  nTransparency = 0x00;
710 
711  }
712  break;
713  }
715  {
716  if(!maMask.IsEmpty())
717  {
718  Bitmap aTestBitmap(maMask);
719  Bitmap::ScopedReadAccess pRead(aTestBitmap);
720 
721  if(pRead)
722  {
723  const BitmapColor aBitmapColor(pRead->GetPixel(nY, nX));
724 
725  if(mbAlpha)
726  {
727  nTransparency = aBitmapColor.GetIndex();
728  }
729  else
730  {
731  if(0x00 == aBitmapColor.GetIndex())
732  {
733  nTransparency = 0x00;
734  }
735  }
736  }
737  }
738  break;
739  }
740  }
741  }
742  }
743 
744  return nTransparency;
745 }
746 
747 
748 Color BitmapEx::GetPixelColor(sal_Int32 nX, sal_Int32 nY) const
749 {
750  Bitmap::ScopedReadAccess pReadAccess( const_cast<Bitmap&>(maBitmap) );
751  assert(pReadAccess);
752 
753  BitmapColor aColor = pReadAccess->GetColor(nY, nX);
754 
755  if (IsAlpha())
756  {
757  AlphaMask aAlpha = GetAlpha();
758  AlphaMask::ScopedReadAccess pAlphaReadAccess(aAlpha);
759  aColor.SetTransparency(pAlphaReadAccess->GetPixel(nY, nX).GetIndex());
760  }
761  else if (maBitmap.GetBitCount() != 32)
762  {
763  aColor.SetTransparency(0);
764  }
765  return aColor;
766 }
767 
768 // Shift alpha transparent pixels between cppcanvas/ implementations
769 // and vcl in a generally grotesque and under-performing fashion
770 bool BitmapEx::Create( const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas,
771  const Size &rSize )
772 {
773  uno::Reference< beans::XFastPropertySet > xFastPropertySet( xBitmapCanvas, uno::UNO_QUERY );
774  if( xFastPropertySet )
775  {
776  // 0 means get BitmapEx
777  uno::Any aAny = xFastPropertySet->getFastPropertyValue( 0 );
778  std::unique_ptr<BitmapEx> xBitmapEx(reinterpret_cast<BitmapEx*>(*o3tl::doAccess<sal_Int64>(aAny)));
779  if( xBitmapEx )
780  {
781  *this = *xBitmapEx;
782  return true;
783  }
784  }
785 
786  std::shared_ptr<SalBitmap> pSalBmp;
787  std::shared_ptr<SalBitmap> pSalMask;
788 
789  pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
790 
791  Size aLocalSize(rSize);
792  if( pSalBmp->Create( xBitmapCanvas, aLocalSize ) )
793  {
794  pSalMask = ImplGetSVData()->mpDefInst->CreateSalBitmap();
795  if ( pSalMask->Create( xBitmapCanvas, aLocalSize, true ) )
796  {
797  *this = BitmapEx(Bitmap(pSalBmp), Bitmap(pSalMask) );
798  return true;
799  }
800  else
801  {
802  *this = BitmapEx(Bitmap(pSalBmp));
803  return true;
804  }
805  }
806 
807  return false;
808 }
809 
810 namespace
811 {
812  Bitmap impTransformBitmap(
813  const Bitmap& rSource,
814  const Size& rDestinationSize,
815  const basegfx::B2DHomMatrix& rTransform,
816  bool bSmooth)
817  {
818  Bitmap aDestination(rDestinationSize, 24);
819  BitmapScopedWriteAccess xWrite(aDestination);
820 
821  if(xWrite)
822  {
823  Bitmap::ScopedReadAccess xRead(const_cast< Bitmap& >(rSource));
824 
825  if (xRead)
826  {
827  const Size aDestinationSizePixel(aDestination.GetSizePixel());
828  const BitmapColor aOutside(BitmapColor(0xff, 0xff, 0xff));
829 
830  for(long y(0); y < aDestinationSizePixel.getHeight(); y++)
831  {
832  Scanline pScanline = xWrite->GetScanline( y );
833  for(long x(0); x < aDestinationSizePixel.getWidth(); x++)
834  {
835  const basegfx::B2DPoint aSourceCoor(rTransform * basegfx::B2DPoint(x, y));
836 
837  if(bSmooth)
838  {
839  xWrite->SetPixelOnData(
840  pScanline,
841  x,
842  xRead->GetInterpolatedColorWithFallback(
843  aSourceCoor.getY(),
844  aSourceCoor.getX(),
845  aOutside));
846  }
847  else
848  {
849  // this version does the correct <= 0.0 checks, so no need
850  // to do the static_cast< sal_Int32 > self and make an error
851  xWrite->SetPixelOnData(
852  pScanline,
853  x,
854  xRead->GetColorWithFallback(
855  aSourceCoor.getY(),
856  aSourceCoor.getX(),
857  aOutside));
858  }
859  }
860  }
861  }
862  }
863  xWrite.reset();
864 
865  rSource.AdaptBitCount(aDestination);
866 
867  return aDestination;
868  }
869 
871  bool implTransformNeedsSmooth(const basegfx::B2DHomMatrix& rTransformation)
872  {
873  basegfx::B2DVector aScale, aTranslate;
874  double fRotate, fShearX;
875  rTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
876  if (aScale != basegfx::B2DVector(1, 1))
877  {
878  return true;
879  }
880 
881  fRotate = fmod( fRotate, F_2PI );
882  if (fRotate < 0)
883  {
884  fRotate += F_2PI;
885  }
886  if (!rtl::math::approxEqual(fRotate, 0)
887  && !rtl::math::approxEqual(fRotate, F_PI2)
888  && !rtl::math::approxEqual(fRotate, F_PI)
889  && !rtl::math::approxEqual(fRotate, 3 * F_PI2))
890  {
891  return true;
892  }
893 
894  if (!rtl::math::approxEqual(fShearX, 0))
895  {
896  return true;
897  }
898 
899  return false;
900  }
901 } // end of anonymous namespace
902 
904  double fWidth,
905  double fHeight,
906  const basegfx::B2DHomMatrix& rTransformation) const
907 {
908  if(fWidth <= 1 || fHeight <= 1)
909  return BitmapEx();
910 
911  // force destination to 24 bit, we want to smooth output
912  const Size aDestinationSize(basegfx::fround(fWidth), basegfx::fround(fHeight));
913  bool bSmooth = implTransformNeedsSmooth(rTransformation);
914  const Bitmap aDestination(impTransformBitmap(GetBitmap(), aDestinationSize, rTransformation, bSmooth));
915 
916  // create mask
917  if(IsTransparent())
918  {
919  if(IsAlpha())
920  {
921  const Bitmap aAlpha(impTransformBitmap(GetAlpha().GetBitmap(), aDestinationSize, rTransformation, bSmooth));
922  return BitmapEx(aDestination, AlphaMask(aAlpha));
923  }
924  else
925  {
926  const Bitmap aLclMask(impTransformBitmap(GetMask(), aDestinationSize, rTransformation, false));
927  return BitmapEx(aDestination, aLclMask);
928  }
929  }
930 
931  return BitmapEx(aDestination);
932 }
933 
935  const basegfx::B2DHomMatrix& rTransformation,
936  const basegfx::B2DRange& rVisibleRange,
937  double fMaximumArea) const
938 {
939  BitmapEx aRetval;
940 
941  if(IsEmpty())
942  return aRetval;
943 
944  const sal_uInt32 nSourceWidth(GetSizePixel().Width());
945  const sal_uInt32 nSourceHeight(GetSizePixel().Height());
946 
947  if(!nSourceWidth || !nSourceHeight)
948  return aRetval;
949 
950  // Get aOutlineRange
951  basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0);
952 
953  aOutlineRange.transform(rTransformation);
954 
955  // create visible range from it by moving from relative to absolute
956  basegfx::B2DRange aVisibleRange(rVisibleRange);
957 
958  aVisibleRange.transform(
960  aOutlineRange.getRange(),
961  aOutlineRange.getMinimum()));
962 
963  // get target size (which is visible range's size)
964  double fWidth(aVisibleRange.getWidth());
965  double fHeight(aVisibleRange.getHeight());
966 
967  if(fWidth < 1.0 || fHeight < 1.0)
968  {
969  return aRetval;
970  }
971 
972  // test if discrete size (pixel) maybe too big and limit it
973  const double fArea(fWidth * fHeight);
974  const bool bNeedToReduce(basegfx::fTools::more(fArea, fMaximumArea));
975  double fReduceFactor(1.0);
976 
977  if(bNeedToReduce)
978  {
979  fReduceFactor = sqrt(fMaximumArea / fArea);
980  fWidth *= fReduceFactor;
981  fHeight *= fReduceFactor;
982  }
983 
984  // Build complete transform from source pixels to target pixels.
985  // Start by scaling from source pixel size to unit coordinates
986  basegfx::B2DHomMatrix aTransform(
988  1.0 / nSourceWidth,
989  1.0 / nSourceHeight));
990 
991  // multiply with given transform which leads from unit coordinates inside
992  // aOutlineRange
993  aTransform = rTransformation * aTransform;
994 
995  // subtract top-left of absolute VisibleRange
996  aTransform.translate(
997  -aVisibleRange.getMinX(),
998  -aVisibleRange.getMinY());
999 
1000  // scale to target pixels (if needed)
1001  if(bNeedToReduce)
1002  {
1003  aTransform.scale(fReduceFactor, fReduceFactor);
1004  }
1005 
1006  // invert to get transformation from target pixel coordinates to source pixels
1007  aTransform.invert();
1008 
1009  // create bitmap using source, destination and linear back-transformation
1010  aRetval = TransformBitmapEx(fWidth, fHeight, aTransform);
1011 
1012  return aRetval;
1013 }
1014 
1015 BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorModifierStack) const
1016 {
1017  Bitmap aChangedBitmap(GetBitmap());
1018  bool bDone(false);
1019 
1020  for(sal_uInt32 a(rBColorModifierStack.count()); a && !bDone; )
1021  {
1022  const basegfx::BColorModifierSharedPtr& rModifier = rBColorModifierStack.getBColorModifier(--a);
1023  const basegfx::BColorModifier_replace* pReplace = dynamic_cast< const basegfx::BColorModifier_replace* >(rModifier.get());
1024 
1025  if(pReplace)
1026  {
1027  // complete replace
1028  if(IsTransparent())
1029  {
1030  // clear bitmap with dest color
1031  if(aChangedBitmap.GetBitCount() <= 8)
1032  {
1033  // For e.g. 8bit Bitmaps, the nearest color to the given erase color is
1034  // determined and used -> this may be different from what is wanted here.
1035  // Better create a new bitmap with the needed color explicitly.
1036  Bitmap::ScopedReadAccess xReadAccess(aChangedBitmap);
1037  OSL_ENSURE(xReadAccess, "Got no Bitmap ReadAccess ?!?");
1038 
1039  if(xReadAccess)
1040  {
1041  BitmapPalette aNewPalette(xReadAccess->GetPalette());
1042  aNewPalette[0] = BitmapColor(Color(pReplace->getBColor()));
1043  aChangedBitmap = Bitmap(
1044  aChangedBitmap.GetSizePixel(),
1045  aChangedBitmap.GetBitCount(),
1046  &aNewPalette);
1047  }
1048  }
1049  aChangedBitmap.Erase(Color(pReplace->getBColor()));
1050  }
1051  else
1052  {
1053  // erase bitmap, caller will know to paint direct
1054  aChangedBitmap.SetEmpty();
1055  }
1056 
1057  bDone = true;
1058  }
1059  else
1060  {
1061  BitmapScopedWriteAccess xContent(aChangedBitmap);
1062 
1063  if(xContent)
1064  {
1065  const double fConvertColor(1.0 / 255.0);
1066 
1067  if(xContent->HasPalette())
1068  {
1069  const sal_uInt16 nCount(xContent->GetPaletteEntryCount());
1070 
1071  for(sal_uInt16 b(0); b < nCount; b++)
1072  {
1073  const BitmapColor& rCol = xContent->GetPaletteColor(b);
1074  const basegfx::BColor aBSource(
1075  rCol.GetRed() * fConvertColor,
1076  rCol.GetGreen() * fConvertColor,
1077  rCol.GetBlue() * fConvertColor);
1078  const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
1079  xContent->SetPaletteColor(b, BitmapColor(Color(aBDest)));
1080  }
1081  }
1082  else if(ScanlineFormat::N24BitTcBgr == xContent->GetScanlineFormat())
1083  {
1084  for(long y(0); y < xContent->Height(); y++)
1085  {
1086  Scanline pScan = xContent->GetScanline(y);
1087 
1088  for(long x(0); x < xContent->Width(); x++)
1089  {
1090  const basegfx::BColor aBSource(
1091  *(pScan + 2)* fConvertColor,
1092  *(pScan + 1) * fConvertColor,
1093  *pScan * fConvertColor);
1094  const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
1095  *pScan++ = static_cast< sal_uInt8 >(aBDest.getBlue() * 255.0);
1096  *pScan++ = static_cast< sal_uInt8 >(aBDest.getGreen() * 255.0);
1097  *pScan++ = static_cast< sal_uInt8 >(aBDest.getRed() * 255.0);
1098  }
1099  }
1100  }
1101  else if(ScanlineFormat::N24BitTcRgb == xContent->GetScanlineFormat())
1102  {
1103  for(long y(0); y < xContent->Height(); y++)
1104  {
1105  Scanline pScan = xContent->GetScanline(y);
1106 
1107  for(long x(0); x < xContent->Width(); x++)
1108  {
1109  const basegfx::BColor aBSource(
1110  *pScan * fConvertColor,
1111  *(pScan + 1) * fConvertColor,
1112  *(pScan + 2) * fConvertColor);
1113  const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
1114  *pScan++ = static_cast< sal_uInt8 >(aBDest.getRed() * 255.0);
1115  *pScan++ = static_cast< sal_uInt8 >(aBDest.getGreen() * 255.0);
1116  *pScan++ = static_cast< sal_uInt8 >(aBDest.getBlue() * 255.0);
1117  }
1118  }
1119  }
1120  else
1121  {
1122  for(long y(0); y < xContent->Height(); y++)
1123  {
1124  Scanline pScanline = xContent->GetScanline( y );
1125  for(long x(0); x < xContent->Width(); x++)
1126  {
1127  const BitmapColor aBMCol(xContent->GetColor(y, x));
1128  const basegfx::BColor aBSource(
1129  static_cast<double>(aBMCol.GetRed()) * fConvertColor,
1130  static_cast<double>(aBMCol.GetGreen()) * fConvertColor,
1131  static_cast<double>(aBMCol.GetBlue()) * fConvertColor);
1132  const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource));
1133 
1134  xContent->SetPixelOnData(pScanline, x, BitmapColor(Color(aBDest)));
1135  }
1136  }
1137  }
1138  }
1139  }
1140  }
1141 
1142  if(aChangedBitmap.IsEmpty())
1143  {
1144  return BitmapEx();
1145  }
1146  else
1147  {
1148  if(IsTransparent())
1149  {
1150  if(IsAlpha())
1151  {
1152  return BitmapEx(aChangedBitmap, GetAlpha());
1153  }
1154  else
1155  {
1156  return BitmapEx(aChangedBitmap, GetMask());
1157  }
1158  }
1159  else
1160  {
1161  return BitmapEx(aChangedBitmap);
1162  }
1163  }
1164 }
1165 
1167  const Size& rSize,
1168  sal_uInt8 nAlpha,
1169  Color aColorTopLeft,
1170  Color aColorBottomRight)
1171 {
1172  const sal_uInt32 nW(rSize.Width());
1173  const sal_uInt32 nH(rSize.Height());
1174 
1175  if(nW || nH)
1176  {
1177  Color aColTopRight(aColorTopLeft);
1178  Color aColBottomLeft(aColorTopLeft);
1179  const sal_uInt32 nDE(nW + nH);
1180 
1181  aColTopRight.Merge(aColorBottomRight, 255 - sal_uInt8((nW * 255) / nDE));
1182  aColBottomLeft.Merge(aColorBottomRight, 255 - sal_uInt8((nH * 255) / nDE));
1183 
1184  return createBlendFrame(rSize, nAlpha, aColorTopLeft, aColTopRight, aColorBottomRight, aColBottomLeft);
1185  }
1186 
1187  return BitmapEx();
1188 }
1189 
1191  const Size& rSize,
1192  sal_uInt8 nAlpha,
1193  Color aColorTopLeft,
1194  Color aColorTopRight,
1195  Color aColorBottomRight,
1196  Color aColorBottomLeft)
1197 {
1198  BlendFrameCache* pBlendFrameCache = ImplGetBlendFrameCache();
1199 
1200  if(pBlendFrameCache->m_aLastSize == rSize
1201  && pBlendFrameCache->m_nLastAlpha == nAlpha
1202  && pBlendFrameCache->m_aLastColorTopLeft == aColorTopLeft
1203  && pBlendFrameCache->m_aLastColorTopRight == aColorTopRight
1204  && pBlendFrameCache->m_aLastColorBottomRight == aColorBottomRight
1205  && pBlendFrameCache->m_aLastColorBottomLeft == aColorBottomLeft)
1206  {
1207  return pBlendFrameCache->m_aLastResult;
1208  }
1209 
1210  pBlendFrameCache->m_aLastSize = rSize;
1211  pBlendFrameCache->m_nLastAlpha = nAlpha;
1212  pBlendFrameCache->m_aLastColorTopLeft = aColorTopLeft;
1213  pBlendFrameCache->m_aLastColorTopRight = aColorTopRight;
1214  pBlendFrameCache->m_aLastColorBottomRight = aColorBottomRight;
1215  pBlendFrameCache->m_aLastColorBottomLeft = aColorBottomLeft;
1216  pBlendFrameCache->m_aLastResult.Clear();
1217 
1218  const long nW(rSize.Width());
1219  const long nH(rSize.Height());
1220 
1221  if(nW > 1 && nH > 1)
1222  {
1223  sal_uInt8 aEraseTrans(0xff);
1224  Bitmap aContent(rSize, 24);
1225  AlphaMask aAlpha(rSize, &aEraseTrans);
1226 
1227  aContent.Erase(COL_BLACK);
1228 
1230  AlphaScopedWriteAccess pAlpha(aAlpha);
1231 
1232  if(pContent && pAlpha)
1233  {
1234  long x(0);
1235  long y(0);
1236  Scanline pScanContent = pContent->GetScanline( 0 );
1237  Scanline pScanAlpha = pContent->GetScanline( 0 );
1238 
1239  // x == 0, y == 0, top-left corner
1240  pContent->SetPixelOnData(pScanContent, 0, aColorTopLeft);
1241  pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha));
1242 
1243  // y == 0, top line left to right
1244  for(x = 1; x < nW - 1; x++)
1245  {
1246  Color aMix(aColorTopLeft);
1247 
1248  aMix.Merge(aColorTopRight, 255 - sal_uInt8((x * 255) / nW));
1249  pContent->SetPixelOnData(pScanContent, x, aMix);
1250  pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha));
1251  }
1252 
1253  // x == nW - 1, y == 0, top-right corner
1254  // #i123690# Caution! When nW is 1, x == nW is possible (!)
1255  if(x < nW)
1256  {
1257  pContent->SetPixelOnData(pScanContent, x, aColorTopRight);
1258  pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha));
1259  }
1260 
1261  // x == 0 and nW - 1, left and right line top-down
1262  for(y = 1; y < nH - 1; y++)
1263  {
1264  pScanContent = pContent->GetScanline( y );
1265  pScanAlpha = pContent->GetScanline( y );
1266  Color aMixA(aColorTopLeft);
1267 
1268  aMixA.Merge(aColorBottomLeft, 255 - sal_uInt8((y * 255) / nH));
1269  pContent->SetPixelOnData(pScanContent, 0, aMixA);
1270  pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha));
1271 
1272  // #i123690# Caution! When nW is 1, x == nW is possible (!)
1273  if(x < nW)
1274  {
1275  Color aMixB(aColorTopRight);
1276 
1277  aMixB.Merge(aColorBottomRight, 255 - sal_uInt8((y * 255) / nH));
1278  pContent->SetPixelOnData(pScanContent, x, aMixB);
1279  pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha));
1280  }
1281  }
1282 
1283  // #i123690# Caution! When nH is 1, y == nH is possible (!)
1284  if(y < nH)
1285  {
1286  // x == 0, y == nH - 1, bottom-left corner
1287  pContent->SetPixelOnData(pScanContent, 0, aColorBottomLeft);
1288  pAlpha->SetPixelOnData(pScanAlpha, 0, BitmapColor(nAlpha));
1289 
1290  // y == nH - 1, bottom line left to right
1291  for(x = 1; x < nW - 1; x++)
1292  {
1293  Color aMix(aColorBottomLeft);
1294 
1295  aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((x - 0)* 255) / nW));
1296  pContent->SetPixelOnData(pScanContent, x, aMix);
1297  pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha));
1298  }
1299 
1300  // x == nW - 1, y == nH - 1, bottom-right corner
1301  // #i123690# Caution! When nW is 1, x == nW is possible (!)
1302  if(x < nW)
1303  {
1304  pContent->SetPixelOnData(pScanContent, x, aColorBottomRight);
1305  pAlpha->SetPixelOnData(pScanAlpha, x, BitmapColor(nAlpha));
1306  }
1307  }
1308 
1309  pContent.reset();
1310  pAlpha.reset();
1311 
1312  pBlendFrameCache->m_aLastResult = BitmapEx(aContent, aAlpha);
1313  }
1314  }
1315 
1316  return pBlendFrameCache->m_aLastResult;
1317 }
1318 
1319 void BitmapEx::Replace(const Color& rSearchColor,
1320  const Color& rReplaceColor,
1321  sal_uInt8 nTolerance)
1322 {
1323  maBitmap.Replace(rSearchColor, rReplaceColor, nTolerance);
1324 }
1325 
1326 void BitmapEx::Replace( const Color* pSearchColors,
1327  const Color* pReplaceColors,
1328  sal_uLong nColorCount,
1329  sal_uInt8 const * pTols )
1330 {
1331  maBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, pTols );
1332 }
1333 
1335 {
1336  if( IsTransparent() )
1337  {
1338  maBitmap.Replace( GetMask(), rColor );
1339  maMask = Bitmap();
1343  mbAlpha = false;
1344  }
1345 }
1346 
1347 static Bitmap DetectEdges( const Bitmap& rBmp )
1348 {
1349  constexpr sal_uInt8 cEdgeDetectThreshold = 128;
1350  const Size aSize( rBmp.GetSizePixel() );
1351  Bitmap aRetBmp;
1352 
1353  if( ( aSize.Width() > 2 ) && ( aSize.Height() > 2 ) )
1354  {
1355  Bitmap aWorkBmp( rBmp );
1356 
1357  if( aWorkBmp.Convert( BmpConversion::N8BitGreys ) )
1358  {
1359  bool bRet = false;
1360 
1362  pVirDev->SetOutputSizePixel(aSize);
1363  Bitmap::ScopedReadAccess pReadAcc(aWorkBmp);
1364 
1365  if( pReadAcc )
1366  {
1367  const long nWidth = aSize.Width();
1368  const long nWidth2 = nWidth - 2;
1369  const long nHeight = aSize.Height();
1370  const long nHeight2 = nHeight - 2;
1371  const long lThres2 = static_cast<long>(cEdgeDetectThreshold) * cEdgeDetectThreshold;
1372  long nSum1;
1373  long nSum2;
1374  long lGray;
1375 
1376  // initialize border with white pixels
1377  pVirDev->SetLineColor( COL_WHITE );
1378  pVirDev->DrawLine( Point(), Point( nWidth - 1, 0L ) );
1379  pVirDev->DrawLine( Point( nWidth - 1, 0L ), Point( nWidth - 1, nHeight - 1 ) );
1380  pVirDev->DrawLine( Point( nWidth - 1, nHeight - 1 ), Point( 0L, nHeight - 1 ) );
1381  pVirDev->DrawLine( Point( 0, nHeight - 1 ), Point() );
1382 
1383  for( long nY = 0, nY1 = 1, nY2 = 2; nY < nHeight2; nY++, nY1++, nY2++ )
1384  {
1385  Scanline pScanlineRead = pReadAcc->GetScanline( nY );
1386  Scanline pScanlineRead1 = pReadAcc->GetScanline( nY1 );
1387  Scanline pScanlineRead2 = pReadAcc->GetScanline( nY2 );
1388  for( long nX = 0, nXDst = 1, nXTmp; nX < nWidth2; nX++, nXDst++ )
1389  {
1390  nXTmp = nX;
1391 
1392  nSum2 = pReadAcc->GetIndexFromData( pScanlineRead, nXTmp++ );
1393  nSum1 = -nSum2;
1394  nSum2 += static_cast<long>(pReadAcc->GetIndexFromData( pScanlineRead, nXTmp++ )) << 1;
1395  lGray = pReadAcc->GetIndexFromData( pScanlineRead, nXTmp );
1396  nSum1 += lGray;
1397  nSum2 += lGray;
1398 
1399  nSum1 += static_cast<long>(pReadAcc->GetIndexFromData( pScanlineRead1, nXTmp )) << 1;
1400  nXTmp -= 2;
1401  nSum1 -= static_cast<long>(pReadAcc->GetIndexFromData( pScanlineRead1, nXTmp )) << 1;
1402 
1403  lGray = -static_cast<long>(pReadAcc->GetIndexFromData( pScanlineRead2, nXTmp++ ));
1404  nSum1 += lGray;
1405  nSum2 += lGray;
1406  nSum2 -= static_cast<long>(pReadAcc->GetIndexFromData( pScanlineRead2, nXTmp++ )) << 1;
1407  lGray = static_cast<long>(pReadAcc->GetIndexFromData( pScanlineRead2, nXTmp ));
1408  nSum1 += lGray;
1409  nSum2 -= lGray;
1410 
1411  if( ( nSum1 * nSum1 + nSum2 * nSum2 ) < lThres2 )
1412  pVirDev->DrawPixel( Point(nXDst, nY), COL_WHITE );
1413  else
1414  pVirDev->DrawPixel( Point(nXDst, nY), COL_BLACK );
1415  }
1416  }
1417 
1418  bRet = true;
1419  }
1420 
1421  pReadAcc.reset();
1422 
1423  if( bRet )
1424  aRetBmp = pVirDev->GetBitmap(Point(0,0), aSize);
1425  }
1426  }
1427 
1428  if( !aRetBmp )
1429  aRetBmp = rBmp;
1430  else
1431  {
1432  aRetBmp.SetPrefMapMode( rBmp.GetPrefMapMode() );
1433  aRetBmp.SetPrefSize( rBmp.GetPrefSize() );
1434  }
1435 
1436  return aRetBmp;
1437 }
1438 
1440 tools::Polygon BitmapEx::GetContour( bool bContourEdgeDetect,
1441  const tools::Rectangle* pWorkRectPixel )
1442 {
1443  Bitmap aWorkBmp;
1444  tools::Polygon aRetPoly;
1445  tools::Rectangle aWorkRect( Point(), maBitmap.GetSizePixel() );
1446 
1447  if( pWorkRectPixel )
1448  aWorkRect.Intersection( *pWorkRectPixel );
1449 
1450  aWorkRect.Justify();
1451 
1452  if( ( aWorkRect.GetWidth() > 4 ) && ( aWorkRect.GetHeight() > 4 ) )
1453  {
1454  // if the flag is set, we need to detect edges
1455  if( bContourEdgeDetect )
1456  aWorkBmp = DetectEdges( maBitmap );
1457  else
1458  aWorkBmp = maBitmap;
1459 
1460  BitmapReadAccess* pAcc = aWorkBmp.AcquireReadAccess();
1461 
1462  const long nWidth = pAcc ? pAcc->Width() : 0;
1463  const long nHeight = pAcc ? pAcc->Height() : 0;
1464 
1465  if (pAcc && nWidth && nHeight)
1466  {
1467  const Size& rPrefSize = aWorkBmp.GetPrefSize();
1468  const double fFactorX = static_cast<double>(rPrefSize.Width()) / nWidth;
1469  const double fFactorY = static_cast<double>(rPrefSize.Height()) / nHeight;
1470  const long nStartX1 = aWorkRect.Left() + 1;
1471  const long nEndX1 = aWorkRect.Right();
1472  const long nStartX2 = nEndX1 - 1;
1473  const long nStartY1 = aWorkRect.Top() + 1;
1474  const long nEndY1 = aWorkRect.Bottom();
1475  std::unique_ptr<Point[]> pPoints1;
1476  std::unique_ptr<Point[]> pPoints2;
1477  long nX, nY;
1478  sal_uInt16 nPolyPos = 0;
1479  const BitmapColor aBlack = pAcc->GetBestMatchingColor( COL_BLACK );
1480 
1481  pPoints1.reset(new Point[ nHeight ]);
1482  pPoints2.reset(new Point[ nHeight ]);
1483 
1484  for ( nY = nStartY1; nY < nEndY1; nY++ )
1485  {
1486  nX = nStartX1;
1487  Scanline pScanline = pAcc->GetScanline( nY );
1488 
1489  // scan row from left to right
1490  while( nX < nEndX1 )
1491  {
1492  if( aBlack == pAcc->GetPixelFromData( pScanline, nX ) )
1493  {
1494  pPoints1[ nPolyPos ] = Point( nX, nY );
1495  nX = nStartX2;
1496 
1497  // this loop always breaks eventually as there is at least one pixel
1498  while( true )
1499  {
1500  if( aBlack == pAcc->GetPixelFromData( pScanline, nX ) )
1501  {
1502  pPoints2[ nPolyPos ] = Point( nX, nY );
1503  break;
1504  }
1505 
1506  nX--;
1507  }
1508 
1509  nPolyPos++;
1510  break;
1511  }
1512 
1513  nX++;
1514  }
1515  }
1516 
1517  const sal_uInt16 nNewSize1 = nPolyPos << 1;
1518 
1519  aRetPoly = tools::Polygon( nPolyPos, pPoints1.get() );
1520  aRetPoly.SetSize( nNewSize1 + 1 );
1521  aRetPoly[ nNewSize1 ] = aRetPoly[ 0 ];
1522 
1523  for( sal_uInt16 j = nPolyPos; nPolyPos < nNewSize1; )
1524  aRetPoly[ nPolyPos++ ] = pPoints2[ --j ];
1525 
1526  if( ( fFactorX != 0. ) && ( fFactorY != 0. ) )
1527  aRetPoly.Scale( fFactorX, fFactorY );
1528  }
1529 
1530  Bitmap::ReleaseAccess(pAcc);
1531  }
1532 
1533  return aRetPoly;
1534 }
1535 
1536 void BitmapEx::setAlphaFrom( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo )
1537 {
1538  AlphaMask aAlphaMask(GetAlpha());
1539  BitmapScopedWriteAccess pWriteAccess(aAlphaMask);
1540  Bitmap::ScopedReadAccess pReadAccess(maBitmap);
1541  assert( pReadAccess.get() && pWriteAccess.get() );
1542  if ( pReadAccess.get() && pWriteAccess.get() )
1543  {
1544  for ( long nY = 0; nY < pReadAccess->Height(); nY++ )
1545  {
1546  Scanline pScanline = pWriteAccess->GetScanline( nY );
1547  Scanline pScanlineRead = pReadAccess->GetScanline( nY );
1548  for ( long nX = 0; nX < pReadAccess->Width(); nX++ )
1549  {
1550  const sal_uInt8 cIndex = pReadAccess->GetPixelFromData( pScanlineRead, nX ).GetIndex();
1551  if ( cIndex == cIndexFrom )
1552  pWriteAccess->SetPixelOnData( pScanline, nX, BitmapColor(nAlphaTo) );
1553  }
1554  }
1555  }
1556 }
1557 
1559 {
1560  AlphaMask aAlpha;
1561 
1562  if (!IsTransparent())
1563  {
1564  aAlpha = AlphaMask(GetSizePixel(), &cTrans);
1565  }
1566  else if( !IsAlpha() )
1567  {
1568  aAlpha = GetMask();
1569  aAlpha.Replace( 0, cTrans );
1570  }
1571  else
1572  {
1573  aAlpha = GetAlpha();
1574  BitmapScopedWriteAccess pA(aAlpha);
1575  assert(pA);
1576 
1577  if( !pA )
1578  return;
1579 
1580  sal_uLong nTrans = cTrans, nNewTrans;
1581  const long nWidth = pA->Width(), nHeight = pA->Height();
1582 
1584  {
1585  for( long nY = 0; nY < nHeight; nY++ )
1586  {
1587  Scanline pAScan = pA->GetScanline( nY );
1588 
1589  for( long nX = 0; nX < nWidth; nX++ )
1590  {
1591  nNewTrans = nTrans + *pAScan;
1592  *pAScan++ = static_cast<sal_uInt8>( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans );
1593  }
1594  }
1595  }
1596  else
1597  {
1598  BitmapColor aAlphaValue( 0 );
1599 
1600  for( long nY = 0; nY < nHeight; nY++ )
1601  {
1602  Scanline pScanline = pA->GetScanline( nY );
1603  for( long nX = 0; nX < nWidth; nX++ )
1604  {
1605  nNewTrans = nTrans + pA->GetIndexFromData( pScanline, nX );
1606  aAlphaValue.SetIndex( static_cast<sal_uInt8>( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans ) );
1607  pA->SetPixelOnData( pScanline, nX, aAlphaValue );
1608  }
1609  }
1610  }
1611  }
1612  *this = BitmapEx( GetBitmap(), aAlpha );
1613 }
1614 
1616 {
1617  Bitmap aNewMask = maBitmap.CreateMask( maskColor, nTol );
1618  if ( IsTransparent() )
1619  aNewMask.CombineSimple( maMask, BmpCombine::Or );
1620  maMask = aNewMask;
1622 }
1623 
1627 void BitmapEx::GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
1628  sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex,
1629  sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount)
1630 {
1631  Bitmap::ScopedReadAccess pReadAccess( maBitmap );
1632  assert( pReadAccess );
1633 
1634  if( pReadAccess->HasPalette() )
1635  {
1636  sal_uInt16 nPalCount = pReadAccess->GetPaletteEntryCount();
1637 
1638  if( nPalCount )
1639  {
1640  rRGBPalette = css::uno::Sequence< sal_Int32 >( nPalCount + 1 );
1641 
1642  sal_Int32* pTmp = rRGBPalette.getArray();
1643 
1644  for( sal_uInt32 i = 0; i < nPalCount; i++, pTmp++ )
1645  {
1646  const BitmapColor& rCol = pReadAccess->GetPaletteColor( static_cast<sal_uInt16>(i) );
1647 
1648  *pTmp = static_cast<sal_Int32>(rCol.GetRed()) << sal_Int32(24);
1649  *pTmp |= static_cast<sal_Int32>(rCol.GetGreen()) << sal_Int32(16);
1650  *pTmp |= static_cast<sal_Int32>(rCol.GetBlue()) << sal_Int32(8);
1651  *pTmp |= sal_Int32(0x000000ffL);
1652  }
1653 
1654  if( IsTransparent() )
1655  {
1656  // append transparent entry
1657  *pTmp = sal_Int32(0xffffff00L);
1658  rnTransparencyIndex = nPalCount;
1659  nPalCount++;
1660  }
1661  else
1662  rnTransparencyIndex = 0;
1663  }
1664  }
1665  else
1666  {
1667  rnRedMask = 0xff000000UL;
1668  rnGreenMask = 0x00ff0000UL;
1669  rnBlueMask = 0x0000ff00UL;
1670  rnAlphaMask = 0x000000ffUL;
1671  rnTransparencyIndex = 0;
1672  }
1673 
1674  rnWidth = pReadAccess->Width();
1675  rnHeight = pReadAccess->Height();
1676  rnBitCount = pReadAccess->GetBitCount();
1677 }
1678 
1679 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const BitmapEx &rBitmapEx) const
Definition: bitmapex.cxx:175
long Width() const
Color m_aLastColorBottomLeft
Definition: svdata.hxx:349
void Replace(const Bitmap &rMask, sal_uInt8 rReplaceTransparency)
Definition: alpha.cxx:80
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
Definition: bitmapex.cxx:565
Bitmap GetMask() const
Definition: bitmapex.cxx:254
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
bool Adjust(short nLuminancePercent, short nContrastPercent=0, short nChannelRPercent=0, short nChannelGPercent=0, short nChannelBPercent=0, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
Change various global color characteristics.
Definition: bitmap3.cxx:999
sal_uInt8 GetIndex() const
Definition: BitmapColor.hxx:61
BitmapEx TransformBitmapEx(double fWidth, double fHeight, const basegfx::B2DHomMatrix &rTransformation) const
Create transformed Bitmap.
Definition: bitmapex.cxx:903
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
sal_uInt8 GetRed() const
void SetTransparency(sal_uInt8 nTransparency)
void SetSizePixel(const Size &rNewSize)
Definition: bitmapex.cxx:309
double getHeight() const
tools::Rectangle & Intersection(const tools::Rectangle &rRect)
Scanline GetScanline(long nY) const
OUString DetermineIconTheme() const
Determine which icon theme should be used.
bool Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, short nChannelGPercent, short nChannelBPercent, double fGamma=1.0, bool bInvert=false, bool msoBrightness=false)
Change various global color characteristics.
Definition: bitmapex.cxx:604
void Replace(const Color &rSearchColor, const Color &rReplaceColor)
Replace all pixel having the search color with the specified color.
Definition: bitmapex.cxx:592
Bitmap maMask
Definition: bitmapex.hxx:475
void Merge(const Color &rMergeColor, sal_uInt8 cTransparency)
BitmapEx createBlendFrame(const Size &rSize, sal_uInt8 nAlpha, Color aColorTopLeft, Color aColorBottomRight)
Create a blend frame as BitmapEx.
Definition: bitmapex.cxx:1166
static bool more(const double &rfValA, const double &rfValB)
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
Definition: button.hxx:32
long Height() const
signed char sal_Int8
TransparentType
Definition: bitmapex.hxx:36
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
BitmapEx m_aLastResult
Definition: svdata.hxx:350
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: bitmapex.cxx:366
sal_uInt8 GetTransparency() const
sal_uIntPtr sal_uLong
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:715
tools::Polygon GetContour(bool bContourEdgeDetect, const tools::Rectangle *pWorkRect)
Get contours in image.
Definition: bitmapex.cxx:1440
void Expand(sal_uLong nDX, sal_uLong nDY, bool bExpandTransparent=false)
Expand the bitmap by pixel padding.
Definition: bitmapex.cxx:455
BitmapEx getTransformed(const basegfx::B2DHomMatrix &rTransformation, const basegfx::B2DRange &rVisibleRange, double fMaximumArea) const
Create transformed Bitmap.
Definition: bitmapex.cxx:934
constexpr std::underlying_type_t< T > underlyingEnumValue(T e)
sal_uInt16 GetBitCount() const
B2DVector getRange() const
void SetSize(sal_uInt16 nNewSize)
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
Definition: checksum.hxx:72
BitmapReadAccess * AcquireReadAccess()
SAL_DLLPRIVATE void ImplSetBitmap(const Bitmap &rBitmap)
Definition: alpha.cxx:63
Size GetSizePixel() const
Size m_aLastSize
Definition: svdata.hxx:344
long Width() const
bool Expand(sal_uLong nDX, sal_uLong nDY, const Color *pInitColor=nullptr)
Expand the bitmap by pixel padding.
float x
BlendFrameCache * ImplGetBlendFrameCache()
Definition: svdata.cxx:317
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Definition: bitmapex.cxx:450
BitmapChecksum GetChecksum() const
Definition: bitmapex.cxx:288
static Bitmap DetectEdges(const Bitmap &rBmp)
Definition: bitmapex.cxx:1347
Size maBitmapSize
Definition: bitmapex.hxx:476
void Scale(double fScaleX, double fScaleY)
sal_uInt8 SVBT32[4]
static BitmapEx AutoScaleBitmap(BitmapEx const &aBitmap, const long aStandardSize)
Definition: bitmapex.cxx:624
NONE
const Size & GetPrefSize() const
Definition: bitmap.hxx:566
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1060
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
static VCL_DLLPUBLIC ImageTree & get()
Definition: ImageTree.cxx:16
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
bool IsAlpha() const
Definition: bitmapex.cxx:222
bool CombineSimple(const Bitmap &rMask, BmpCombine eCombine)
Perform boolean operations with another bitmap.
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
double getWidth() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
BitmapEx & operator=(const BitmapEx &rBitmapEx)
class SAL_WARN_UNUSED UNLESS_MERGELIBS(BASEGFX_DLLPUBLIC) BColorModifier_black_and_white final class SAL_WARN_UNUSED UNLESS_MERGELIBS(BASEGFX_DLLPUBLIC) BColorModifier_gamma final class SAL_WARN_UNUSED UNLESS_MERGELIBS(BASEGFX_DLLPUBLIC) BColorModifier_RGBLuminanceContrast final typedef std::shared_ptr< BColorModifier > BColorModifierSharedPtr
bool HasGreyPalette8Bit() const
B2DHomMatrix createScaleB2DHomMatrix(double fScaleX, double fScaleY)
bool mbAlpha
Definition: bitmapex.hxx:479
int nCount
static bool Filter(BitmapEx &rBmpEx, BitmapFilter const &rFilter)
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
void SetPixelOnData(sal_uInt8 *pData, long nX, const BitmapColor &rBitmapColor)
void loadFromIconTheme(const OUString &rIconName)
Definition: bitmapex.cxx:96
sal_uInt8 m_nLastAlpha
Definition: svdata.hxx:345
sal_uInt8 GetBlue() const
B2IRange fround(const B2DRange &rRange)
void Clear()
Definition: bitmapex.cxx:212
float y
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
Definition: bitmapex.cxx:329
void CombineMaskOr(Color maskColor, sal_uInt8 nTol)
Definition: bitmapex.cxx:1615
BitmapEx ModifyBitmapEx(const basegfx::BColorModifierStack &rBColorModifierStack) const
Create ColorStack-modified version of this BitmapEx.
Definition: bitmapex.cxx:1015
Color m_aLastColorTopRight
Definition: svdata.hxx:347
void AdjustTransparency(sal_uInt8 cTrans)
Definition: bitmapex.cxx:1558
void Invert()
void SetEmpty()
Definition: bitmapex.cxx:204
bool IsEmpty() const
Definition: bitmapex.cxx:199
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76
const MapMode & GetPrefMapMode() const
Definition: bitmap.hxx:556
VCL_DLLPUBLIC bool loadImage(OUString const &name, OUString const &style, BitmapEx &bitmap, bool localized, const ImageLoadFlags eFlags=ImageLoadFlags::NONE)
Definition: ImageTree.cxx:45
void SetPrefMapMode(const MapMode &rMapMode)
Definition: bitmap.hxx:561
bool Create(const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas, const Size &rSize)
populate from a canvas implementation
Definition: bitmapex.cxx:770
#define BITMAP_CHECKSUM_SIZE
Definition: checksum.hxx:28
Bitmap maBitmap
Definition: bitmapex.hxx:474
sal_uInt8 * Scanline
Definition: Scanline.hxx:25
Color m_aLastColorTopLeft
Definition: svdata.hxx:346
int i
bool HasPalette() const
uno_Any a
ScanlineFormat GetScanlineFormat() const
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
Color m_aLastColorBottomRight
Definition: svdata.hxx:348
BitmapChecksum GetChecksum() const
bool Invert()
Perform the Invert operation on every pixel.
Definition: bitmapex.cxx:314
sal_uLong GetSizeBytes() const
Definition: bitmap.hxx:581
#define F_2PI
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
sal_uLong GetSizeBytes() const
Definition: bitmapex.cxx:278
::rtl::Reference< Content > pContent
BmpMirrorFlags
Definition: bitmap.hxx:36
bool Invert()
Perform the Invert operation on every pixel.
Definition: bitmappaint.cxx:64
BmpScaleFlag
Definition: bitmap.hxx:48
static void ReleaseAccess(BitmapInfoAccess *pAccess)
::Color GetPixelColor(sal_Int32 nX, sal_Int32 nY) const
Get pixel color (including alpha) at given position.
Definition: bitmapex.cxx:748
bool CopyPixel(const tools::Rectangle &rRectDst, const tools::Rectangle &rRectSrc, const BitmapEx *pBmpExSrc)
Copy a rectangular area from another bitmap.
Definition: bitmapex.cxx:476
BmpConversion
Definition: bitmap.hxx:65
bool IsTransparent() const
Definition: bitmapex.cxx:217
const Bitmap & GetBitmap() const
Gives direct access to the contained bitmap.
Definition: bitmapex.cxx:227
bool CopyPixel_AlphaOptimized(const tools::Rectangle &rRectDst, const tools::Rectangle &rRectSrc, const Bitmap *pBmpSrc)
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
Definition: bitmapex.cxx:613
BitmapColor GetPixel(long nY, long nX) const
sal_uInt16 GetPaletteEntryCount() const
void SetIndex(sal_uInt8 cIndex)
Definition: BitmapColor.hxx:66
void SetEmpty()
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: bitmapex.cxx:232
sal_uInt8 GetGreen() const
SAL_DLLPRIVATE const Bitmap & ImplGetBitmap() const
Definition: alpha.cxx:58
double getMinY() const
bool Rotate(long nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
virtual std::shared_ptr< SalBitmap > CreateSalBitmap()=0
AlphaMask GetAlpha() const
Definition: bitmapex.cxx:264
long Height() const
#define SAL_WARN_IF(condition, area, stream)
unsigned char sal_uInt8
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: bitmap3.cxx:764
void BCToBCOA(BitmapChecksum n, BitmapChecksumOctetArray p)
Definition: checksum.hxx:34
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Definition: bitmap3.cxx:229
BitmapColor GetColor(long nY, long nX) const
const BitmapPalette & GetPalette() const
B2DPoint getMinimum() const
bool IsEmpty() const
Definition: bitmap.hxx:551
void GetColorModel(css::uno::Sequence< sal_Int32 > &rRGBPalette, sal_uInt32 &rnRedMask, sal_uInt32 &rnGreenMask, sal_uInt32 &rnBlueMask, sal_uInt32 &rnAlphaMask, sal_uInt32 &rnTransparencyIndex, sal_uInt32 &rnWidth, sal_uInt32 &rnHeight, sal_uInt8 &rnBitCount)
Retrieves the color model data we need for the XImageConsumer stuff.
Definition: bitmapex.cxx:1627
BitmapEx()
Definition: bitmapex.cxx:51
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
void translate(double fX, double fY)
BitmapColor GetPixelFromData(const sal_uInt8 *pData, long nX) const
void AdaptBitCount(Bitmap &rNew) const
Definition: bitmap3.cxx:794
TransparentType meTransparent
Definition: bitmapex.hxx:478
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
Definition: bitmappaint.cxx:34
uno::Reference< ucb::XContent > xContent
void setAlphaFrom(sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo)
Definition: bitmapex.cxx:1536
#define SAL_WARN(area, stream)
sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE]
Definition: checksum.hxx:31
double getMinX() const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
void ReplaceTransparency(const Color &rColor)
Replace transparency with given color.
Definition: bitmapex.cxx:1334
sal_uInt16 GetBitCount() const
bool CopyPixel(const tools::Rectangle &rRectDst, const tools::Rectangle &rRectSrc, const Bitmap *pBmpSrc=nullptr)
Copy a rectangular area from another bitmap.
bool Replace(const Bitmap &rMask, const Color &rReplaceColor)
Replace all pixel where the given mask is on with the specified color.
const Size & GetSizePixel() const
Definition: bitmapex.hxx:83
Color maTransparentColor
Definition: bitmapex.hxx:477
sal_uInt8 GetTransparency(sal_Int32 nX, sal_Int32 nY) const
Get transparency at given position.
Definition: bitmapex.cxx:680
BitmapColor GetBestMatchingColor(const BitmapColor &rBitmapColor)
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
Definition: bitmapex.cxx:430
Bitmap CreateMask(const Color &rTransColor, sal_uInt8 nTol=0) const
Create on-off mask from bitmap.
void SetPaletteColor(sal_uInt16 nColor, const BitmapColor &rBitmapColor)
SalInstance * mpDefInst
Definition: svdata.hxx:381
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, long nX) const
bool Rotate(long nAngle10, const Color &rFillColor)
Rotate bitmap by the specified angle.
Definition: bitmapex.cxx:386