LibreOffice Module vcl (master)  1
bitmapex.hxx
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 #ifndef INCLUDED_VCL_BITMAPEX_HXX
21 #define INCLUDED_VCL_BITMAPEX_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <vcl/alpha.hxx>
25 #include <vcl/Scanline.hxx>
26 #include <tools/color.hxx>
27 #include <tools/degree.hxx>
28 
29 #include <sal/types.h>
30 
31 namespace com::sun::star::rendering {
32  class XBitmapCanvas;
33 }
34 namespace com::sun::star::uno { template <class interface_type> class Reference; }
35 namespace basegfx { class BColorModifierStack; }
36 
38 {
39 public:
40 
41  BitmapEx();
42  explicit BitmapEx( const OUString& rIconName );
43  BitmapEx( const BitmapEx& rBitmapEx );
44  BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize );
45  BitmapEx(Size aSize, vcl::PixelFormat ePixelFormat);
46  explicit BitmapEx( const Bitmap& rBmp );
47  BitmapEx( const Bitmap& rBmp, const Bitmap& rMask );
48  BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask );
49  BitmapEx( const Bitmap& rBmp, const Color& rTransparentColor );
50 
51  BitmapEx& operator=( const BitmapEx& rBitmapEx );
52  BitmapEx& operator=( const Bitmap& rBitmap ) { return operator=(BitmapEx(rBitmap)); }
53  bool operator==( const BitmapEx& rBitmapEx ) const;
54  bool operator!=( const BitmapEx& rBitmapEx ) const { return !(*this==rBitmapEx); }
55 
56  bool IsEmpty() const;
57  void SetEmpty();
58  void Clear();
59 
60  void Draw( OutputDevice* pOutDev,
61  const Point& rDestPt ) const;
62  void Draw( OutputDevice* pOutDev,
63  const Point& rDestPt, const Size& rDestSize ) const;
64 
65  Bitmap GetBitmap( Color aTransparentReplaceColor ) const;
67  const Bitmap& GetBitmap() const;
68 
69  bool IsAlpha() const;
70  AlphaMask GetAlpha() const;
71 
72  const Size& GetSizePixel() const { return maBitmapSize; }
73  void SetSizePixel(const Size& rNewSize);
74 
75  const Size& GetPrefSize() const { return maBitmap.GetPrefSize(); }
76  void SetPrefSize( const Size& rPrefSize ) { maBitmap.SetPrefSize( rPrefSize ); }
77 
78  const MapMode& GetPrefMapMode() const { return maBitmap.GetPrefMapMode(); }
79  void SetPrefMapMode( const MapMode& rPrefMapMode ) { maBitmap.SetPrefMapMode( rPrefMapMode ); }
80 
82  {
83  return maBitmap.getPixelFormat();
84  }
85 
86  sal_Int64 GetSizeBytes() const;
87  BitmapChecksum GetChecksum() const;
88 
96  bool Convert( BmpConversion eConversion );
97 
112  bool Crop( const tools::Rectangle& rRectPixel );
113 
125  void Expand(
126  sal_Int32 nDX, sal_Int32 nDY,
127  bool bExpandTransparent = false );
128 
151  bool CopyPixel(
152  const tools::Rectangle& rRectDst,
153  const tools::Rectangle& rRectSrc,
154  const BitmapEx* pBmpExSrc );
155 
164  bool Erase( const Color& rFillColor );
165 
170  bool Invert();
171 
179  bool Mirror( BmpMirrorFlags nMirrorFlags );
180 
191  bool Scale(
192  const Size& rNewSize,
193  BmpScaleFlag nScaleFlag = BmpScaleFlag::Default );
194 
208  bool Scale(
209  const double& rScaleX,
210  const double& rScaleY,
211  BmpScaleFlag nScaleFlag = BmpScaleFlag::Default );
212 
226  bool Rotate(
227  Degree10 nAngle10,
228  const Color& rFillColor );
229 
238  void Replace(
239  const Color& rSearchColor,
240  const Color& rReplaceColor );
241 
255  void Replace(
256  const Color& rSearchColor,
257  const Color& rReplaceColor,
258  sal_uInt8 nTolerance );
259 
276  void Replace(
277  const Color* pSearchColors,
278  const Color* pReplaceColors,
279  size_t nColorCount );
280 
299  void Replace(
300  const Color* pSearchColors,
301  const Color* pReplaceColors,
302  size_t nColorCount,
303  sal_uInt8 const * pTols );
304 
307  void ReplaceTransparency( const Color& rColor );
308 
310  tools::Polygon GetContour( bool bContourEdgeDetect, const tools::Rectangle* pWorkRect );
311 
342  bool Adjust(
343  short nLuminancePercent,
344  short nContrastPercent,
345  short nChannelRPercent,
346  short nChannelGPercent,
347  short nChannelBPercent,
348  double fGamma = 1.0,
349  bool bInvert = false,
350  bool msoBrightness = false );
351 
363  sal_uInt8 GetAlpha(
364  sal_Int32 nX,
365  sal_Int32 nY) const;
366 
375  ::Color GetPixelColor(
376  sal_Int32 nX,
377  sal_Int32 nY) const;
378 
391  [[nodiscard]]
392  BitmapEx TransformBitmapEx(
393  double fWidth,
394  double fHeight,
395  const basegfx::B2DHomMatrix& rTransformation) const;
396 
415  [[nodiscard]]
416  BitmapEx getTransformed(
417  const basegfx::B2DHomMatrix& rTransformation,
418  const basegfx::B2DRange& rVisibleRange,
419  double fMaximumArea) const;
420 
426  [[nodiscard]]
427  BitmapEx ModifyBitmapEx( const basegfx::BColorModifierStack& rBColorModifierStack) const;
428 
429  [[nodiscard]]
430  static BitmapEx AutoScaleBitmap( BitmapEx const & aBitmap, const tools::Long aStandardSize );
431 
433  bool Create(
434  const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas,
435  const Size &rSize );
436 
437  void setAlphaFrom( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo );
438 
439  void AdjustTransparency( sal_uInt8 cTrans );
440 
441  void CombineMaskOr(Color maskColor, sal_uInt8 nTol);
442 
446  void GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
447  sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex,
448  sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount);
449 
450  SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetBitmapSalBitmap() const { return maBitmap.ImplGetSalBitmap(); }
451 
452 
453 private:
454  friend class ImpGraphic;
455  friend class OutputDevice;
456  friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm);
457  friend bool VCL_DLLPUBLIC ReadRawDIB(BitmapEx& rTarget, const unsigned char* pBuf,
458  const ScanlineFormat nFormat,
459  const int nHeight,
460  const int nStride);
461 
462  void loadFromIconTheme( const OUString& rIconName );
463 
467 };
468 
469 
484  const Size& rSize,
485  sal_uInt8 nAlpha,
486  Color aColorTopLeft,
487  Color aColorBottomRight);
488 
489 
503  const Size& rSize,
504  sal_uInt8 nAlpha,
505  Color aColorTopLeft,
506  Color aColorTopRight,
507  Color aColorBottomRight,
508  Color aColorBottomLeft);
509 
510 #endif // INCLUDED_VCL_BITMAPEX_HXX
511 
512 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:19
BitmapEx & operator=(const Bitmap &rBitmap)
Definition: bitmapex.hxx:52
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
const MapMode & GetPrefMapMode() const
Definition: bitmapex.hxx:78
signed char sal_Int8
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
void SetPrefMapMode(const MapMode &rPrefMapMode)
Definition: bitmapex.hxx:79
Reference
Size maBitmapSize
Definition: bitmapex.hxx:466
ScanlineFormat
Definition: Scanline.hxx:29
const Size & GetPrefSize() const
Definition: bitmapex.hxx:75
bool operator!=(const BitmapEx &rBitmapEx) const
Definition: bitmapex.hxx:54
Point Rotate(const Point &rPoint, Degree10 nOrientation, const Point &rOrigin)
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:202
Bitmap maBitmap
Definition: bitmapex.hxx:464
bool WriteDIBBitmapEx(const BitmapEx &rSource, SvStream &rOStm)
Definition: dibtools.cxx:1849
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:175
Bitmap maAlphaMask
Definition: bitmapex.hxx:465
void Clear(EHistoryType eHistory)
SAL_DLLPRIVATE std::shared_ptr< SalBitmap > const & ImplGetBitmapSalBitmap() const
Definition: bitmapex.hxx:450
#define SAL_WARN_UNUSED
unsigned char sal_uInt8
BitmapEx VCL_DLLPUBLIC createBlendFrame(const Size &rSize, sal_uInt8 nAlpha, Color aColorTopLeft, Color aColorBottomRight)
Create a blend frame as BitmapEx.
Definition: BitmapEx.cxx:1000
void SetPrefSize(const Size &rPrefSize)
Definition: bitmapex.hxx:76
const Size & GetSizePixel() const
Definition: bitmapex.hxx:72
vcl::PixelFormat getPixelFormat() const
Definition: bitmapex.hxx:81
bool ReadRawDIB(BitmapEx &rTarget, const unsigned char *pBuf, const ScanlineFormat nFormat, const int nHeight, const int nStride)
Definition: dibtools.cxx:1816
BmpMirrorFlags