Skip to content

Commit 02d04c8

Browse files
BorisTheBraveJimBobSquarePants
authored andcommitted
ImageBrush shouldn't Dispose of the image it is using. (#883)
Fixes #881
1 parent 4197e69 commit 02d04c8

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/ImageSharp.Drawing/Processing/ImageBrush{TPixel}.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public ImageBrushApplicator(ImageFrame<TPixel> target, ImageFrame<TPixel> image,
113113
/// <inheritdoc />
114114
public override void Dispose()
115115
{
116-
this.source.Dispose();
117116
}
118117

119118
/// <inheritdoc />
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Six Labors and contributors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System;
5+
6+
using SixLabors.ImageSharp.PixelFormats;
7+
using SixLabors.ImageSharp.Primitives;
8+
using SixLabors.ImageSharp.Processing;
9+
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
10+
using SixLabors.Primitives;
11+
using SixLabors.Shapes;
12+
13+
using Xunit;
14+
15+
// ReSharper disable InconsistentNaming
16+
17+
namespace SixLabors.ImageSharp.Tests.Drawing
18+
{
19+
[GroupOutput("Drawing")]
20+
public class FillImageBrushTests
21+
{
22+
[Fact]
23+
public void DoesNotDisposeImage()
24+
{
25+
using (var src = new Image<Rgba32>(5, 5))
26+
{
27+
var brush = new ImageBrush<Rgba32>(src);
28+
using (var dest = new Image<Rgba32>(10, 10))
29+
{
30+
dest.Mutate(c => c.Fill(brush, new Rectangle(0, 0, 10, 10)));
31+
dest.Mutate(c => c.Fill(brush, new Rectangle(0, 0, 10, 10)));
32+
}
33+
}
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)