1 /* -*- Mode: C; tab-width: 8;	 indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 
3 /*
4  *  GThumb
5  *
6  *  Copyright (C) 2011 The Free Software Foundation, Inc.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef GTH_IMAGE_H
23 #define GTH_IMAGE_H
24 
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #include <gio/gio.h>
29 #include <cairo.h>
30 #include "gth-file-data.h"
31 #include "gth-icc-profile.h"
32 
33 G_BEGIN_DECLS
34 
35 typedef enum {
36 	GTH_IMAGE_FORMAT_CAIRO_SURFACE,
37 	GTH_IMAGE_FORMAT_GDK_PIXBUF,
38 	GTH_IMAGE_FORMAT_GDK_PIXBUF_ANIMATION,
39 	GTH_IMAGE_N_FORMATS
40 } GthImageFormat;
41 
42 #define GTH_TYPE_IMAGE            (gth_image_get_type ())
43 #define GTH_IMAGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_IMAGE, GthImage))
44 #define GTH_IMAGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_IMAGE, GthImageClass))
45 #define GTH_IS_IMAGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_IMAGE))
46 #define GTH_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_IMAGE))
47 #define GTH_IMAGE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GTH_TYPE_IMAGE, GthImageClass))
48 
49 typedef struct _GthImage         GthImage;
50 typedef struct _GthImageClass    GthImageClass;
51 typedef struct _GthImagePrivate  GthImagePrivate;
52 
53 struct _GthImage
54 {
55 	GObject __parent;
56 	GthImagePrivate *priv;
57 };
58 
59 struct _GthImageClass
60 {
61 	GObjectClass __parent_class;
62 
63 	gboolean  (*get_is_zoomable)  (GthImage *image);
64 	gboolean  (*set_zoom)         (GthImage *image,
65 				       double    zoom,
66 				       int      *original_width,
67 				       int      *original_height);
68 };
69 
70 
71 typedef GthImage * (*GthImageLoaderFunc) (GInputStream  *istream,
72 					  GthFileData   *file_data,
73 					  int            requested_size,
74 					  int           *original_width,
75 					  int           *original_height,
76 					  gboolean      *loaded_original,
77 					  gpointer       user_data,
78 					  GCancellable  *cancellable,
79 					  GError       **error);
80 
81 
82 GType                 gth_image_get_type                    (void);
83 GthImage *            gth_image_new                         (void);
84 GthImage *            gth_image_new_for_surface             (cairo_surface_t    *surface);
85 GthImage *            gth_image_new_for_pixbuf              (GdkPixbuf          *value);
86 GthImage *            gth_image_copy                        (GthImage           *image);
87 void                  gth_image_set_cairo_surface           (GthImage           *image,
88 						             cairo_surface_t    *value);
89 cairo_surface_t *     gth_image_get_cairo_surface           (GthImage           *image);
90 gboolean              gth_image_get_original_size	    (GthImage           *image,
91 							     int                *width,
92 							     int                *height);
93 gboolean              gth_image_get_is_zoomable             (GthImage           *image);
94 gboolean              gth_image_get_is_null                 (GthImage           *image);
95 gboolean              gth_image_set_zoom                    (GthImage           *image,
96 							     double              zoom,
97 							     int                *original_width,
98 							     int                *original_height);
99 void                  gth_image_set_pixbuf                  (GthImage           *image,
100 						             GdkPixbuf          *value);
101 GdkPixbuf *           gth_image_get_pixbuf                  (GthImage           *image);
102 void                  gth_image_set_pixbuf_animation        (GthImage           *image,
103 						             GdkPixbufAnimation *value);
104 GdkPixbufAnimation *  gth_image_get_pixbuf_animation        (GthImage           *image);
105 gboolean              gth_image_get_is_animation            (GthImage           *image);
106 void		      gth_image_set_icc_profile		    (GthImage           *image,
107 							     GthICCProfile	*profile);
108 GthICCProfile *	      gth_image_get_icc_profile		    (GthImage           *image);
109 void		      gth_image_apply_icc_profile           (GthImage           *image,
110 							     GthICCProfile      *out_profile,
111 							     GCancellable       *cancellable);
112 void		      gth_image_apply_icc_profile_async     (GthImage           *image,
113 							     GthICCProfile	*out_profile,
114 							     GCancellable	*cancellable,
115 							     GAsyncReadyCallback callback,
116 							     gpointer            user_data);
117 gboolean	      gth_image_apply_icc_profile_finish    (GAsyncResult       *result,
118 							     GError            **error);
119 
120 G_END_DECLS
121 
122 #endif /* GTH_IMAGE_H */
123