diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-03-15 12:43:34 +0000 |
|---|---|---|
| committer | John Smith <removethis.john.q.public@bigmail.com> | 2012-03-15 12:43:34 +0000 |
| commit | a0c24c953a1ba7fb285050dfe26e2bd41149bf30 (patch) | |
| tree | dacdad05159b58cd621b0f1814586b5629f58246 /src/ui/widget | |
| parent | buildtool: don't create build output folders in parallel. superfast in series... (diff) | |
| download | inkscape-a0c24c953a1ba7fb285050dfe26e2bd41149bf30.tar.gz inkscape-a0c24c953a1ba7fb285050dfe26e2bd41149bf30.zip | |
Fix for 903671 : Fill and Stroke Gradient list and Gradient Editor
(bzr r11089)
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/color-preview.cpp | 48 | ||||
| -rw-r--r-- | src/ui/widget/color-preview.h | 3 |
2 files changed, 50 insertions, 1 deletions
diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index 8bb523831..244e2b4e3 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -114,6 +114,54 @@ ColorPreview::paint (GdkRectangle *area) cairo_destroy(ct); } +GdkPixbuf* +ColorPreview::toPixbuf (int width, int height) +{ + GdkRectangle carea; + gint w2; + w2 = width / 2; + + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); + cairo_t *ct = cairo_create(s); + + /* Transparent area */ + carea.x = 0; + carea.y = 0; + carea.width = w2; + carea.height = height; + + cairo_pattern_t *checkers = ink_cairo_pattern_create_checkerboard(); + + cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height); + cairo_set_source(ct, checkers); + cairo_fill_preserve(ct); + ink_cairo_set_source_rgba32(ct, _rgba); + cairo_fill(ct); + + cairo_pattern_destroy(checkers); + + /* Solid area */ + carea.x = w2; + carea.y = 0; + carea.width = width - w2; + carea.height = height; + + cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height); + ink_cairo_set_source_rgba32(ct, _rgba | 0xff); + cairo_fill(ct); + + cairo_destroy(ct); + cairo_surface_flush(s); + + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( cairo_image_surface_get_data(s), + GDK_COLORSPACE_RGB, TRUE, 8, + width, height, cairo_image_surface_get_stride(s), + ink_cairo_pixbuf_cleanup, s); + convert_pixbuf_argb32_to_normal(pixbuf); + + return pixbuf; +} + }}} /* diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h index f89e0ea42..d6d3da01c 100644 --- a/src/ui/widget/color-preview.h +++ b/src/ui/widget/color-preview.h @@ -24,13 +24,14 @@ class ColorPreview : public Gtk::Widget { public: ColorPreview (guint32 rgba); void setRgba32 (guint32 rgba); + GdkPixbuf* toPixbuf (int width, int height); protected: virtual void on_size_request (Gtk::Requisition *req); virtual void on_size_allocate (Gtk::Allocation &all); virtual bool on_expose_event (GdkEventExpose *event); void paint (GdkRectangle *area); - + guint32 _rgba; }; |
