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