1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SVIMBASE_HXX 29 #define _SVIMBASE_HXX 30 31 #include <vcl/bitmap.hxx> 32 #include <vcl/salbtype.hxx> 33 34 35 // ----------- 36 // - Defines - 37 // ----------- 38 39 #define _SVHUGE 40 41 // ---------------- 42 // - SimDepthType - 43 // ---------------- 44 45 enum SimDepthType 46 { 47 SIM_DEPTH_1, 48 SIM_DEPTH_4, 49 SIM_DEPTH_8, 50 SIM_DEPTH_24 51 }; 52 53 // ------------ 54 // - SimColor - 55 // ------------ 56 57 struct SimColor 58 { 59 sal_uInt8 cBlue; 60 sal_uInt8 cGreen; 61 sal_uInt8 cRed; 62 }; 63 64 // ------------------------------------------------------------------------ 65 66 inline sal_Bool operator==( const SimColor& rCol1, const SimColor& rCol2 ) 67 { 68 return ( ( rCol1.cRed == rCol2.cRed ) && 69 ( rCol1.cGreen == rCol2.cGreen ) && 70 ( rCol1.cBlue == rCol2.cBlue ) ); 71 } 72 73 // -------------- 74 // - SimPalette - 75 // -------------- 76 77 struct SimPalette 78 { 79 sal_uIntPtr nColors; 80 SimColor aColorArray[ 256 ]; 81 }; 82 83 // --------------- 84 // - SvImageBase - 85 // --------------- 86 87 class SfxViewFrame; 88 class SfxProgress; 89 90 class SvImageBase 91 { 92 private: 93 94 Bitmap aOutBitmap; 95 HPBYTE pArray1; 96 HPBYTE pArray2; 97 HPBYTE pArray3; 98 HPBYTE pArray4; 99 HPBYTE pOrgArray; 100 HPBYTE pDestArray; 101 SimPalette* pPal1; 102 SimPalette* pPal2; 103 SimPalette* pPal3; 104 SimPalette* pPal4; 105 sal_uIntPtr nWidth1; 106 sal_uIntPtr nWidth2; 107 sal_uIntPtr nWidth3; 108 sal_uIntPtr nWidth4; 109 sal_uIntPtr nHeight1; 110 sal_uIntPtr nHeight2; 111 sal_uIntPtr nHeight3; 112 sal_uIntPtr nHeight4; 113 sal_uIntPtr nAlignedWidth1; 114 sal_uIntPtr nAlignedWidth2; 115 sal_uIntPtr nAlignedWidth3; 116 sal_uIntPtr nAlignedWidth4; 117 sal_uIntPtr nWhichOrg; 118 SimDepthType eOrgDepth; 119 SimDepthType eUndoDepth; 120 SimDepthType eRedoDepth; 121 sal_Bool bIsUndo; 122 sal_Bool bIsRedo; 123 sal_Bool bCreateUndo; 124 sal_Bool bValid; 125 sal_Bool bDitherAll; 126 127 HPBYTE BitmapToArray24( const Bitmap& rBitmap, sal_uIntPtr* pWidth, 128 sal_uIntPtr* pHeight, sal_uIntPtr* pAlignedWidth, 129 SfxViewFrame *pFrame = NULL ); 130 sal_Bool Array24ToBitmap( HPBYTE pArray, Bitmap &rBitmap, 131 const sal_uIntPtr nWidth, const sal_uIntPtr nHeight, 132 const sal_uIntPtr nColorCount = 256, 133 sal_uIntPtr nLast = 0, SfxProgress* pProgress = NULL ); 134 135 Bitmap CreateSaveBitmap( const SimDepthType eDepth, SfxViewFrame *pFrame = NULL ); 136 137 HPBYTE CreateArray24( sal_uIntPtr nWidth, sal_uIntPtr nHeight ); 138 void DeleteArray( HPBYTE pArray ); 139 140 SvImageBase(const SvImageBase& rSvImageBase); 141 const SvImageBase& operator=(const SvImageBase& rSvImageBase); 142 143 public: 144 145 SvImageBase(); 146 SvImageBase( const Bitmap& rBitmap, 147 const sal_uIntPtr nColorCount = 256, 148 sal_uIntPtr nLast = 0, SfxProgress* pProgress = NULL ); 149 ~SvImageBase(); 150 151 sal_Bool IsValid() { return bValid; } 152 153 sal_uIntPtr GetOrgWidth() const { return nWhichOrg == 1 ? nWidth1 : nWidth2; } 154 sal_uIntPtr GetDestWidth() const { return nWhichOrg == 1 ? nWidth2 : nWidth1; } 155 156 sal_uIntPtr GetOrgHeight() const { return nWhichOrg == 1 ? nHeight1 : nHeight2; } 157 sal_uIntPtr GetDestHeight() const { return nWhichOrg == 1 ? nHeight2 : nHeight1; } 158 159 sal_uIntPtr GetOrgAlignedWidth() const { return nWhichOrg == 1 ? nAlignedWidth1 : nAlignedWidth2; } 160 sal_uIntPtr GetDestAlignedWidth() const { return nWhichOrg == 1 ? nAlignedWidth2 : nAlignedWidth1; } 161 162 sal_uIntPtr GetOrgAlignedSize() const { return GetOrgAlignedWidth() * GetOrgHeight(); } 163 sal_uIntPtr GetDestAlignedSize() const { return GetDestAlignedWidth() * GetDestHeight(); } 164 165 // Farbtiefe des Ausgangsbildes ermitteln und setzen 166 SimDepthType GetDepth() const { return eOrgDepth; } 167 void SetDepth( const SimDepthType eDepth ) { eOrgDepth = eDepth; } 168 169 // Farbtiefen nach Undo und Redo ermitteln und setzen 170 SimDepthType GetUndoDepth() const { return eUndoDepth; } 171 void SetUndoDepth(const SimDepthType eDepth) { eUndoDepth = eDepth; } 172 173 SimDepthType GetRedoDepth() const { return eRedoDepth; } 174 void SetRedoDepth(const SimDepthType eDepth) { eRedoDepth = eDepth; } 175 176 // Vor- und Ruecklauf der Bildverarbeitung 177 sal_Bool BeginProcessing( sal_Bool bUndo = sal_True ); 178 void EndProcessing(); 179 180 sal_Bool BeginProcessingExt(sal_uIntPtr nWidth, sal_uIntPtr nHeight, sal_Bool bUndo = sal_True); 181 void EndProcessingExt() { EndProcessing(); } 182 183 // Zeiger auf Arrays zur Verfuegung stellen 184 HPBYTE GetOrgPointer() { return pOrgArray; } 185 HPBYTE GetDestPointer() { return pDestArray; } 186 187 // DIB-Erzeugung fuer Anzeige 188 sal_Bool CreateOutBitmap( const sal_uIntPtr nColorCount = 256, sal_uIntPtr nLast = 0, 189 SfxProgress* pProgress = NULL ); 190 191 // Undo-Verwaltung 192 sal_Bool DoUndo( SfxProgress* pProgress = NULL ); 193 sal_Bool DoRedo( SfxProgress* pProgress = NULL ); 194 195 // DIB-Rueckgabe fuer Anzeige 196 const Bitmap& GetOutBitmap() const; 197 198 // DIB-Rueckgabe fuer Speicherung 199 Bitmap GetSaveBitmap(); 200 201 // Palette besorgen 202 SimPalette* GetOrgPalette() const { return nWhichOrg == 1 ? pPal1 : pPal2; } 203 SimPalette* GetDestPalette() const { return nWhichOrg == 1 ? pPal2 : pPal1; } 204 }; 205 206 // ---------------- 207 // - DitherBitmap - 208 // ---------------- 209 210 sal_Bool DitherBitmap( Bitmap& rBitmap, sal_Bool bDitherAlways = sal_False ); 211 212 #endif // _SVIMBASE_HXX 213