• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

gr_Image.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017  * 02111-1307, USA.
00018  */
00019 
00020 #ifndef GR_IMAGE_H
00021 #define GR_IMAGE_H
00022 
00023 #include <string>
00024 #include "ut_types.h"
00025 #include "ut_string_class.h"
00026 #include "ut_misc.h"
00027 
00028 class GR_Graphics;
00029 class UT_ByteBuf;
00030 
00031 class ABI_EXPORT GR_Image_Point
00032 {
00033 public:
00034   GR_Image_Point(void) : m_iX(0),m_iY(0)
00035     {}
00036   UT_sint32 m_iX;
00037   UT_sint32 m_iY;
00038 };
00039 
00040 class ABI_EXPORT GR_Image
00041 {
00042 public:
00043     GR_Image();
00044     virtual ~GR_Image();
00045 
00046     virtual UT_sint32   getDisplayWidth(void) const;
00047     virtual UT_sint32   getDisplayHeight(void) const;
00048 
00049     virtual bool        convertToBuffer(UT_ByteBuf** ppBB) const = 0;
00050     virtual bool        convertFromBuffer(const UT_ByteBuf* pBB, const std::string& mimetype, UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight) = 0;
00056     virtual GR_Image *  createImageSegment(GR_Graphics * pG, const UT_Rect & rec) = 0;
00057     virtual void        scaleImageTo(GR_Graphics * pG, const UT_Rect & rec);
00058     void                getName(char* szName) const;
00059     void getName ( std::string & name) const;
00060     void getName ( UT_String & copy ) const;
00064     virtual bool hasAlpha(void) const = 0;
00068     virtual bool isTransparentAt(UT_sint32 x, UT_sint32 y) = 0;
00069     void         GenerateOutline(void);
00070     void         DestroyOutline(void);
00071     UT_sint32 GetOffsetFromLeft(GR_Graphics * pG, UT_sint32 pad, UT_sint32 yTop, UT_sint32 height);
00072     UT_sint32 GetOffsetFromRight(GR_Graphics * pG, UT_sint32 pad, UT_sint32 yTop, UT_sint32 height);
00073 
00074     bool isOutLinePresent(void) const
00075       { return (m_vecOutLine.getItemCount() > 0);}
00076     enum GRType {
00077        GRT_Unknown,
00078        GRT_Raster,
00079        GRT_Vector
00080     };
00081 
00082     static GRType       getBufferType(const UT_ByteBuf* pBB);
00083     virtual GRType      getType() const;
00084     virtual bool        render(GR_Graphics *pGR, UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight);
00085 
00086     void setDisplaySize(UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight);
00087 
00088 protected:
00089     void setName ( const char * szName );
00090     void setName ( const UT_String & szName );
00091 
00092 private:
00093     std::string         m_szName;
00094     UT_sint32           m_iDisplayWidth;
00095     UT_sint32           m_iDisplayHeight;
00096     UT_GenericVector<GR_Image_Point *> m_vecOutLine;
00097 };
00098 
00099 class ABI_EXPORT GR_RasterImage : public GR_Image
00100 {
00101 public:
00102     virtual bool hasAlpha(void) const = 0;
00103     virtual bool isTransparentAt(UT_sint32 x, UT_sint32 y) = 0;
00104     virtual GRType      getType() const { return GRT_Raster; }
00105 };
00106 
00107 class ABI_EXPORT GR_ImageFactory
00108 {
00109 public:
00110     virtual ~GR_ImageFactory() {}
00111 
00112     virtual GR_Image*   createNewImage(const char* pszName, GR_Image::GRType iType = GR_Image::GRT_Raster) = 0;
00113 };
00114 
00115 #include "gr_VectorImage.h"
00116 
00117 #endif /* GR_IMAGE */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1