Hi ,
We are reading the clipping path stored in image using a third party library.For reading paths we are refereeing to Adobe Photoshop File Formats Specification
we are not able to read the path properly if the paths were created using low tolerance value (0.5 to 0.7)
During conversion of selection in work path, PS asks for a tolerance value which can vary from 0.5 to 10.0 pixels. So if we choose any value less than 0.8 pixels, we are not able to read the complete path in our application.For any value of tolerance between 0.8 to 10.0 (both inclusive), we are able to reader the path properly.
code snippet -
byte[] readPath( tree)
{
Byte[] pathData = null;
try
{
bool nextArrayIsPathData = false;
for (int i = 0; i < tree.Children.Count; i++)
{
// If the child is a leaf (where the data lives), then we parse the data.
if (tree.Children[i] is Leaf)
{
Leaf leaf = (Leaf)tree.Children[i];
// If the data is an array get the serialized data, otherwise just get the data.
if (leaf.Data.GetType().IsArray)
{
if (nextArrayIsPathData == true)
{
return (Byte[])leaf.Data;
}
}
else
{
//When Paths data is found leaf tag is 1008, however according to Adobe's spec. for path name leaf tag should be 2999
//See adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_17587
if ((leaf.Tag == 1008) || (leaf.Tag == 2999))
{
nextArrayIsPathData = true;
}
}
}
// If the child is a tree (which holds more trees and/or leaves), then recursively call the function.
else if (tree.Children[i] is Tree)
{
Tree tree2 = tree.Children[i];
if (pathData == null)
{
pathData = readPath(tree2);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return pathData;
}
Can you please let us know why we are facing the issue in case of low tolerance value? and is there any workaround for this issue?
Thank you in advance.
Regards,
Mithun