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

gr_CairoImage.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 /* AbiWord
00003  * Copyright (C) 2008 Dominic Lachowicz
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00018  * 02111-1307, USA.
00019  */
00020 
00021 #ifndef GR_CAIROIMAGE_H
00022 #define GR_CAIROIMAGE_H
00023 
00024 #include <cairo.h>
00025 
00026 #include "gr_CairoGraphics.h"
00027 #include "ut_bytebuf.h"
00028 #include "gr_UnixImage.h"
00029 #include <librsvg/rsvg.h>
00030 #include <librsvg/rsvg-cairo.h>
00031 
00032 class GR_RSVGVectorImage : public GR_CairoVectorImage {
00033  public:
00034 
00035   GR_RSVGVectorImage(const char* name);
00036   virtual ~GR_RSVGVectorImage();
00037 
00038   virtual bool convertToBuffer(UT_ByteBuf** ppBB) const;
00039   virtual bool convertFromBuffer(const UT_ByteBuf* pBB,
00040                  const std::string& mimetype,
00041                  UT_sint32 iDisplayWidth,
00042                  UT_sint32 iDisplayHeight);
00043   virtual void cairoSetSource(cairo_t *cr);
00044   virtual void scaleImageTo(GR_Graphics * pG, const UT_Rect & rec);
00045 
00046   virtual bool            hasAlpha(void) const;
00047   virtual bool            isTransparentAt(UT_sint32 x, UT_sint32 y);
00048   virtual GR_Image *  createImageSegment(GR_Graphics *pG, const UT_Rect &rec);
00049 
00050  private:
00051   void reset();
00052   void setupScale(UT_sint32 w, UT_sint32 h);
00053   void createSurface(cairo_t* cairo);
00054   void createImageSurface();
00055   void renderToSurface(cairo_surface_t* surf);
00056 
00057   UT_ByteBuf m_data;
00058   RsvgDimensionData m_size;
00059   cairo_t* m_graphics;
00060   cairo_surface_t* m_surface;
00061   cairo_surface_t* m_image_surface;
00062   RsvgHandle* m_svg;
00063   double m_scaleX;
00064   double m_scaleY;
00065   bool m_needsNewSurface;
00066   GR_UnixImage * m_rasterImage;
00067 };
00068 
00069 #endif

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1