bshadow.h

Go to the documentation of this file.
00001 // $Id: bshadow.h 751 2006-03-31 15:43:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 #ifndef _BITMAPSHADOW_H_
00099 #define _BITMAPSHADOW_H_
00100 
00101 #include "bshadow2.h"
00102 
00103 #ifdef BUILDSHADOWS
00104 
00105 //const UINT32 MAX_SHADOW_BLUR  = 100 ;     // Maximum amount of blur
00106 //const UINT32 MAX_CONTOUR      = 100 ;     // Maximum contour pixel size.
00107 //const double MIN_BLUR_DIAMETER = 0.71;    // Minimum blur diameter is sqrt(0.5), rounded up
00108                                         // a little to safely avoid boundary conditions.
00109 
00110 class ShadowBitmap : public CCObject
00111 {
00112 // CC_DECLARE_DYNCREATE(ShadowBitmap);
00113 public:
00114     ShadowBitmap();
00115     ~ShadowBitmap();
00116 
00117     BOOL CreateFilled(INT32 Width, INT32 Height, BYTE value, UINT32 Depth = 32);
00118     
00119     BOOL Create8BitBitmap(UINT32 * pBits, UINT32 Width, UINT32 Height);
00120 
00121     HRESULT Create(INT32 Width, INT32 Height, UINT32 Depth = 32);
00122     LPBYTE GetBytes() { return (LPBYTE)m_Bytes; }
00123 
00124     INT32 GetWidth() { return m_Width; }
00125     INT32 GetHeight() { return m_Height; }
00126     UINT32 GetDepth() { return m_Depth; }
00127 
00128 private:
00129     INT32 m_Width;
00130     INT32 m_Height;
00131     BYTE * m_Bytes;
00132     UINT32 m_Depth;
00133 } ;
00134 
00135 class CBitmapShadow : public ShadowBitmap
00136 {
00137     friend class NodeFeatherEffect;
00138 
00139 // CC_DECLARE_DYNCREATE(CBitmapShadow);
00140 public:
00141     enum {
00142 //      MAX_ROW_OFFSETS = MAX_SHADOW_BLUR*2+1,  // Maximum size of shadow mask.
00143 //      TABLE_SIZE = 0x800                      // Maximum lookup table size for shadow generation.
00144     } ;
00145 
00146     CBitmapShadow();
00147         
00148     BOOL CreateShadow(const BOOL bIsWallShadow,
00149                                             const double dProjection,
00150                                             const double dTiltAngle,
00151                                             const double dBlurriness,
00152                                             const double dDarknessCoeff,
00153                                             const double dPositionX,
00154                                             const double dPositionY,
00155                                             UINT32* pForegroundBits,
00156                                             const CNativeSize ForegroundSize
00157                                             );
00158 
00159     void GetShadowOffset(INT32* pOffsetX, INT32* pOffsetY)
00160     {
00161         *pOffsetX = m_OffsetX;
00162         *pOffsetY = m_OffsetY;      
00163     }
00164 
00165     BOOL IsWallShadow(void) const
00166     {
00167         return m_bIsWallShadow;
00168     }
00169 
00170     double GetBlurriness(void) const
00171     {
00172         return m_dBlurriness;
00173     }
00174 
00175     double GetDarknessCoeff(void) const
00176     {
00177         return m_dDarknessCoeff;
00178     }
00179 
00180 private:
00181     BOOL MakeWallShadow (const UINT32* pForegroundBits,
00182                                     const CNativeSize ForegroundSize,
00183                                     const INT32 nXPosition,
00184                                     const INT32 nYPosition,
00185                                     const double fBlur,
00186                                     INT32 *pOffsetX,
00187                                     INT32 *pOffsetY,
00188                                     const double dDarknessCoeff = 1.0);
00189 
00190     BOOL MakeCastShadow (UINT32* pForegroundBits,
00191                                 const CNativeSize ForegroundSize,
00192                                 const double fBlur,                                  
00193                                 const double dTiltAngle, 
00194                                 const double dProjection,
00195                                 const double dDarknessCoeff = 1.0 );
00196 
00197     BOOL m_bIsWallShadow;
00198     double m_dProjection;
00199     double m_dTiltAngle;
00200     double m_dBlurriness;
00201     double m_dDarknessCoeff;
00202     double m_dPositionX;
00203     double m_dPositionY;
00204     INT32 m_OffsetX;
00205     INT32 m_OffsetY;
00206 
00207 protected:
00208     ShadowBitmap* Tilt(BYTE* pSourceBits, const INT32 nSourceWidth, const INT32 nSourceHeight, const double dTiltDegrees);
00209     static bool ProjectShadow(BYTE* pSBitmap, BYTE* pDBitmap, UINT32 nWidth, UINT32 nSHeight, UINT32 nDHeight);
00210 
00211 
00212 // Karim 02/08/2000
00213 // made this static so it can be accessed by the public static feathering
00214 // function.
00215 
00216 public:
00217     // Karim 08/08/2000
00218     // Blur the source bitmap, storing the result in the destination bitmap.
00219 
00220     static void Blur8BppBitmap( LPBITMAPINFOHEADER pSrcBMIHeader,   LPBYTE pSrcBits,
00221                                 LPBITMAPINFOHEADER pDestBMIHeader,  LPBYTE pDestBits,
00222                                 const UINT32 DWordBitmapWidth, const double fBlur );
00223 
00224     // Karim 17/08/2000
00225     // Determine whether the resultant bitmap for this blur setting
00226     // will be offset up and right by half a pixel.
00227     static BOOL BlurringWillOffsetBitmap(double fBlurDiameter)
00228     {
00229         // bitmap will be offset if the blur diameter is even,
00230         // and is not smaller than the minimum blur diameter.
00231         return (    ((UINT32)(fBlurDiameter + 0.5) % 2 == 0) &&
00232                     !(fBlurDiameter < MIN_BLUR_DIAMETER)    );
00233     }
00234 
00235     static UINT32 GetWholePixelBlurDiameter(double fBlurDiameter)
00236     {
00237         double fNewBlur = fBlurDiameter / 2.0;
00238         if (fNewBlur > MAX_SHADOW_BLUR)
00239             fNewBlur = MAX_SHADOW_BLUR;
00240 
00241         return (UINT32)(2 * fNewBlur + 0.5);
00242     }
00243 
00244     static LPBITMAPINFO Feather8BppBitmap(
00245         const double fBlur,
00246         LPBITMAPINFO pSrcInfo,
00247         LPBYTE pSrcBits32,
00248         LPBYTE* pDestBits
00249     ) ;
00250 
00251     //
00252     // Gavin 24/11/2004
00253     //
00254     // Contour the 32bpp source bitmap, putting the result into the 32bpp destination bitmap.
00255     //
00256     static bool ContourBitmap(
00257                         const LPBITMAPINFO  pSrcInfo32,
00258                         const LPBYTE        pSrcBits32,
00259                         const double        fContour,
00260                         const BYTE          uThreshold,
00261                         LPBITMAPINFO*       ppDestInfo32,
00262                         LPBYTE*             ppDestBits32,
00263                         double*             pfOffsetX,
00264                         double*             pfOffsetY
00265                     ) ;
00266     //
00267     // Gavin 20/04/2005
00268     //
00269     // Contour the 8bpp source bitmap, putting the result into the 8bpp destination bitmap.
00270     //
00271     static bool ContourBitmap(
00272                         const LPBITMAPINFO  pSrcInfo8,
00273                         const LPBYTE        pSrcBits8,
00274                         const double        fContour,
00275                         const bool          bInside,
00276                         const BYTE          uThreshold,
00277                         LPBITMAPINFO*       ppDestInfo8,
00278                         LPBYTE*             ppDestBits8,
00279                         double*             pfOffsetX,
00280                         double*             pfOffsetY
00281                     ) ;
00282 
00283 protected:
00284 } ;
00285 
00286 #endif
00287 
00288 #endif //_BITMAPSHADOW_H_
00289 
00290 
00291 
00292 

Generated on Sat Nov 10 03:44:35 2007 for Camelot by  doxygen 1.4.4