Rank: Advanced Member
Groups: Guest
Joined: 5/10/2017(UTC) Posts: 33
Thanks: 10 times Was thanked: 1 time(s) in 1 post(s)
|
I have an image (see attachment) which contains a clippingpath with multiple subPaths. One path (Cyan area) ist completely embedded in the area (Magenta) of another. The area of the inner path is not cropped, when I create a mask from the paths, but the other one (Yellow) is. PathForTest.tif (1,856kb) downloaded 15 time(s). This one from the tutorial works as expected Code:
using (var reader = ImageReader.Create(@"input.tif"))
using (var bitmap = reader.Frames[0].GetBitmap())
using (var maskBitmap = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format8bppGrayscale, System.Drawing.Color.Black))
using (var graphics = maskBitmap.GetAdvancedGraphics())
{
var grPath = Aurigma.GraphicsMill.AdvancedDrawing.Path.Create(reader.ClippingPaths[0], reader.Width, reader.Height);
graphics.FillPath(new SolidBrush(new GrayscaleColor(255)), grPath);
bitmap.Channels.SetAlpha(maskBitmap);
bitmap.Save(System.IO.Path.GetTempPath() + "result.tif");
}
This is mine and it does not: Code:using (var reader = ImageReader.Create(@"input.tif"))
using (var maskGen = new ImageGenerator(new GraphicsContainer(reader), PixelFormat.Format8bppGrayscale, RgbColor.Black))
using (var graphics = maskGen.GraphicsContainer.GetGraphics())
using (var bitmap = new Bitmap())
{
var graphicsPath = reader.ClippingPaths[0].CreateGraphicsPath(reader.Width, reader.Height);
graphics.FillPath(new SolidBrush(new GrayscaleColor(255)), Aurigma.GraphicsMill.AdvancedDrawing.Path.Create(graphicsPath));
using (var setAlpha = new SetAlpha(maskGen))
{
(reader + setAlpha + bitmap).Run();
bitmap.Save(System.IO.Path.GetTempPath() + "result.tif");
}
}
I can't see the difference. I already tracked it down to the creation of the mask, which is wrong in the way that the blue area is not marked to crop. What do I have to do to correct this issue?
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Please try this code: Code:using (var reader = ImageReader.Create("../../../PathForTest.tif"))
using (var maskGen = new ImageGenerator(reader.Width, reader.Height, PixelFormat.Format8bppGrayscale, RgbColor.Black))
using (var drawer = new Drawer())
using (var bitmap = new Bitmap())
{
var graphicsPath = Aurigma.GraphicsMill.AdvancedDrawing.Path.Create(reader.ClippingPaths[0], reader.Width, reader.Height);
drawer.Draw += (sender, e) =>
{
e.Graphics.FillPath(new SolidBrush(new GrayscaleColor(255)), graphicsPath);
};
using (var setAlpha = new SetAlpha(maskGen + drawer))
{
(reader + setAlpha + bitmap).Run();
bitmap.Save("../../../result.tif");
}
}
Edited by user Tuesday, May 16, 2017 7:59:26 AM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
1 user thanked Fedor for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.