[maemo-commits] [maemo-commits] r19237 - in projects/haf/branches/sapwood/rgb-only: . engine
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Aug 28 15:52:54 EEST 2009
- Previous message: [maemo-commits] r19236 - in projects/haf/branches/sapwood/rgb-only: . engine
- Next message: [maemo-commits] r19238 - projects/haf/branches/sapwood/rgb-only/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: herzi Date: 2009-08-28 15:52:52 +0300 (Fri, 28 Aug 2009) New Revision: 19237 Modified: projects/haf/branches/sapwood/rgb-only/ChangeLog projects/haf/branches/sapwood/rgb-only/engine/sapwood-pixmap.c Log: 2009-08-20 Christian Dywan <christian at lanedo.com> NB#118393 - Crop images if they are supposed to be rendered too small * engine/sapwood-pixmap.c (sapwood_crop_pixmap), (sapwood_pixmap_render_rects): Implement sapwood_crop_pixmap and crop the image if it is too big. Modified: projects/haf/branches/sapwood/rgb-only/ChangeLog =================================================================== --- projects/haf/branches/sapwood/rgb-only/ChangeLog 2009-08-28 12:52:41 UTC (rev 19236) +++ projects/haf/branches/sapwood/rgb-only/ChangeLog 2009-08-28 12:52:52 UTC (rev 19237) @@ -1,3 +1,11 @@ +2009-08-20 Christian Dywan <christian at lanedo.com> + + NB#118393 - Crop images if they are supposed to be rendered too small + + * engine/sapwood-pixmap.c (sapwood_crop_pixmap), + (sapwood_pixmap_render_rects): Implement sapwood_crop_pixmap and crop + the image if it is too big. + 2009-08-07 Alejandro G. Castro <alex at igalia.com> Added a new debug enviroment option to enable the synchronous X Modified: projects/haf/branches/sapwood/rgb-only/engine/sapwood-pixmap.c =================================================================== --- projects/haf/branches/sapwood/rgb-only/engine/sapwood-pixmap.c 2009-08-28 12:52:41 UTC (rev 19236) +++ projects/haf/branches/sapwood/rgb-only/engine/sapwood-pixmap.c 2009-08-28 12:52:52 UTC (rev 19237) @@ -350,6 +350,63 @@ } } +static void +sapwood_crop_pixmap (GdkPixmap *pixmap, + int x, + int y, + int requested_width, + int requested_height, + int original_width, + int original_height) +{ + cairo_t *cr; + cairo_surface_t *surface; + int w1, h1, w2, h2; + + cr = gdk_cairo_create (pixmap); + surface = cairo_get_target (cr); + + w1 = requested_width / 2; + h1 = requested_height / 2; + w2 = (requested_width + 1) / 2; + h2 = (requested_height + 1) / 2; + + /* top-left */ + cairo_save (cr); + cairo_set_source_surface (cr, surface, x, y); + cairo_rectangle (cr, x, y, w2, h2); + cairo_clip (cr); + cairo_paint (cr); + cairo_restore (cr); + + /* top-right */ + cairo_save (cr); + cairo_set_source_surface (cr, surface, x + requested_width - original_width, y); + cairo_rectangle (cr, x + w1, y, w2, h2); + cairo_clip (cr); + cairo_paint (cr); + cairo_restore (cr); + + /* bottom-left */ + cairo_save (cr); + cairo_set_source_surface (cr, surface, x, y + requested_height - original_height); + cairo_rectangle (cr, x, y + h1, w2, h2); + cairo_clip (cr); + cairo_paint (cr); + cairo_restore (cr); + + /* bottom-right */ + cairo_save (cr); + cairo_set_source_surface (cr, surface, x + requested_width - original_width, + y + requested_height - original_height); + cairo_rectangle (cr, x + w1, y + h1, w2, h2); + cairo_clip (cr); + cairo_paint (cr); + cairo_restore (cr); + + cairo_destroy (cr); +} + void sapwood_pixmap_render_rects (SapwoodPixmap *self, GtkWidget *widget, @@ -427,7 +484,10 @@ cairo_translate (cr, draw_x, draw_y); - if (width != tmp_width || height != tmp_height) + if (width > 0 && width < tmp_width || height > 0 && height < tmp_height) + sapwood_crop_pixmap (tmp, 0, 0, width, height, + self->width, self->height); + else if (width != tmp_width || height != tmp_height) { cairo_scale (cr, (double)width / (double)tmp_width, (double)height / (double)tmp_height);
- Previous message: [maemo-commits] r19236 - in projects/haf/branches/sapwood/rgb-only: . engine
- Next message: [maemo-commits] r19238 - projects/haf/branches/sapwood/rgb-only/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]