Skip to content

Commit 746f10f

Browse files
Merge branch 'main' into js/fix-241
2 parents 2534877 + 83747f4 commit 746f10f

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

src/ImageSharp.Drawing/Processing/ImageBrush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public ImageBrushApplicator(
137137
get
138138
{
139139
int srcX = ((x - this.offsetX) % this.sourceRegion.Width) + this.sourceRegion.X;
140-
int srcY = ((y - this.offsetY) % this.sourceRegion.Width) + this.sourceRegion.Y;
140+
int srcY = ((y - this.offsetY) % this.sourceRegion.Height) + this.sourceRegion.Y;
141141
return this.sourceFrame[srcX, srcY];
142142
}
143143
}

src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void Draw(IEnumerable<DrawingOperation> operations)
7070
int startX = operation.RenderLocation.X;
7171
int offsetSpan = 0;
7272

73-
if (startX + buffer.Height < 0)
73+
if (startY + buffer.Height < 0)
7474
{
7575
continue;
7676
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System.Numerics;
5+
using SixLabors.Fonts;
6+
using SixLabors.ImageSharp.Drawing.Processing;
7+
using SixLabors.ImageSharp.PixelFormats;
8+
using SixLabors.ImageSharp.Processing;
9+
using Xunit;
10+
11+
namespace SixLabors.ImageSharp.Drawing.Tests.Issues
12+
{
13+
public class Issue_270
14+
{
15+
[Fact]
16+
public void DoesNotThrowArgumentOutOfRangeException()
17+
{
18+
if (!TestEnvironment.IsWindows)
19+
{
20+
return;
21+
}
22+
23+
const int sourceImageWidth = 256;
24+
const int sourceImageHeight = 256;
25+
const int targetImageWidth = 350;
26+
const int targetImageHeight = 350;
27+
const float minimumCrashingFontSize = 47;
28+
const string text = "Hello, World!";
29+
30+
Font font = SystemFonts.CreateFont("Arial", minimumCrashingFontSize);
31+
Pen pen = Pens.Solid(Color.Black, 1);
32+
33+
using Image<Rgba32> targetImage = new(targetImageWidth, targetImageHeight, Color.Wheat);
34+
using Image<Rgba32> imageBrushImage = new(sourceImageWidth, sourceImageHeight, Color.Black);
35+
ImageBrush imageBrush = new(imageBrushImage);
36+
37+
targetImage.Mutate(x => x.DrawText(CreateTextOptions(font, targetImageWidth), text, imageBrush, pen));
38+
}
39+
40+
private static RichTextOptions CreateTextOptions(Font font, int wrappingLength)
41+
=> new(font)
42+
{
43+
Origin = new Vector2(175, 175),
44+
TextAlignment = TextAlignment.Center,
45+
LayoutMode = LayoutMode.HorizontalTopBottom,
46+
WrappingLength = wrappingLength,
47+
WordBreaking = WordBreaking.Standard,
48+
HorizontalAlignment = HorizontalAlignment.Center,
49+
VerticalAlignment = VerticalAlignment.Center,
50+
KerningMode = KerningMode.None,
51+
};
52+
}
53+
}

0 commit comments

Comments
 (0)