This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
Aruky788  
#1 Posted : Sunday, February 5, 2017 2:30:12 AM(UTC)
Aruky788

Rank: Newbie

Groups: Guest
Joined: 2/5/2017(UTC)
Posts: 4

Hi,

I am currently testing the "Graphicmill" FrameWork.

I try to create a large picture from 2 pictures. The two pictures are placed side by side on the big picture.

The 2 pictures have both a clipping path with same names.

My problem is that I can not combine the both clipping path into 1 clipping path.

Is that possible? Can anyone give tips or code example?

Fedor  
#2 Posted : Sunday, February 5, 2017 11:37:42 PM(UTC)
Fedor

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)
Could you send us source images? It should help us to understand your requirements better.

You can either post files here or submit a case.

Best regards,

Fedor Skvortsov

Aruky788  
#3 Posted : Monday, February 6, 2017 4:21:31 AM(UTC)
Aruky788

Rank: Newbie

Groups: Guest
Joined: 2/5/2017(UTC)
Posts: 4

My source images:

1) source-image-1.jpg and 2) source-image-2.jpg

The result what i need, i have created with photoshop:

result-image.jpg

Fedor  
#4 Posted : Monday, February 6, 2017 7:19:01 PM(UTC)
Fedor

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)
You can copy 2 clipping paths to the result image using the following code:

Code:
using System;
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Transforms;

class Program
{
	private const int FirstPathId = 2000;

	private const int LastPathId = 2997;

	static void Main(string[] args)
	{
		using (var reader1 = new JpegReader("../../../source-image-1.jpg"))
		using (var reader2 = new JpegReader("../../../source-image-2.jpg"))
		using (var writer = new JpegWriter("../../../result.jpg"))
		using (var sourceBitmap1 = reader1.Frames[0].GetBitmap())
		using (var sourceBitmap2 = reader2.Frames[0].GetBitmap())
		using (var resultBitmap = new Bitmap(sourceBitmap1.Width + sourceBitmap2.Width,
			Math.Max(sourceBitmap1.Height, sourceBitmap1.Height)
			, sourceBitmap1.PixelFormat))
		{
			resultBitmap.Draw(sourceBitmap1, 0, 0, CombineMode.Copy);
			resultBitmap.Draw(sourceBitmap2, sourceBitmap1.Width, 0, CombineMode.Copy);

			var adobeResources = new Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary();

			// The clipping path has relatives coordinates (0.0f ... 1.f0). So we need to transform it.
			var clippingPath1 = reader1.ClippingPaths[0];

			var transform1 = new System.Drawing.Drawing2D.Matrix();
			transform1.Scale((float)sourceBitmap1.Width / (float)resultBitmap.Width, 1f);
			clippingPath1.ApplyTransform(transform1);

			adobeResources.Add(FirstPathId, new AdobeResourceBlock(clippingPath1.Name + "_1", clippingPath1.Data));


			var clippingPath2 = reader2.ClippingPaths[0];

			var transform2 = new System.Drawing.Drawing2D.Matrix();
			transform2.Translate((float)sourceBitmap1.Width / (float)resultBitmap.Width, 0);
			transform2.Scale((float)sourceBitmap2.Width / (float)resultBitmap.Width, 1f);

			clippingPath2.ApplyTransform(transform2);
	
			adobeResources.Add(FirstPathId + 1, new AdobeResourceBlock(clippingPath2.Name + "_2", clippingPath2.Data));


			writer.AdobeResources = adobeResources;


			Pipeline.Run(resultBitmap + writer);
		}

	}
}

Please let me know if you need to combine 2 paths.

clipping_path.png

Best regards,

Fedor Skvortsov

Aruky788  
#5 Posted : Tuesday, February 7, 2017 3:10:01 AM(UTC)
Aruky788

Rank: Newbie

Groups: Guest
Joined: 2/5/2017(UTC)
Posts: 4

I got that too.

My Problem:

As a result I need a path "Path 1", which is from the path "Path 1" from Source Image1 and from the path "Path 1" from Source Image 2.

I need to merge 2 Clipping Path in 1 Clipping Path "Path 1".

Is that possible?

Fedor  
#6 Posted : Wednesday, February 8, 2017 9:33:27 PM(UTC)
Fedor

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)
Currently, it is not possible. If you just concatenate two raw Adobe clipping path data blocks, it won't join these paths properly. You need to parse it (convert to a regular Path object) and do some math to make a union of these paths.

In theory, you can take Aurigma.GraphicsMill.Codecs.ClippingPath.Path.Data (raw Adobe data, clippingPath1.Data and clippingPath2.Data) and parse it yourself in accordance to Adobe Photoshop file specification. It may be a bit challenging (some Adobe structures are unusual, apparently due to the legacy reasons), but it is possible.

We don't have any plans to implement this feature in the product in the near future. However, if it is really important for you and you don't want to write the Adobe data parser yourself, we could consider implementing it as a custom work. Please let me know if you are interested.

Edited by user Wednesday, February 8, 2017 9:57:16 PM(UTC)  | Reason: Not specified

Best regards,

Fedor Skvortsov

Aruky788  
#7 Posted : Wednesday, February 8, 2017 10:31:29 PM(UTC)
Aruky788

Rank: Newbie

Groups: Guest
Joined: 2/5/2017(UTC)
Posts: 4

Thank you very much for your effort.

I will try to merge the paths, as you have suggested. This function is very important for my work.

Users browsing this topic
Guest (4)
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.