Main Page - Header
Author: The Inti Development Team

Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# pixbuf.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002-2003 The Inti 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 INTI_GDK_PIXBUF_H
    00025 #define INTI_GDK_PIXBUF_H
    00026
    00027 #ifndef INTI_OBJECT_H
    00028 #include <inti/object.h>
    00029 #endif
    00030
    00031 #ifndef INTI_G_OBJECT_H
    00032 #include <inti/glib/object.h>
    00033 #endif
    00034
    00035 #ifndef INTI_GDK_TYPES_H
    00036 #include <inti/gdk/types.h>
    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 Inti {
    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 ReferencedObject
    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 { return format_; }
    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 reference = true);
    00207
    00209
    00210 public:
    00213
    00214         Pixbuf(const Pixbuf& src, int src_x, int src_y, int width, int height);
    00225
    00226         Pixbuf(const String& filename, G::Error *error = 0);
    00246
    00247         Pixbuf(const unsigned char *data, int width, int height, int rowstride, bool has_alpha,
    00248                GdkPixbufDestroyNotify destroy_fn = 0, void *destroy_fn_data = 0,
    00249                int bits_per_sample = 8, Colorspace colorspace = COLORSPACE_RGB);
    00269
    00270         Pixbuf(const char **data);
    00275
    00276         Pixbuf(int data_length, const unsigned char *data, bool copy_pixels, G::Error *error = 0);
    00303
    00304         virtual ~Pixbuf();
    00306
    00310
    00311         GdkPixbuf* gdk_pixbuf() const { return (GdkPixbuf*)instance; }
    00313
    00314         operator GdkPixbuf* () const;
    00316
    00317         Colorspace get_colorspace() const;
    00319
    00320         int get_n_channels() const;
    00322
    00323         bool get_has_alpha() const;
    00325
    00326         int get_bits_per_sample() const;
    00328
    00329         unsigned char* get_pixels() const;
    00332
    00333         int get_width() const;
    00335
    00336         int get_height() const;
    00338
    00339         int get_rowstride() const;
    00341
    00342         String get_option(const String& key) const;
    00347
    00349
    00350         static Pointer<Pixbuf> create(int width, int height, bool has_alpha, int bits_per_sample = 8, Colorspace colorspace = COLORSPACE_RGB);
    00363
    00364         static Pointer<Pixbuf> create(const Drawable& drawable, int x, int y, int width, int height, Colormap *colormap = 0);
    00375
    00376         static Pointer<Pixbuf> create(const Image& image, int x, int y, int width, int height, Colormap *colormap = 0);
    00385
    00386         static bool get_formats(std::vector<Pointer<PixbufFormat> >& formats);
    00390
    00393
    00394         Pointer<Pixbuf> copy() const;
    00400
    00401         void fill(unsigned int pixel);
    00406
    00407         bool save(const String& filename, const char *type, G::Error *error, ...);
    00427
    00428         bool save(const String& filename, const char *type, char **option_keys, char **option_values, G::Error *error = 0);
    00439
    00440         Pointer<Pixbuf> add_alpha(bool substitute_color, unsigned char red, unsigned char green, unsigned char blue);
    00454
    00455         void copy_area(const Pixbuf& src, int src_x, int src_y, int width, int height, int dest_x, int dest_y);
    00465
    00466         void copy_area(const Pixbuf& src, const Rectangle& src_rect, int dest_x, int dest_y);
    00473
    00474         void saturate_and_pixelate(const Pixbuf& src, float saturation, bool pixelate);
    00485
    00486         void saturate_and_pixelate(float saturation, bool pixelate);
    00496
    00497         Pointer<Pixbuf> scale_simple(int width, int height, InterpType interp_type);
    00512
    00513         void scale
    00514         (
    00515                 const Pixbuf& src,
    00516                 int dest_x,
    00517                 int dest_y,
    00518                 int dest_width,
    00519                 int dest_height,
    00520                 double offset_x,
    00521                 double offset_y,
    00522                 double scale_x,
    00523                 double scale_y,
    00524                 InterpType interp_type
    00525         );
    00544
    00545         void scale
    00546         (
    00547                 const Pixbuf& src,
    00548                 const Rectangle& dest_rect,
    00549                 double offset_x,
    00550                 double offset_y,
    00551                 double scale_x,
    00552                 double scale_y,
    00553                 InterpType interp_type
    00554         );
    00569
    00570         void composite
    00571         (
    00572                 const Pixbuf& src,
    00573                 int dest_x,
    00574                 int dest_y,
    00575                 int dest_width,
    00576                 int dest_height,
    00577                 double offset_x,
    00578                 double offset_y,
    00579                 double scale_x,
    00580                 double scale_y,
    00581                 InterpType interp_type,
    00582                 int overall_alpha
    00583         );
    00599
    00600         void composite
    00601         (
    00602                 const Pixbuf& src,
    00603                 const Rectangle& dest_rect,
    00604                 double offset_x,
    00605                 double offset_y,
    00606                 double scale_x,
    00607                 double scale_y,
    00608                 InterpType interp_type,
    00609                 int overall_alpha
    00610         );
    00623
    00624         void composite_color
    00625         (
    00626                 const Pixbuf& src,
    00627                 int dest_x,
    00628                 int dest_y,
    00629                 int dest_width,
    00630                 int dest_height,
    00631                 double offset_x,
    00632                 double offset_y,
    00633                 double scale_x,
    00634                 double scale_y,
    00635                 InterpType interp_type,
    00636                 int overall_alpha,
    00637                 int check_x,
    00638                 int check_y,
    00639                 int check_size,
    00640                 unsigned int color1,
    00641                 unsigned int color2
    00642         );
    00666
    00667         void composite_color
    00668         (
    00669                 const Pixbuf& src,
    00670                 const Rectangle& dest_rect,
    00671                 double offset_x,
    00672                 double offset_y,
    00673                 double scale_x,
    00674                 double scale_y,
    00675                 InterpType interp_type,
    00676                 int overall_alpha,
    00677                 const Point& check_offset,
    00678                 int check_size,
    00679                 unsigned int color1,
    00680                 unsigned int color2
    00681         );
    00702
    00703         Pointer<Pixbuf> composite_color_simple
    00704         (
    00705                 int width,
    00706                 int height,
    00707                 InterpType interp_type,
    00708                 int overall_alpha,
    00709                 int check_size,
    00710                 unsigned int color1,
    00711                 unsigned int color2
    00712
    00713         );
    00724
    00728
    00729         void render_threshold_alpha
    00730         (
    00731                 Bitmap& bitmap,
    00732                 int src_x,
    00733                 int src_y,
    00734                 int dest_x,
    00735                 int dest_y,
    00736                 int width,
    00737                 int height,
    00738                 int alpha_threshold
    00739         );
    00751
    00752         void render_pixmap_and_mask
    00753         (
    00754                 Pointer<Pixmap> *pixmap_return,
    00755                 Pointer<Bitmap> *mask_return,
    00756                 int alpha_threshold,
    00757                 Colormap *colormap = 0
    00758         );
    00777
    00778         bool get_from_drawable
    00779         (
    00780                 const Drawable& src,
    00781                 int src_x,
    00782                 int src_y,
    00783                 int dest_x,
    00784                 int dest_y,
    00785                 int width,
    00786                 int height,
    00787                 Colormap *colormap = 0
    00788         );
    00836
    00837         bool get_from_image
    00838         (
    00839                 const Image& src,
    00840                 int src_x,
    00841                 int src_y,
    00842                 int dest_x,
    00843                 int dest_y,
    00844                 int width,
    00845                 int height,
    00846                 Colormap *colormap = 0
    00847         );
    00858
    00860 };
    00861
    00862 } // namespace Gdk
    00863
    00864 } // namespace Inti
    00865
    00866 #endif // INTI_GDK_PIXBUF_H
    00867

Main Page - Footer