We started using the System.Drawing.Graphics.DrawImage function that supports a source and destination rectangle, but found that the output was incorrect. After digging into the source we determined that the problem originated in the "image.c" file of the libgdi source. The translation of the matrix was being applied using both the source and destination coordinates after scaling, even though the source and destination rectangles are at different scales. The fix is to apply the source translation before the matrix scale and the destination translation afterwards.
The result of this problem can be seen in the following bug: https://bugzilla.novell.com/show_bug.cgi?GoAheadAndLogIn=1&id=529887 I have attached a patch (which is against the 2.6.4 release of libgdi but can also apply to the trunk since that file has not been changed). Kind regards, Dan Parnham and Justen Hyde 436ada0853 436ada0853
--- image.c 2010-04-28 13:57:42.449171092 +0100 +++ image.c.new 2010-04-28 14:19:23.799197284 +0100 @@ -710,8 +710,9 @@ } } + cairo_matrix_translate(&mat, srcx, srcy); cairo_matrix_scale (&mat, srcwidth / dstwidth, srcheight / dstheight); - cairo_matrix_translate (&mat, srcx - (dstx + posx), srcy - (dsty + posy)); + cairo_matrix_translate (&mat, - (dstx + posx), - (dsty + posy)); pattern = cairo_pattern_create_for_surface(cur_image->surface); cairo_pattern_set_matrix (pattern, &mat); @@ -760,10 +761,12 @@ filter = cairo_pattern_create_for_surface (image->surface); cairo_pattern_set_filter (filter, gdip_get_cairo_filter (graphics->interpolation)); + cairo_matrix_translate(&mat, srcx, srcy); + if (!gdip_near_zero(srcwidth - dstwidth) || !gdip_near_zero(srcheight - dstheight)) cairo_matrix_scale (&mat, srcwidth / dstwidth, srcheight / dstheight); - cairo_matrix_translate (&mat, srcx - dstx, srcy - dsty); + cairo_matrix_translate(&mat, -dstx, -dsty); pattern = cairo_pattern_create_for_surface(image->surface); cairo_pattern_set_matrix (pattern, &mat);
_______________________________________________ Mono-devel-list mailing list [email protected] http://lists.ximian.com/mailman/listinfo/mono-devel-list
