diff --git a/ChangeLog b/ChangeLog index 28f7c33..558f42b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-09-06 Yavor Doganov + + * src/goocanvasimage.c (goo_canvas_image_is_item_at): Check + translucency of the pixel and return FALSE if alpha is 0. + 2017-11-23 Damon Chaplin * src/goocanvasitemmodel.c (goo_canvas_item_model_class_list_child_properties): diff --git a/src/goocanvasimage.c b/src/goocanvasimage.c index 28c948f..d04cbe9 100644 --- a/src/goocanvasimage.c +++ b/src/goocanvasimage.c @@ -463,11 +463,30 @@ goo_canvas_image_is_item_at (GooCanvasItemSimple *simple, { GooCanvasImage *image = (GooCanvasImage*) simple; GooCanvasImageData *image_data = image->image_data; + cairo_surface_t *surface; + unsigned char *rawdata; + guint32 *pixel; + int alpha, stride; if (x < image_data->x || (x > image_data->x + image_data->width) || y < image_data->y || (y > image_data->y + image_data->height)) return FALSE; + cairo_pattern_get_surface (image_data->pattern, &surface); + + if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_IMAGE + || cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) + return TRUE; + + cairo_surface_flush (surface); + rawdata = cairo_image_surface_get_data (surface); + stride = cairo_image_surface_get_stride (surface); + pixel = (guint32*) (rawdata + ((int) (y - image_data->y)) * stride); + alpha = (pixel[(int) (x - image_data->x)] & 0xff000000) >> 24; + + if (alpha == 0) + return FALSE; + return TRUE; }