diff options
Diffstat (limited to '')
-rw-r--r-- | vcl/inc/bitmap/Octree.hxx | 82 | ||||
-rw-r--r-- | vcl/inc/bitmap/ScanlineTools.hxx | 236 | ||||
-rw-r--r-- | vcl/inc/bitmap/impoctree.hxx | 109 | ||||
-rw-r--r-- | vcl/inc/bitmaps.hlst | 228 | ||||
-rw-r--r-- | vcl/inc/bitmapwriteaccess.hxx | 94 |
5 files changed, 749 insertions, 0 deletions
diff --git a/vcl/inc/bitmap/Octree.hxx b/vcl/inc/bitmap/Octree.hxx new file mode 100644 index 000000000..f1d6e2a58 --- /dev/null +++ b/vcl/inc/bitmap/Octree.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_OCTREE_HXX +#define INCLUDED_VCL_INC_OCTREE_HXX + +#include <vcl/dllapi.h> +#include <vcl/BitmapColor.hxx> + +struct OctreeNode +{ + sal_uLong nCount = 0; + sal_uLong nRed = 0; + sal_uLong nGreen = 0; + sal_uLong nBlue = 0; + std::unique_ptr<OctreeNode> pChild[8]; + OctreeNode* pNext = nullptr; + sal_uInt16 nPalIndex = 0; + bool bLeaf = false; +}; + +class BitmapReadAccess; + +class VCL_PLUGIN_PUBLIC Octree +{ +private: + void CreatePalette(OctreeNode* pNode); + void GetPalIndex(const OctreeNode* pNode); + + SAL_DLLPRIVATE void add(std::unique_ptr<OctreeNode>& rpNode); + SAL_DLLPRIVATE void reduce(); + + BitmapPalette maPalette; + sal_uLong mnLeafCount; + sal_uLong mnLevel; + std::unique_ptr<OctreeNode> pTree; + std::vector<OctreeNode*> mpReduce; + BitmapColor const* mpColor; + sal_uInt16 mnPalIndex; + +public: + Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors); + ~Octree(); + + const BitmapPalette& GetPalette(); + sal_uInt16 GetBestPaletteIndex(const BitmapColor& rColor); +}; + +class InverseColorMap +{ +private: + std::vector<sal_uInt8> mpBuffer; + std::vector<sal_uInt8> mpMap; + + void ImplCreateBuffers(); + +public: + explicit InverseColorMap(const BitmapPalette& rPal); + ~InverseColorMap(); + + sal_uInt16 GetBestPaletteIndex(const BitmapColor& rColor); +}; + +#endif // INCLUDED_VCL_INC_OCTREE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx new file mode 100644 index 000000000..9528f4809 --- /dev/null +++ b/vcl/inc/bitmap/ScanlineTools.hxx @@ -0,0 +1,236 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef INCLUDED_VCL_INC_BITMAP_SCANLINETOOLS_HXX +#define INCLUDED_VCL_INC_BITMAP_SCANLINETOOLS_HXX + +#include <tools/color.hxx> +#include <vcl/BitmapPalette.hxx> + +namespace vcl::bitmap +{ +class ScanlineTransformer +{ +public: + virtual void startLine(sal_uInt8* pLine) = 0; + virtual void skipPixel(sal_uInt32 nPixel) = 0; + virtual Color readPixel() = 0; + virtual void writePixel(Color nColor) = 0; + + virtual ~ScanlineTransformer() = default; +}; + +class ScanlineTransformer_ARGB final : public ScanlineTransformer +{ +private: + sal_uInt8* pData; + +public: + virtual void startLine(sal_uInt8* pLine) override { pData = pLine; } + + virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel << 2; } + + virtual Color readPixel() override + { + const Color aColor(pData[4], pData[1], pData[2], pData[3]); + pData += 4; + return aColor; + } + + virtual void writePixel(Color nColor) override + { + *pData++ = nColor.GetTransparency(); + *pData++ = nColor.GetRed(); + *pData++ = nColor.GetGreen(); + *pData++ = nColor.GetBlue(); + } +}; + +class ScanlineTransformer_BGR final : public ScanlineTransformer +{ +private: + sal_uInt8* pData; + +public: + virtual void startLine(sal_uInt8* pLine) override { pData = pLine; } + + virtual void skipPixel(sal_uInt32 nPixel) override { pData += (nPixel << 1) + nPixel; } + + virtual Color readPixel() override + { + const Color aColor(pData[2], pData[1], pData[0]); + pData += 3; + return aColor; + } + + virtual void writePixel(Color nColor) override + { + *pData++ = nColor.GetBlue(); + *pData++ = nColor.GetGreen(); + *pData++ = nColor.GetRed(); + } +}; + +class ScanlineTransformer_8BitPalette final : public ScanlineTransformer +{ +private: + sal_uInt8* pData; + const BitmapPalette& mrPalette; + +public: + explicit ScanlineTransformer_8BitPalette(const BitmapPalette& rPalette) + : pData(nullptr) + , mrPalette(rPalette) + { + } + + virtual void startLine(sal_uInt8* pLine) override { pData = pLine; } + + virtual void skipPixel(sal_uInt32 nPixel) override { pData += nPixel; } + + virtual Color readPixel() override + { + const sal_uInt8 nIndex(*pData++); + if (nIndex < mrPalette.GetEntryCount()) + return mrPalette[nIndex]; + else + return COL_BLACK; + } + + virtual void writePixel(Color nColor) override + { + *pData++ = static_cast<sal_uInt8>(mrPalette.GetBestIndex(nColor)); + } +}; + +class ScanlineTransformer_4BitPalette final : public ScanlineTransformer +{ +private: + sal_uInt8* pData; + const BitmapPalette& mrPalette; + sal_uInt32 mnX; + sal_uInt32 mnShift; + +public: + explicit ScanlineTransformer_4BitPalette(const BitmapPalette& rPalette) + : pData(nullptr) + , mrPalette(rPalette) + , mnX(0) + , mnShift(0) + { + } + + virtual void skipPixel(sal_uInt32 nPixel) override + { + mnX += nPixel; + if (nPixel & 1) // is nPixel an odd number + mnShift ^= 4; + } + + virtual void startLine(sal_uInt8* pLine) override + { + pData = pLine; + mnX = 0; + mnShift = 4; + } + + virtual Color readPixel() override + { + const sal_uInt32 nDataIndex = mnX / 2; + const sal_uInt8 nIndex((pData[nDataIndex] >> mnShift) & 0x0f); + mnX++; + mnShift ^= 4; + + if (nIndex < mrPalette.GetEntryCount()) + return mrPalette[nIndex]; + else + return COL_BLACK; + } + + virtual void writePixel(Color nColor) override + { + const sal_uInt32 nDataIndex = mnX / 2; + const sal_uInt8 nColorIndex = mrPalette.GetBestIndex(nColor); + pData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift; + mnX++; + mnShift ^= 4; + } +}; + +class ScanlineTransformer_1BitPalette final : public ScanlineTransformer +{ +private: + sal_uInt8* pData; + const BitmapPalette& mrPalette; + sal_uInt32 mnX; + +public: + explicit ScanlineTransformer_1BitPalette(const BitmapPalette& rPalette) + : pData(nullptr) + , mrPalette(rPalette) + , mnX(0) + { + } + + virtual void skipPixel(sal_uInt32 nPixel) override { mnX += nPixel; } + + virtual void startLine(sal_uInt8* pLine) override + { + pData = pLine; + mnX = 0; + } + + virtual Color readPixel() override + { + const sal_uInt8 nIndex((pData[mnX >> 3] >> (7 - (mnX & 7))) & 1); + mnX++; + + if (nIndex < mrPalette.GetEntryCount()) + return mrPalette[nIndex]; + else + return COL_BLACK; + } + + virtual void writePixel(Color nColor) override + { + if (mrPalette.GetBestIndex(nColor) & 1) + pData[mnX >> 3] |= 1 << (7 - (mnX & 7)); + else + pData[mnX >> 3] &= ~(1 << (7 - (mnX & 7))); + mnX++; + } +}; + +std::unique_ptr<ScanlineTransformer> getScanlineTransformer(sal_uInt16 nBits, + const BitmapPalette& rPalette) +{ + switch (nBits) + { + case 1: + return std::make_unique<ScanlineTransformer_1BitPalette>(rPalette); + case 4: + return std::make_unique<ScanlineTransformer_4BitPalette>(rPalette); + case 8: + return std::make_unique<ScanlineTransformer_8BitPalette>(rPalette); + case 24: + return std::make_unique<ScanlineTransformer_BGR>(); + case 32: + return std::make_unique<ScanlineTransformer_ARGB>(); + default: + assert(false); + break; + } + return nullptr; +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/bitmap/impoctree.hxx b/vcl/inc/bitmap/impoctree.hxx new file mode 100644 index 000000000..06fbd6924 --- /dev/null +++ b/vcl/inc/bitmap/impoctree.hxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_IMPOCTREE_HXX +#define INCLUDED_VCL_INC_IMPOCTREE_HXX + +#include "Octree.hxx" + +class ImpErrorQuad +{ + long nRed; + long nGreen; + long nBlue; + +public: + ImpErrorQuad() + : nRed(0) + , nGreen(0) + , nBlue(0) + { + } + + ImpErrorQuad(const BitmapColor& rColor) + : nRed(long(rColor.GetRed()) << 5) + , nGreen(long(rColor.GetGreen()) << 5) + , nBlue(long(rColor.GetBlue()) << 5) + { + } + + inline void operator=(const BitmapColor& rColor); + inline ImpErrorQuad& operator-=(const BitmapColor& rColor); + + inline void ImplAddColorError1(const ImpErrorQuad& rErrQuad); + inline void ImplAddColorError3(const ImpErrorQuad& rErrQuad); + inline void ImplAddColorError5(const ImpErrorQuad& rErrQuad); + inline void ImplAddColorError7(const ImpErrorQuad& rErrQuad); + + inline BitmapColor ImplGetColor(); +}; + +inline void ImpErrorQuad::operator=(const BitmapColor& rColor) +{ + nRed = long(rColor.GetRed()) << 5; + nGreen = long(rColor.GetGreen()) << 5; + nBlue = long(rColor.GetBlue()) << 5; +} + +inline ImpErrorQuad& ImpErrorQuad::operator-=(const BitmapColor& rColor) +{ + nRed -= long(rColor.GetRed()) << 5; + nGreen -= long(rColor.GetGreen()) << 5; + nBlue -= long(rColor.GetBlue()) << 5; + + return *this; +} + +inline void ImpErrorQuad::ImplAddColorError1(const ImpErrorQuad& rErrQuad) +{ + nRed += rErrQuad.nRed >> 4; + nGreen += rErrQuad.nGreen >> 4; + nBlue += rErrQuad.nBlue >> 4; +} + +inline void ImpErrorQuad::ImplAddColorError3(const ImpErrorQuad& rErrQuad) +{ + nRed += rErrQuad.nRed * 3L >> 4; + nGreen += rErrQuad.nGreen * 3L >> 4; + nBlue += rErrQuad.nBlue * 3L >> 4; +} + +inline void ImpErrorQuad::ImplAddColorError5(const ImpErrorQuad& rErrQuad) +{ + nRed += rErrQuad.nRed * 5L >> 4; + nGreen += rErrQuad.nGreen * 5L >> 4; + nBlue += rErrQuad.nBlue * 5L >> 4; +} + +inline void ImpErrorQuad::ImplAddColorError7(const ImpErrorQuad& rErrQuad) +{ + nRed += rErrQuad.nRed * 7L >> 4; + nGreen += rErrQuad.nGreen * 7L >> 4; + nBlue += rErrQuad.nBlue * 7L >> 4; +} + +inline BitmapColor ImpErrorQuad::ImplGetColor() +{ + return BitmapColor(std::clamp(nRed, 0L, 8160L) >> 5, std::clamp(nGreen, 0L, 8160L) >> 5, + std::clamp(nBlue, 0L, 8160L) >> 5); +} + +#endif // INCLUDED_VCL_INC_IMPOCTREE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/bitmaps.hlst b/vcl/inc/bitmaps.hlst new file mode 100644 index 000000000..68f23533e --- /dev/null +++ b/vcl/inc/bitmaps.hlst @@ -0,0 +1,228 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_BITMAPS_HRC +#define INCLUDED_VCL_INC_BITMAPS_HRC + +#define SV_RESID_BITMAP_CHECK1 "vcl/res/check1.png" +#define SV_RESID_BITMAP_CHECK2 "vcl/res/check2.png" +#define SV_RESID_BITMAP_CHECK3 "vcl/res/check3.png" +#define SV_RESID_BITMAP_CHECK4 "vcl/res/check4.png" +#define SV_RESID_BITMAP_CHECK5 "vcl/res/check5.png" +#define SV_RESID_BITMAP_CHECK6 "vcl/res/check6.png" +#define SV_RESID_BITMAP_CHECK7 "vcl/res/check7.png" +#define SV_RESID_BITMAP_CHECK8 "vcl/res/check8.png" +#define SV_RESID_BITMAP_CHECK9 "vcl/res/check9.png" +#define SV_RESID_BITMAP_CHECKMONO1 "vcl/res/checkmono1.png" +#define SV_RESID_BITMAP_CHECKMONO2 "vcl/res/checkmono2.png" +#define SV_RESID_BITMAP_CHECKMONO3 "vcl/res/checkmono3.png" +#define SV_RESID_BITMAP_CHECKMONO4 "vcl/res/checkmono4.png" +#define SV_RESID_BITMAP_CHECKMONO5 "vcl/res/checkmono5.png" +#define SV_RESID_BITMAP_CHECKMONO6 "vcl/res/checkmono6.png" +#define SV_RESID_BITMAP_CHECKMONO7 "vcl/res/checkmono7.png" +#define SV_RESID_BITMAP_CHECKMONO8 "vcl/res/checkmono8.png" +#define SV_RESID_BITMAP_CHECKMONO9 "vcl/res/checkmono9.png" +#define SV_RESID_BITMAP_RADIO1 "vcl/res/radio1.png" +#define SV_RESID_BITMAP_RADIO2 "vcl/res/radio2.png" +#define SV_RESID_BITMAP_RADIO3 "vcl/res/radio3.png" +#define SV_RESID_BITMAP_RADIO4 "vcl/res/radio4.png" +#define SV_RESID_BITMAP_RADIO5 "vcl/res/radio5.png" +#define SV_RESID_BITMAP_RADIO6 "vcl/res/radio6.png" +#define SV_RESID_BITMAP_RADIOMONO1 "vcl/res/radiomono1.png" +#define SV_RESID_BITMAP_RADIOMONO2 "vcl/res/radiomono2.png" +#define SV_RESID_BITMAP_RADIOMONO3 "vcl/res/radiomono3.png" +#define SV_RESID_BITMAP_RADIOMONO4 "vcl/res/radiomono4.png" +#define SV_RESID_BITMAP_RADIOMONO5 "vcl/res/radiomono5.png" +#define SV_RESID_BITMAP_RADIOMONO6 "vcl/res/radiomono6.png" + +#define SV_RESID_BITMAP_ERRORBOX "vcl/res/errorbox.png" +#define SV_RESID_BITMAP_QUERYBOX "vcl/res/querybox.png" +#define SV_RESID_BITMAP_WARNINGBOX "vcl/res/warningbox.png" +#define SV_RESID_BITMAP_INFOBOX "vcl/res/infobox.png" + +#define SV_RESID_BITMAP_SCROLLMSK "vcl/res/scrmsk.png" +#define SV_RESID_BITMAP_WHEELVH "vcl/res/wheelvh.png" +#define SV_RESID_BITMAP_WHEELV "vcl/res/wheelv.png" +#define SV_RESID_BITMAP_WHEELH "vcl/res/wheelh.png" +#define SV_RESID_BITMAP_SCROLLVH "vcl/res/scrollvh.png" +#define SV_RESID_BITMAP_SCROLLV "vcl/res/scrollv.png" +#define SV_RESID_BITMAP_SCROLLH "vcl/res/scrollh.png" +#define SV_RESID_BITMAP_CLOSEDOC "vcl/res/closedoc.png" +#define SV_RESID_BITMAP_INDEX "vcl/res/index.png" +#define SV_RESID_BITMAP_REFRESH "res/reload.png" +#define SV_RESID_BITMAP_NOTEBOOKBAR "res/notebookbar.png" + +#define SV_DISCLOSURE_PLUS "res/plus.png" +#define SV_DISCLOSURE_MINUS "res/minus.png" + +#define SV_PRINT_COLLATE_BMP "vcl/res/collate.png" +#define SV_PRINT_NOCOLLATE_BMP "vcl/res/ncollate.png" + +#define MAINAPP_48_8 "res/mainapp_48_8.png" +#define ODT_48_8 "res/odt_48_8.png" +#define OTT_48_8 "res/ott_48_8.png" +#define ODS_48_8 "res/ods_48_8.png" +#define OTS_48_8 "res/ots_48_8.png" +#define ODG_48_8 "res/odg_48_8.png" +#define ODP_48_8 "res/odp_48_8.png" +#define ODM_48_8 "res/odm_48_8.png" +#define ODB_48_8 "res/odb_48_8.png" +#define ODF_48_8 "res/odf_48_8.png" + +#define MAINAPP_32_8 "res/mainapp_32_8.png" +#define ODT_32_8 "res/odt_32_8.png" +#define OTT_32_8 "res/ott_32_8.png" +#define ODS_32_8 "res/ods_32_8.png" +#define OTS_32_8 "res/ots_32_8.png" +#define ODG_32_8 "res/odg_32_8.png" +#define ODP_32_8 "res/odp_32_8.png" +#define ODM_32_8 "res/odm_32_8.png" +#define ODB_32_8 "res/odb_32_8.png" +#define ODF_32_8 "res/odf_32_8.png" + +#define MAINAPP_16_8 "res/mainapp_16_8.png" +#define ODT_16_8 "res/odt_16_8.png" +#define OTT_16_8 "res/ott_16_8.png" +#define ODS_16_8 "res/ods_16_8.png" +#define OTS_16_8 "res/ots_16_8.png" +#define ODG_16_8 "res/odg_16_8.png" +#define ODP_16_8 "res/odp_16_8.png" +#define ODM_16_8 "res/odm_16_8.png" +#define ODB_16_8 "res/odb_16_8.png" +#define ODF_16_8 "res/odf_16_8.png" + +//start, Throbber::getDefaultImageURLs +#define SPINNER_16_01 "vcl/res/spinner-16-01.png" +#define SPINNER_16_02 "vcl/res/spinner-16-02.png" +#define SPINNER_16_03 "vcl/res/spinner-16-03.png" +#define SPINNER_16_04 "vcl/res/spinner-16-04.png" +#define SPINNER_16_05 "vcl/res/spinner-16-05.png" +#define SPINNER_16_06 "vcl/res/spinner-16-06.png" + +#define SPINNER_32_01 "vcl/res/spinner-32-01.png" +#define SPINNER_32_02 "vcl/res/spinner-32-02.png" +#define SPINNER_32_03 "vcl/res/spinner-32-03.png" +#define SPINNER_32_04 "vcl/res/spinner-32-04.png" +#define SPINNER_32_05 "vcl/res/spinner-32-05.png" +#define SPINNER_32_06 "vcl/res/spinner-32-06.png" +#define SPINNER_32_07 "vcl/res/spinner-32-07.png" +#define SPINNER_32_08 "vcl/res/spinner-32-08.png" +#define SPINNER_32_09 "vcl/res/spinner-32-09.png" +#define SPINNER_32_10 "vcl/res/spinner-32-10.png" +#define SPINNER_32_11 "vcl/res/spinner-32-11.png" +#define SPINNER_32_12 "vcl/res/spinner-32-12.png" + +#define SPINNER_64_01 "vcl/res/spinner-64-01.png" +#define SPINNER_64_02 "vcl/res/spinner-64-02.png" +#define SPINNER_64_03 "vcl/res/spinner-64-03.png" +#define SPINNER_64_04 "vcl/res/spinner-64-04.png" +#define SPINNER_64_05 "vcl/res/spinner-64-05.png" +#define SPINNER_64_06 "vcl/res/spinner-64-06.png" +#define SPINNER_64_07 "vcl/res/spinner-64-07.png" +#define SPINNER_64_08 "vcl/res/spinner-64-08.png" +#define SPINNER_64_09 "vcl/res/spinner-64-09.png" +#define SPINNER_64_10 "vcl/res/spinner-64-10.png" +#define SPINNER_64_11 "vcl/res/spinner-64-11.png" +#define SPINNER_64_12 "vcl/res/spinner-64-12.png" +//end, Throbber::getDefaultImageURLs + +#define IMG_APPLY "sw/res/sc20558.png" +#define IMG_WARN "dbaccess/res/exwarning.png" +#define IMG_ERROR "dbaccess/res/exerror.png" +#define IMG_INFO "dbaccess/res/exinfo.png" +#define IMG_ADD "extensions/res/scanner/plus.png" +#define IMG_REMOVE "extensions/res/scanner/minus.png" +#define IMG_COPY "cmd/sc_copy.png" +#define IMG_PASTE "cmd/sc_paste.png" + +#define RID_BMP_TREENODE_COLLAPSED "res/plus.png" +#define RID_BMP_TREENODE_EXPANDED "res/minus.png" + +#define RID_CURSOR_AUTOSCROLL_E "vcl/res/autoscroll_e.png" +#define RID_CURSOR_AUTOSCROLL_N "vcl/res/autoscroll_n.png" +#define RID_CURSOR_AUTOSCROLL_NE "vcl/res/autoscroll_ne.png" +#define RID_CURSOR_AUTOSCROLL_NS "vcl/res/autoscroll_ns.png" +#define RID_CURSOR_AUTOSCROLL_NSWE "vcl/res/autoscroll_nswe.png" +#define RID_CURSOR_AUTOSCROLL_NW "vcl/res/autoscroll_nw.png" +#define RID_CURSOR_AUTOSCROLL_S "vcl/res/autoscroll_s.png" +#define RID_CURSOR_AUTOSCROLL_SE "vcl/res/autoscroll_se.png" +#define RID_CURSOR_AUTOSCROLL_SW "vcl/res/autoscroll_sw.png" +#define RID_CURSOR_AUTOSCROLL_W "vcl/res/autoscroll_w.png" +#define RID_CURSOR_AUTOSCROLL_WE "vcl/res/autoscroll_we.png" +#define RID_CURSOR_CHAIN "vcl/res/chain.png" +#define RID_CURSOR_CHAIN_NOT_ALLOWED "vcl/res/chain_not_allowed.png" +#define RID_CURSOR_CHART "vcl/res/chart.png" +#define RID_CURSOR_COPY_DATA "vcl/res/copy_data.png" +#define RID_CURSOR_COPY_DATA_LINK "vcl/res/copy_data_link.png" +#define RID_CURSOR_COPY_FILE "vcl/res/copy_file.png" +#define RID_CURSOR_COPY_FILES "vcl/res/copy_files.png" +#define RID_CURSOR_COPY_FILE_LINK "vcl/res/copy_file_link.png" +#define RID_CURSOR_CROOK "vcl/res/crook.png" +#define RID_CURSOR_CROP "vcl/res/crop.png" +#define RID_CURSOR_DRAW_ARC "vcl/res/draw_arc.png" +#define RID_CURSOR_DRAW_BEZIER "vcl/res/draw_bezier.png" +#define RID_CURSOR_DRAW_CAPTION "vcl/res/draw_caption.png" +#define RID_CURSOR_DRAW_CIRCLE_CUT "vcl/res/draw_circle_cut.png" +#define RID_CURSOR_DRAW_CONNECT "vcl/res/draw_connect.png" +#define RID_CURSOR_DRAW_ELLIPSE "vcl/res/draw_ellipse.png" +#define RID_CURSOR_DETECTIVE "vcl/res/detective.png" +#define RID_CURSOR_DRAW_FREEHAND "vcl/res/draw_freehand.png" +#define RID_CURSOR_DRAW_LINE "vcl/res/draw_line.png" +#define RID_CURSOR_DRAW_PIE "vcl/res/draw_pie.png" +#define RID_CURSOR_DRAW_POLYGON "vcl/res/draw_polygon.png" +#define RID_CURSOR_DRAW_RECT "vcl/res/draw_rect.png" +#define RID_CURSOR_DRAW_TEXT "vcl/res/draw_text.png" +#define RID_CURSOR_FILL "vcl/res/fill.png" +#define RID_CURSOR_HELP "vcl/res/help.png" +#define RID_CURSOR_H_SHEAR "vcl/res/h_shear.png" +#define RID_CURSOR_LINK_DATA "vcl/res/link_data.png" +#define RID_CURSOR_LINK_FILE "vcl/res/link_file.png" +#define RID_CURSOR_MAGNIFY "vcl/res/magnify.png" +#define RID_CURSOR_MIRROR "vcl/res/mirror.png" +#define RID_CURSOR_MOVE_BEZIER_WEIGHT "vcl/res/move_bezier_weight.png" +#define RID_CURSOR_MOVE_DATA "vcl/res/move_data.png" +#define RID_CURSOR_MOVE_DATA_LINK "vcl/res/move_data_link.png" +#define RID_CURSOR_MOVE_FILE "vcl/res/move_file.png" +#define RID_CURSOR_MOVE_FILES "vcl/res/move_files.png" +#define RID_CURSOR_MOVE_FILE_LINK "vcl/res/move_file_link.png" +#define RID_CURSOR_MOVE_POINT "vcl/res/move_point.png" +#define RID_CURSOR_NESWSIZE "vcl/res/neswsize.png" +#define RID_CURSOR_NOT_ALLOWED "vcl/res/not_allowed.png" +#define RID_CURSOR_NULL "vcl/res/null.png" +#define RID_CURSOR_NWSESIZE "vcl/res/nwsesize.png" +#define RID_CURSOR_PEN "vcl/res/pen.png" +#define RID_CURSOR_PIVOT_COLUMN "vcl/res/pivot_column.png" +#define RID_CURSOR_PIVOT_DELETE "vcl/res/pivot_delete.png" +#define RID_CURSOR_PIVOT_FIELD "vcl/res/pivot_field.png" +#define RID_CURSOR_PIVOT_ROW "vcl/res/pivot_row.png" +#define RID_CURSOR_ROTATE "vcl/res/rotate.png" +#define RID_CURSOR_TAB_SELECT_E "vcl/res/tab_select_e.png" +#define RID_CURSOR_TAB_SELECT_S "vcl/res/tab_select_s.png" +#define RID_CURSOR_TAB_SELECT_SE "vcl/res/tab_select_se.png" +#define RID_CURSOR_TAB_SELECT_SW "vcl/res/tab_select_sw.png" +#define RID_CURSOR_TAB_SELECT_W "vcl/res/tab_select_w.png" +#define RID_CURSOR_V_SHEAR "vcl/res/v_shear.png" +#define RID_CURSOR_TEXT_VERTICAL "vcl/res/text_vertical.png" +#define RID_CURSOR_HIDE_WHITESPACE "vcl/res/hide_whitespace.png" +#define RID_CURSOR_SHOW_WHITESPACE "vcl/res/show_whitespace.png" +#define RID_CURSOR_WAIT "vcl/res/wait.png" +#define RID_CURSOR_NWSIZE "vcl/res/nwsize.png" +#define RID_CURSOR_NESIZE "vcl/res/nesize.png" +#define RID_CURSOR_SWSIZE "vcl/res/swsize.png" +#define RID_CURSOR_SESIZE "vcl/res/sesize.png" +#define RID_CURSOR_WINDOW_NWSIZE "vcl/res/window_nwsize.png" +#define RID_CURSOR_WINDOW_NESIZE "vcl/res/window_nesize.png" +#define RID_CURSOR_WINDOW_SWSIZE "vcl/res/window_swsize.png" +#define RID_CURSOR_WINDOW_SESIZE "vcl/res/window_sesize.png" + +#define CHEVRON "sfx2/res/chevron.png" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/bitmapwriteaccess.hxx b/vcl/inc/bitmapwriteaccess.hxx new file mode 100644 index 000000000..f747223ec --- /dev/null +++ b/vcl/inc/bitmapwriteaccess.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef INCLUDED_VCL_INC_BITMAPWRITEACCESS_HXX +#define INCLUDED_VCL_INC_BITMAPWRITEACCESS_HXX + +#include <vcl/alpha.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/bitmapaccess.hxx> +#include <optional> + +typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess> + BitmapScopedWriteAccess; + +typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireAlphaWriteAccess> + AlphaScopedWriteAccess; + +class VCL_DLLPUBLIC BitmapWriteAccess : public BitmapReadAccess +{ +public: + BitmapWriteAccess(Bitmap& rBitmap); + virtual ~BitmapWriteAccess() override; + + void CopyScanline(long nY, const BitmapReadAccess& rReadAcc); + void CopyScanline(long nY, ConstScanline aSrcScanline, ScanlineFormat nSrcScanlineFormat, + sal_uInt32 nSrcScanlineSize); + + void SetPalette(const BitmapPalette& rPalette) + { + assert(mpBuffer && "Access is not valid!"); + + mpBuffer->maPalette = rPalette; + } + + void SetPaletteEntryCount(sal_uInt16 nCount) + { + assert(mpBuffer && "Access is not valid!"); + + mpBuffer->maPalette.SetEntryCount(nCount); + } + + void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor) + { + assert(mpBuffer && "Access is not valid!"); + assert(HasPalette() && "Bitmap has no palette!"); + + mpBuffer->maPalette[nColor] = rBitmapColor; + } + + void SetPixel(long nY, long nX, const BitmapColor& rBitmapColor) + { + assert(mpBuffer && "Access is not valid!"); + assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!"); + assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!"); + + mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask); + } + + void SetPixelIndex(long nY, long nX, sal_uInt8 cIndex) + { + SetPixel(nY, nX, BitmapColor(cIndex)); + } + + void SetLineColor(const Color& rColor); + + void SetFillColor(); + void SetFillColor(const Color& rColor); + + void Erase(const Color& rColor); + + void DrawLine(const Point& rStart, const Point& rEnd); + + void FillRect(const tools::Rectangle& rRect); + void DrawRect(const tools::Rectangle& rRect); + +private: + std::optional<BitmapColor> mpLineColor; + std::optional<BitmapColor> mpFillColor; + + BitmapWriteAccess() = delete; + BitmapWriteAccess(const BitmapWriteAccess&) = delete; + BitmapWriteAccess& operator=(const BitmapWriteAccess&) = delete; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |