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 #include <tools/solar.h>
29 
30 #include <sal/types.h>
31 
32 namespace com::sun::star::rendering {
33  class XBitmapCanvas;
34 }
35 namespace com::sun::star::uno { template <class interface_type> class Reference; }
36 namespace basegfx { class BColorModifierStack; }
37 
39 {
40 public:
41 
42  BitmapEx();
43  explicit BitmapEx( const OUString& rIconName );
44  BitmapEx( const BitmapEx& rBitmapEx );
45  BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize );
46  BitmapEx(Size aSize, vcl::PixelFormat ePixelFormat);
47  explicit BitmapEx( const Bitmap& rBmp );
48  BitmapEx( const Bitmap& rBmp, const Bitmap& rMask );
49  BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask );
50  BitmapEx( const Bitmap& rBmp, const Color& rTransparentColor );
51 
52  BitmapEx& operator=( const BitmapEx& rBitmapEx );
53  BitmapEx& operator=( const Bitmap& rBitmap ) { return operator=(BitmapEx(rBitmap)); }
54  bool operator==( const BitmapEx& rBitmapEx ) const;
55  bool operator!=( const BitmapEx& rBitmapEx ) const { return !(*this==rBitmapEx); }
56 
57  bool IsEmpty() const;
58  void SetEmpty();
59  void Clear();
60 
61  void Draw( OutputDevice* pOutDev,
62  const Point& rDestPt ) const;
63  void Draw( OutputDevice* pOutDev,
64  const Point& rDestPt, const Size& rDestSize ) const;
65 
66  Bitmap GetBitmap( Color aTransparentReplaceColor ) const;
68  const Bitmap& GetBitmap() const;
69 
70  bool IsAlpha() const;
71  AlphaMask GetAlpha() const;
72 
73  const Size& GetSizePixel() const { return maBitmapSize; }
74  void SetSizePixel(const Size& rNewSize);
75 
76  const Size& GetPrefSize() const { return maBitmap.GetPrefSize(); }
77  void SetPrefSize( const Size& rPrefSize ) { maBitmap.SetPrefSize( rPrefSize ); }
78 
79  const MapMode& GetPrefMapMode() const { return maBitmap.GetPrefMapMode(); }
80  void SetPrefMapMode( const MapMode& rPrefMapMode ) { maBitmap.SetPrefMapMode( rPrefMapMode ); }
81 
83  {
84  return maBitmap.getPixelFormat();
85  }
86 
87  sal_Int64 GetSizeBytes() const;
88  BitmapChecksum GetChecksum() const;
89 
97  bool Convert( BmpConversion eConversion );
98 
113  bool Crop( const tools::Rectangle& rRectPixel );
114 
126  void Expand(
127  sal_Int32 nDX, sal_Int32 nDY,
128  bool bExpandTransparent = false );
129 
152  bool CopyPixel(
153  const tools::Rectangle& rRectDst,
154  const tools::Rectangle& rRectSrc,
155  const BitmapEx* pBmpExSrc );
156 
165  bool Erase( const Color& rFillColor );
166 
171  bool Invert();
172 
180  bool Mirror( BmpMirrorFlags nMirrorFlags );
181 
192  bool Scale(
193  const Size& rNewSize,
194  BmpScaleFlag nScaleFlag = BmpScaleFlag::Default );
195 
209  bool Scale(
210  const double& rScaleX,
211  const double& rScaleY,
212  BmpScaleFlag nScaleFlag = BmpScaleFlag::Default );
213 
227  bool Rotate(
228  Degree10 nAngle10,
229  const Color& rFillColor );
230 
239  void Replace(
240  const Color& rSearchColor,
241  const Color& rReplaceColor );
242 
256  void Replace(
257  const Color& rSearchColor,
258  const Color& rReplaceColor,
259  sal_uInt8 nTolerance );
260 
277  void Replace(
278  const Color* pSearchColors,
279  const Color* pReplaceColors,
280  size_t nColorCount );
281 
300  void Replace(
301  const Color* pSearchColors,
302  const Color* pReplaceColors,
303  size_t nColorCount,
304  sal_uInt8 const * pTols );
305 
308  void ReplaceTransparency( const Color& rColor );
309 
311  tools::Polygon GetContour( bool bContourEdgeDetect, const tools::Rectangle* pWorkRect );
312 
343  bool Adjust(
344  short nLuminancePercent,
345  short nContrastPercent,
346  short nChannelRPercent,
347  short nChannelGPercent,
348  short nChannelBPercent,
349  double fGamma = 1.0,
350  bool bInvert = false,
351  bool msoBrightness = false );
352 
364  sal_uInt8 GetAlpha(
365  sal_Int32 nX,
366  sal_Int32 nY) const;
367 
376  ::Color GetPixelColor(
377  sal_Int32 nX,
378  sal_Int32 nY) const;
379 
392  [[nodiscard]]
393  BitmapEx TransformBitmapEx(
394  double fWidth,
395  double fHeight,
396  const basegfx::B2DHomMatrix& rTransformation) const;
397 
416  [[nodiscard]]
417  BitmapEx getTransformed(
418  const basegfx::B2DHomMatrix& rTransformation,
419  const basegfx::B2DRange& rVisibleRange,
420  double fMaximumArea) const;
421 
427  [[nodiscard]]
428  BitmapEx ModifyBitmapEx( const basegfx::BColorModifierStack& rBColorModifierStack) const;
429 
430  [[nodiscard]]
431  static BitmapEx AutoScaleBitmap( BitmapEx const & aBitmap, const tools::Long aStandardSize );
432 
434  bool Create(
435  const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas,
436  const Size &rSize );
437 
438  void setAlphaFrom( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo );
439 
440  void AdjustTransparency( sal_uInt8 cTrans );
441 
442  void CombineMaskOr(Color maskColor, sal_uInt8 nTol);
443 
447  void GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
448  sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex,
449  sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount);
450 
451  SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetBitmapSalBitmap() const { return maBitmap.ImplGetSalBitmap(); }
452 
453 
454 private:
455  friend class ImpGraphic;
456  friend class OutputDevice;
457  friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm);
458  friend bool VCL_DLLPUBLIC ReadRawDIB(BitmapEx& rTarget, const unsigned char* pBuf,
459  const ScanlineFormat nFormat,
460  const int nHeight,
461  const int nStride);
462 
463  void loadFromIconTheme( const OUString& rIconName );
464 
468 };
469 
470 
485  const Size& rSize,
486  sal_uInt8 nAlpha,
487  Color aColorTopLeft,
488  Color aColorBottomRight);
489 
490 
504  const Size& rSize,
505  sal_uInt8 nAlpha,
506  Color aColorTopLeft,
507  Color aColorTopRight,
508  Color aColorBottomRight,
509  Color aColorBottomLeft);
510 
511 #endif // INCLUDED_VCL_BITMAPEX_HXX
512 
513 /* 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:53
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
const MapMode & GetPrefMapMode() const
Definition: bitmapex.hxx:79
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:80
Reference
Size maBitmapSize
Definition: bitmapex.hxx:467
ScanlineFormat
Definition: Scanline.hxx:29
const Size & GetPrefSize() const
Definition: bitmapex.hxx:76
bool operator!=(const BitmapEx &rBitmapEx) const
Definition: bitmapex.hxx:55
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:465
bool WriteDIBBitmapEx(const BitmapEx &rSource, SvStream &rOStm)
Definition: dibtools.cxx:1835
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
Bitmap maAlphaMask
Definition: bitmapex.hxx:466
void Clear(EHistoryType eHistory)
SAL_DLLPRIVATE std::shared_ptr< SalBitmap > const & ImplGetBitmapSalBitmap() const
Definition: bitmapex.hxx:451
#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:77
const Size & GetSizePixel() const
Definition: bitmapex.hxx:73
vcl::PixelFormat getPixelFormat() const
Definition: bitmapex.hxx:82
bool ReadRawDIB(BitmapEx &rTarget, const unsigned char *pBuf, const ScanlineFormat nFormat, const int nHeight, const int nStride)
Definition: dibtools.cxx:1802
BmpMirrorFlags