Laxkit  0.0.7.1
laximages-cairo.h
1 //
2 //
3 // The Laxkit, a windowing toolkit
4 // Please consult http://laxkit.sourceforge.net about where to send any
5 // correspondence about this software.
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 // Copyright (C) 2013 by Tom Lechner
22 //
23 #ifndef _LAX_LAXIMAGES_CAIRO_H
24 #define _LAX_LAXIMAGES_CAIRO_H
25 
26 #include <lax/laximages.h>
27 
28 #include <cairo/cairo-xlib.h>
29 
30 
31 
32 namespace Laxkit {
33 
34 
35 
36 //--------------------------- LaxCairoImage --------------------------------------
37 class LaxCairoImage : public LaxImage
38 {
39  protected:
40  char flag,whichimage;
41  int display_count;
42  public:
43  cairo_surface_t *image;
44  int width,height;
45  int dwidth,dheight;
46  LaxCairoImage(const char *fname,cairo_surface_t *img=NULL,const char *npreviewfile=NULL,
47  int maxx=0,int maxy=0,char del=0);
48  virtual ~LaxCairoImage();
49  virtual cairo_surface_t *Image(int which=0);
50  virtual void doneForNow();
51  virtual unsigned int imagestate();
52  virtual int imagetype() { return LAX_IMAGE_CAIRO; }
53  virtual int w() { return width; }
54  virtual int h() { return height; }
55  virtual int dataw() { return dwidth; } //often smaller image used for preview purposes..
56  virtual int datah() { return dheight; }
57  virtual void clear();
58 
59  virtual int createFromData_ARGB8(int width, int height, int stride, const unsigned char *data);
60  virtual unsigned char *getImageBuffer();
61  virtual int doneWithBuffer(unsigned char *buffer);
62 };
63 
64 //----------------- LaxCairoImage utils
65 
66 int laxcairo_image_type();
67 
68 void laxcairo_image_out(LaxImage *image, aDrawable *win, int ulx, int uly);
69 void laxcairo_image_out_rotated(LaxImage *image, aDrawable *win, int ulx,int uly, int urx,int ury);
70 void laxcairo_image_out_skewed(LaxImage *image, aDrawable *win, int ulx,int uly, int urx,int ury, int llx, int lly);
71 void laxcairo_image_out_matrix(LaxImage *image, aDrawable *win, double *m);
72 
73 LaxImage *load_cairo_image(const char *filename);
74 LaxImage *load_cairo_image_with_preview(const char *filename,const char *previewfile,int maxx,int maxy,char del);
75 int laxcairo_generate_preview(const char *original, const char *preview, const char *format,int maxw, int maxh, int fit);
76 
77 LaxImage *image_from_buffer_cairo(unsigned char *buffer, int w, int h, int stride);
78 LaxImage *create_new_cairo_image(int w, int h);
79 
80 
81 
82 } //namespace Laxkit
83 
84 #endif
85 

Mon Feb 17 2014 11:52:56, Laxkit