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 void ClearAlpha();
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 const AlphaMask & GetAlphaMask() const { return maAlphaMask; }
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 ChangeColorAlpha( 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
454 void DumpAsPng(const char* pFileName = nullptr) const;
455
456private:
457 friend class ImpGraphic;
458 friend class OutputDevice;
459 friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm);
460 friend bool VCL_DLLPUBLIC ReadRawDIB(BitmapEx& rTarget, const unsigned char* pBuf,
461 const ScanlineFormat nFormat,
462 const int nHeight,
463 const int nStride);
464
465 void loadFromIconTheme( const OUString& rIconName );
466
470};
471
472
487 const Size& rSize,
488 sal_uInt8 nAlpha,
489 Color aColorTopLeft,
490 Color aColorBottomRight);
491
492
506 const Size& rSize,
507 sal_uInt8 nAlpha,
508 Color aColorTopLeft,
509 Color aColorTopRight,
510 Color aColorBottomRight,
511 Color aColorBottomLeft);
512
513#endif // INCLUDED_VCL_BITMAPEX_HXX
514
515/* 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:1003
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
Bitmap maBitmap
Definition: bitmapex.hxx:467
BitmapEx & operator=(const Bitmap &rBitmap)
Definition: bitmapex.hxx:52
const AlphaMask & GetAlphaMask() const
Definition: bitmapex.hxx:71
BitmapEx & operator=(const BitmapEx &rBitmapEx)
void SetPrefMapMode(const MapMode &rPrefMapMode)
Definition: bitmapex.hxx:80
vcl::PixelFormat getPixelFormat() const
Definition: bitmapex.hxx:82
bool operator!=(const BitmapEx &rBitmapEx) const
Definition: bitmapex.hxx:54
SAL_DLLPRIVATE std::shared_ptr< SalBitmap > const & ImplGetBitmapSalBitmap() const
Definition: bitmapex.hxx:451
Size maBitmapSize
Definition: bitmapex.hxx:469
void SetPrefSize(const Size &rPrefSize)
Definition: bitmapex.hxx:77
BitmapEx(const BitmapEx &rBitmapEx)
const MapMode & GetPrefMapMode() const
Definition: bitmapex.hxx:79
const Size & GetPrefSize() const
Definition: bitmapex.hxx:76
const Size & GetSizePixel() const
Definition: bitmapex.hxx:73
AlphaMask maAlphaMask
Definition: bitmapex.hxx:468
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:1742
bool ReadRawDIB(BitmapEx &rTarget, const unsigned char *pBuf, const ScanlineFormat nFormat, const int nHeight, const int nStride)
Definition: dibtools.cxx:1709
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
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:175