GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

pixbuf.hh

Go to the documentation of this file.
00001 /* GFC-UI: GTK+ Foundation Classes (User Interface Library) 00002 * Copyright (C) 2002-2004 The GFC Development Team. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (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 Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library 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 02111-1307, USA. 00017 */ 00018 00023 00024 #ifndef GFC_GDK_PIXBUF_HH 00025 #define GFC_GDK_PIXBUF_HH 00026 00027 #ifndef GFC_OBJECT_HH 00028 #include <gfc/object.hh> 00029 #endif 00030 00031 #ifndef GFC_G_OBJECT_HH 00032 #include <gfc/glib/object.hh> 00033 #endif 00034 00035 #ifndef GFC_GDK_TYPES_HH 00036 #include <gfc/gdk/types.hh> 00037 #endif 00038 00039 #ifndef GDK_PIXBUF_H 00040 #include <gdk-pixbuf/gdk-pixbuf.h> 00041 #endif 00042 00043 #ifndef __GDK_RGB_H__ 00044 #include <gdk/gdkrgb.h> 00045 #endif 00046 00047 #ifndef _CPP_VECTOR 00048 #include <vector> 00049 #endif 00050 00051 namespace GFC { 00052 00053 namespace G { 00054 class Error; 00055 } 00056 00057 namespace Gdk { 00058 00059 class Bitmap; 00060 class Colormap; 00061 class Drawable; 00062 class GC; 00063 class Image; 00064 class Pixmap; 00065 00069 00070 enum Colorspace 00071 { 00072 COLORSPACE_RGB = GDK_COLORSPACE_RGB 00073 }; 00074 00083 00084 enum InterpType 00085 { 00086 INTERP_NEAREST = GDK_INTERP_NEAREST, 00090 00091 INTERP_TILES = GDK_INTERP_TILES, 00096 00097 INTERP_BILINEAR = GDK_INTERP_BILINEAR, 00102 00103 INTERP_HYPER = GDK_INTERP_HYPER 00108 }; 00109 00116 00117 enum PixbufAlphaMode 00118 { 00119 PIXBUF_ALPHA_BILEVEL = GDK_PIXBUF_ALPHA_BILEVEL, 00123 00124 PIXBUF_ALPHA_FULL = GDK_PIXBUF_ALPHA_FULL 00127 }; 00128 00135 00136 class PixbufFormat : public GFC::Object 00137 { 00138 PixbufFormat(const PixbufFormat&); 00139 PixbufFormat& operator=(const PixbufFormat&); 00140 00141 GdkPixbufFormat *format_; 00142 00143 public: 00146 00147 explicit PixbufFormat(GdkPixbufFormat *format); 00150 00151 ~PixbufFormat(); 00153 00157 00158 GdkPixbufFormat* gdk_pixbuf_format() const; 00160 00161 String get_name() const; 00163 00164 String get_description() const; 00166 00167 std::vector<String> get_mime_types() const; 00170 00171 std::vector<String> get_extensions() const; 00174 00175 bool is_writable() const; 00177 00179 }; 00180 00188 00189 class Pixbuf : public G::Object 00190 { 00191 friend class G::Object; 00192 00193 Pixbuf(const Pixbuf&); 00194 Pixbuf& operator=(const Pixbuf&); 00195 00196 protected: 00199 00200 explicit Pixbuf(GdkPixbuf *pixbuf, bool owns_reference = true); 00207 00209 00210 public: 00211 typedef sigc::slot<bool, const char*, size_t, G::Error*> SaveSlot; 00228 00231 00232 Pixbuf(const Pixbuf& src, int src_x, int src_y, int width, int height); 00243 00244 Pixbuf(const unsigned char *data, int width, int height, int rowstride, bool has_alpha, 00245 GdkPixbufDestroyNotify destroy_fn = 0, void *destroy_fn_data = 0, 00246 int bits_per_sample = 8, Colorspace colorspace = COLORSPACE_RGB); 00266 00267 Pixbuf(const char **data); 00272 00273 virtual ~Pixbuf(); 00275 00277 00278 static Pointer<Pixbuf> create(const char *filename, G::Error *error = 0); 00279 static Pointer<Pixbuf> create(const String& filename, G::Error *error = 0); 00297 00298 static Pointer<Pixbuf> create(const char *filename, int width, int height, G::Error *error = 0); 00299 static Pointer<Pixbuf> create(const String& filename, int width, int height, G::Error *error = 0); 00315 00316 static Pointer<Pixbuf> create(int width, int height, bool has_alpha, int bits_per_sample = 8, Colorspace colorspace = COLORSPACE_RGB); 00329 00330 static Pointer<Pixbuf> create(const Drawable& drawable, int x, int y, int width, int height, Colormap *colormap = 0); 00341 00342 static Pointer<Pixbuf> create(const Image& image, int x, int y, int width, int height, Colormap *colormap = 0); 00351 00352 static Pointer<Pixbuf> create(int data_length, const unsigned char *data, bool copy_pixels, G::Error *error = 0); 00380 00381 static bool get_formats(std::vector<Pointer<PixbufFormat> >& formats); 00385 00388 00389 GdkPixbuf* gdk_pixbuf() const; 00391 00392 operator GdkPixbuf* () const; 00394 00395 Colorspace get_colorspace() const; 00397 00398 int get_n_channels() const; 00400 00401 bool get_has_alpha() const; 00403 00404 int get_bits_per_sample() const; 00406 00407 unsigned char* get_pixels() const; 00410 00411 int get_width() const; 00413 00414 int get_height() const; 00416 00417 int get_rowstride() const; 00419 00420 String get_option(const char *key) const; 00421 String get_option(const String& key) const; 00426 00428 00429 static Pointer<PixbufFormat> get_file_info(const char *filename, int *width, int *height); 00430 static Pointer<PixbufFormat> get_file_info(const String& filename, int *width, int *height); 00437 00440 00441 Pointer<Pixbuf> copy() const; 00447 00448 void fill(unsigned int pixel); 00453 00454 bool save(const String& filename, const char *type, G::Error *error, ...); 00474 00475 bool save(const char *filename, const char *type, char **option_keys, char **option_values, G::Error *error = 0); 00476 bool save(const String& filename, const char *type, char **option_keys, char **option_values, G::Error *error = 0); 00487 00488 bool save(const SaveSlot& slot, const char *type, G::Error *error, ...); 00500 00501 bool save(const SaveSlot& slot, const char *type, char **option_keys, char **option_values, G::Error *error = 0); 00511 00512 bool save(char **buffer, size_t *buffer_size, const char *type, G::Error *error, ...); 00526 00527 bool save(char **buffer, size_t *buffer_size, const char *type, char **option_keys, char **option_values, G::Error *error = 0); 00535 00536 Pointer<Pixbuf> add_alpha(bool substitute_color, unsigned char red, unsigned char green, unsigned char blue); 00550 00551 void copy_area(const Pixbuf& src, int src_x, int src_y, int width, int height, int dest_x, int dest_y); 00561 00562 void copy_area(const Pixbuf& src, const Rectangle& src_rect, int dest_x, int dest_y); 00569 00570 void saturate_and_pixelate(const Pixbuf& src, float saturation, bool pixelate); 00581 00582 void saturate_and_pixelate(float saturation, bool pixelate); 00592 00593 Pointer<Pixbuf> scale_simple(int width, int height, InterpType interp_type); 00608 00609 void scale 00610 ( 00611 const Pixbuf& src, 00612 int dest_x, 00613 int dest_y, 00614 int dest_width, 00615 int dest_height, 00616 double offset_x, 00617 double offset_y, 00618 double scale_x, 00619 double scale_y, 00620 InterpType interp_type 00621 ); 00640 00641 void scale 00642 ( 00643 const Pixbuf& src, 00644 const Rectangle& dest_rect, 00645 double offset_x, 00646 double offset_y, 00647 double scale_x, 00648 double scale_y, 00649 InterpType interp_type 00650 ); 00665 00666 void composite 00667 ( 00668 const Pixbuf& src, 00669 int dest_x, 00670 int dest_y, 00671 int dest_width, 00672 int dest_height, 00673 double offset_x, 00674 double offset_y, 00675 double scale_x, 00676 double scale_y, 00677 InterpType interp_type, 00678 int overall_alpha 00679 ); 00695 00696 void composite 00697 ( 00698 const Pixbuf& src, 00699 const Rectangle& dest_rect, 00700 double offset_x, 00701 double offset_y, 00702 double scale_x, 00703 double scale_y, 00704 InterpType interp_type, 00705 int overall_alpha 00706 ); 00719 00720 void composite_color 00721 ( 00722 const Pixbuf& src, 00723 int dest_x, 00724 int dest_y, 00725 int dest_width, 00726 int dest_height, 00727 double offset_x, 00728 double offset_y, 00729 double scale_x, 00730 double scale_y, 00731 InterpType interp_type, 00732 int overall_alpha, 00733 int check_x, 00734 int check_y, 00735 int check_size, 00736 unsigned int color1, 00737 unsigned int color2 00738 ); 00762 00763 void composite_color 00764 ( 00765 const Pixbuf& src, 00766 const Rectangle& dest_rect, 00767 double offset_x, 00768 double offset_y, 00769 double scale_x, 00770 double scale_y, 00771 InterpType interp_type, 00772 int overall_alpha, 00773 const Point& check_offset, 00774 int check_size, 00775 unsigned int color1, 00776 unsigned int color2 00777 ); 00798 00799 Pointer<Pixbuf> composite_color_simple 00800 ( 00801 int width, 00802 int height, 00803 InterpType interp_type, 00804 int overall_alpha, 00805 int check_size, 00806 unsigned int color1, 00807 unsigned int color2 00808 00809 ); 00820 00824 00825 void render_threshold_alpha 00826 ( 00827 Bitmap& bitmap, 00828 int src_x, 00829 int src_y, 00830 int dest_x, 00831 int dest_y, 00832 int width, 00833 int height, 00834 int alpha_threshold 00835 ); 00847 00848 void render_pixmap_and_mask 00849 ( 00850 Pointer<Pixmap> *pixmap_return, 00851 Pointer<Bitmap> *mask_return, 00852 int alpha_threshold, 00853 Colormap *colormap = 0 00854 ); 00873 00874 bool get_from_drawable 00875 ( 00876 const Drawable& src, 00877 int src_x, 00878 int src_y, 00879 int dest_x, 00880 int dest_y, 00881 int width, 00882 int height, 00883 Colormap *colormap = 0 00884 ); 00932 00933 bool get_from_image 00934 ( 00935 const Image& src, 00936 int src_x, 00937 int src_y, 00938 int dest_x, 00939 int dest_y, 00940 int width, 00941 int height, 00942 Colormap *colormap = 0 00943 ); 00954 00956 }; 00957 00958 } // namespace Gdk 00959 00960 } // namespace GFC 00961 00962 #include <gfc/gdk-pixbuf/inline/pixbuf.inl> 00963 00964 #endif // GFC_GDK_PIXBUF_HH 00965

Generated on Tue Aug 24 00:34:31 2004 for GFC-UI by doxygen 1.3.8