SixLabors / ImageSharp.Drawing

:pen: Extensions to ImageSharp containing a cross-platform 2D polygon manipulation API and drawing operations.
https://sixlabors.com/products/imagesharp-drawing/
Other
285 stars 38 forks source link

Fill issue when using ImageBrush #221

Closed x3x4x5 closed 2 years ago

x3x4x5 commented 2 years ago

Prerequisites

Description

I think there is a problem when using Fill method with ImageBrush. When we use a rectangle for an image, squares are always drawn.

Steps to Reproduce

img.Fill(new ImageBrush(frameImage), new RectangleF(Convert.ToInt32(0), Convert.ToInt32(0), Convert.ToInt32(2000), Convert.ToInt32(2000)));

ImageBrush (frameImage): source

Result: result

I think the problem is in Apply method of ImageBrush class. I think Height should be used for sourceY calculation and not Width.

image

System Configuration

MarkusGrafBuildDesk commented 2 years ago

If the ImageBrush is orientated landscape, (e.g. width =125, height =90) you will get the exception _"Specified argument was out of the range of valid values. (Parameter 'DangerousGetRowSpan(99). Y was out of range. Height=90')".

Applying the change suggested above fixes also this issue.

JimBobSquarePants commented 2 years ago

Thanks @x3x4x5 for providing so much information and also the suggested fix!

@MarkusGrafBuildDesk I can confirm that the PR #223 containing the fix works for your provided dimensions in both landscape and portrait. Thanks for the additional information.