[gegl-gtk] Use cairo API to calculate stride (bug 733357)
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl-gtk] Use cairo API to calculate stride (bug 733357)
- Date: Fri, 18 Jul 2014 16:52:58 +0000 (UTC)
commit 5dbb89dc0518efa047595cdb63b0b3265422cd30
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Jul 18 15:57:46 2014 +0200
Use cairo API to calculate stride (bug 733357)
The cairo documentation recommends this because the stride maybe larger
than width * bytes_per_pixel to provide proper alignment for each pixel
and row.
gegl-gtk/internal/view-helper.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gegl-gtk/internal/view-helper.c b/gegl-gtk/internal/view-helper.c
index cebf487..98289fd 100644
--- a/gegl-gtk/internal/view-helper.c
+++ b/gegl-gtk/internal/view-helper.c
@@ -243,13 +243,15 @@ view_helper_draw(ViewHelper *self, cairo_t *cr, GdkRectangle *rect)
cairo_surface_t *surface = NULL;
guchar *buf = NULL;
GeglRectangle roi;
+ gint stride;
roi.x = self->x + rect->x;
roi.y = self->y + rect->y;
roi.width = rect->width;
roi.height = rect->height;
- buf = g_malloc((roi.width) * (roi.height) * 4);
+ stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, roi.width);
+ buf = g_malloc(stride * roi.height);
gegl_node_blit(self->node,
self->scale,
@@ -262,7 +264,7 @@ view_helper_draw(ViewHelper *self, cairo_t *cr, GdkRectangle *rect)
surface = cairo_image_surface_create_for_data(buf,
CAIRO_FORMAT_ARGB32,
roi.width, roi.height,
- roi.width * 4);
+ stride);
cairo_set_source_surface(cr, surface, rect->x, rect->y);
cairo_paint(cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]