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
32 class XBitmapCanvas;
33}
34namespace com::sun::star::uno { template <class interface_type> class Reference; }
35namespace basegfx { class BColorModifierStack; }
36
38{
39public:
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 const AlphaMask & GetAlphaMask() const { return maAlphaMask; }
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 ChangeColorAlpha( 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
453 void DumpAsPng(const char* pFileName = nullptr) const;
454
455private:
456 friend class ImpGraphic;
457 friend class OutputDevice;
458 friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm);
459 friend bool VCL_DLLPUBLIC ReadRawDIB(BitmapEx& rTarget, const unsigned char* pBuf,
460 const ScanlineFormat nFormat,
461 const int nHeight,
462 const int nStride);
463
464 void loadFromIconTheme( const OUString& rIconName );
465
469};
470
471
486 const Size& rSize,
487 sal_uInt8 nAlpha,
488 Color aColorTopLeft,
489 Color aColorBottomRight);
490
491
505 const Size& rSize,
506 sal_uInt8 nAlpha,
507 Color aColorTopLeft,
508 Color aColorTopRight,
509 Color aColorBottomRight,
510 Color aColorBottomLeft);
511
512#endif // INCLUDED_VCL_BITMAPEX_HXX
513
514/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScanlineFormat
Definition: Scanline.hxx:29
BitmapEx VCL_DLLPUBLIC createBlendFrame(const Size &rSize, sal_uInt8 nAlpha, Color aColorTopLeft, Color aColorBottomRight)
Create a blend frame as BitmapEx.
Definition: BitmapEx.cxx:989
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
Bitmap maBitmap
Definition: bitmapex.hxx:466
BitmapEx & operator=(const Bitmap &rBitmap)
Definition: bitmapex.hxx:52
const AlphaMask & GetAlphaMask() const
Definition: bitmapex.hxx:70
BitmapEx & operator=(const BitmapEx &rBitmapEx)
void SetPrefMapMode(const MapMode &rPrefMapMode)
Definition: bitmapex.hxx:79
vcl::PixelFormat getPixelFormat() const
Definition: bitmapex.hxx:81
bool operator!=(const BitmapEx &rBitmapEx) const
Definition: bitmapex.hxx:54
SAL_DLLPRIVATE std::shared_ptr< SalBitmap > const & ImplGetBitmapSalBitmap() const
Definition: bitmapex.hxx:450
Size maBitmapSize
Definition: bitmapex.hxx:468
void SetPrefSize(const Size &rPrefSize)
Definition: bitmapex.hxx:76
BitmapEx(const BitmapEx &rBitmapEx)
const MapMode & GetPrefMapMode() const
Definition: bitmapex.hxx:78
const Size & GetPrefSize() const
Definition: bitmapex.hxx:75
const Size & GetSizePixel() const
Definition: bitmapex.hxx:72
AlphaMask maAlphaMask
Definition: bitmapex.hxx:467
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
bool WriteDIBBitmapEx(const BitmapEx &rSource, SvStream &rOStm)
Definition: dibtools.cxx:1751
bool ReadRawDIB(BitmapEx &rTarget, const unsigned char *pBuf, const ScanlineFormat nFormat, const int nHeight, const int nStride)
Definition: dibtools.cxx:1718
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
Point Rotate(const Point &rPoint, Degree10 nOrientation, const Point &rOrigin)
BmpMirrorFlags
void Clear(EHistoryType eHistory)
Reference
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
long Long
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:20
unsigned char sal_uInt8
signed char sal_Int8
#define SAL_WARN_UNUSED
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:170