Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
SebastianR  
#1 Posted : Tuesday, May 16, 2017 3:35:45 AM(UTC)
SebastianR

Rank: Advanced Member

Groups: Member
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 9 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?
Fedor  
#2 Posted : Tuesday, May 16, 2017 7:57:28 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,558

Thanks: 5 times
Was thanked: 62 time(s) in 61 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
thanks 1 user thanked Fedor for this useful post.
SebastianR on 5/17/2017(UTC)
Users browsing this topic
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.