kopia lustrzana https://github.com/njcrawford/EmbroideryReader
				
				
				
			Found values for color table up to 61, added embroideryInfo to project
							rodzic
							
								
									5bc71cd0ed
								
							
						
					
					
						commit
						01db6ea0e9
					
				| 
						 | 
				
			
			@ -0,0 +1,326 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Drawing;
 | 
			
		||||
 | 
			
		||||
namespace embroideryReader
 | 
			
		||||
{
 | 
			
		||||
    public class stitchBlock
 | 
			
		||||
    {
 | 
			
		||||
        public System.Drawing.Color color;
 | 
			
		||||
        public Int32 colorIndex;
 | 
			
		||||
        public Int32 stitchesTotal;
 | 
			
		||||
        public Point[] stitches;
 | 
			
		||||
        public stitchBlock()
 | 
			
		||||
        {
 | 
			
		||||
            color = System.Drawing.Color.Black;
 | 
			
		||||
            //stitches = new List<System.Drawing.Point>();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public struct intPair
 | 
			
		||||
    {
 | 
			
		||||
        public int a;
 | 
			
		||||
        public int b;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public class PesFile
 | 
			
		||||
    {
 | 
			
		||||
        //private long bytesRead = 0;
 | 
			
		||||
        System.IO.BinaryReader fileIn;
 | 
			
		||||
        Random rnd = new Random();
 | 
			
		||||
        int stitchCount = 0;
 | 
			
		||||
        int stitchesLeft = 0;
 | 
			
		||||
        int skipStitches = 0;
 | 
			
		||||
        //int minX = int.MaxValue;
 | 
			
		||||
        //int minY = int.MaxValue;
 | 
			
		||||
        //int maxX = int.MinValue;
 | 
			
		||||
        //int maxY = int.MinValue;
 | 
			
		||||
        int imageWidth;
 | 
			
		||||
        int imageHeight;
 | 
			
		||||
        int lastColorIndex = -1;
 | 
			
		||||
        string _filename;
 | 
			
		||||
        public List<Int16> pesHeader = new List<short>();
 | 
			
		||||
        public List<Int16> embOneHeader = new List<short>();
 | 
			
		||||
        public List<Int16> csewsegHeader = new List<short>();
 | 
			
		||||
        public List<stitchBlock> blocks = new List<stitchBlock>();
 | 
			
		||||
        public List<intPair> afterStictchesTable = new List<intPair>();
 | 
			
		||||
 | 
			
		||||
        Int64 startStitches = 0;
 | 
			
		||||
 | 
			
		||||
        bool _readyToUse = false;
 | 
			
		||||
 | 
			
		||||
        public PesFile(string filename)
 | 
			
		||||
        {
 | 
			
		||||
            OpenFile(filename);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OpenFile(string filename)
 | 
			
		||||
        {
 | 
			
		||||
            //string message = "";
 | 
			
		||||
            _filename = filename;
 | 
			
		||||
            //string filename;
 | 
			
		||||
            //openFileDialog1.ShowDialog();
 | 
			
		||||
            //filename = openFileDialog1.FileName;
 | 
			
		||||
            //if (!System.IO.File.Exists(filename))
 | 
			
		||||
            //{
 | 
			
		||||
            //    return;
 | 
			
		||||
            //}
 | 
			
		||||
            //fileIn = new System.IO.BinaryReader(System.IO.File.Open("118866.pes", System.IO.FileMode.Open));
 | 
			
		||||
            //fileIn = new System.IO.BinaryReader(System.IO.File.Open("144496.pes", System.IO.FileMode.Open));
 | 
			
		||||
            fileIn = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open));
 | 
			
		||||
            //charIn = fileIn.ReadChar();
 | 
			
		||||
            for (int i = 0; i < 8; i++)//8 bytes
 | 
			
		||||
            {
 | 
			
		||||
                //message += fileIn.ReadChar();
 | 
			
		||||
                //bytesRead++;
 | 
			
		||||
                fileIn.ReadChar();
 | 
			
		||||
            }
 | 
			
		||||
            //message += Environment.NewLine;
 | 
			
		||||
            for (int i = 0; i < 8; i++)//16 bytes
 | 
			
		||||
            {
 | 
			
		||||
                pesHeader.Add(fileIn.ReadInt16());
 | 
			
		||||
                //message += fileIn.ReadInt16().ToString();
 | 
			
		||||
                //message += Environment.NewLine;
 | 
			
		||||
                //bytesRead += 2;
 | 
			
		||||
            }
 | 
			
		||||
            for (int i = 0; i < 7; i++)//7 bytes
 | 
			
		||||
            {
 | 
			
		||||
                //message += fileIn.ReadChar();
 | 
			
		||||
                //bytesRead++;
 | 
			
		||||
                fileIn.ReadChar();
 | 
			
		||||
            }
 | 
			
		||||
            //message += Environment.NewLine;
 | 
			
		||||
            //MessageBox.Show(message);
 | 
			
		||||
 | 
			
		||||
            //message = "";
 | 
			
		||||
            //int headerValNum = 1;
 | 
			
		||||
            Int16 tmpval;
 | 
			
		||||
            for (int i = 0; i < 33; i++) //read 66 bytes
 | 
			
		||||
            {
 | 
			
		||||
                tmpval = fileIn.ReadInt16();
 | 
			
		||||
                embOneHeader.Add(tmpval);
 | 
			
		||||
                switch (i)
 | 
			
		||||
                {
 | 
			
		||||
                    case 23:
 | 
			
		||||
                        imageWidth = tmpval;
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 24:
 | 
			
		||||
                        imageHeight = tmpval;
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                //message += tmpval.ToString();
 | 
			
		||||
                //if (headerValNum % 3 == 0)
 | 
			
		||||
                //{
 | 
			
		||||
                //    message += Environment.NewLine;
 | 
			
		||||
                //}
 | 
			
		||||
                //else
 | 
			
		||||
                //{
 | 
			
		||||
                //    message += "\t| ";
 | 
			
		||||
                //}
 | 
			
		||||
                //headerValNum++;
 | 
			
		||||
                //message += "\t| ";
 | 
			
		||||
                //message += fileIn.ReadInt16().ToString();
 | 
			
		||||
                //message += "\t| ";
 | 
			
		||||
                //message += fileIn.ReadInt16().ToString();
 | 
			
		||||
                //message += Environment.NewLine;
 | 
			
		||||
                //bytesRead += 6;
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show(message);
 | 
			
		||||
 | 
			
		||||
            //message = "";
 | 
			
		||||
            for (int i = 0; i < 7; i++)//7 bytes
 | 
			
		||||
            {
 | 
			
		||||
                //message += fileIn.ReadChar();
 | 
			
		||||
                //bytesRead++;
 | 
			
		||||
                fileIn.ReadChar();
 | 
			
		||||
            }
 | 
			
		||||
            //MessageBox.Show(message);
 | 
			
		||||
 | 
			
		||||
            //message = "";
 | 
			
		||||
            //MessageBox.Show(fileIn.BaseStream.Position.ToString());
 | 
			
		||||
            for (int i = 0; i < 7; i++)//14 bytes
 | 
			
		||||
            {
 | 
			
		||||
                //message += fileIn.ReadInt16();
 | 
			
		||||
                //message += Environment.NewLine;
 | 
			
		||||
                //bytesRead += 2;
 | 
			
		||||
                csewsegHeader.Add(fileIn.ReadInt16());
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
            startStitches = fileIn.BaseStream.Position;
 | 
			
		||||
 | 
			
		||||
            //start of point pairs
 | 
			
		||||
            List<Point> currentBlock = new List<Point>();
 | 
			
		||||
            Color currentColor = Color.Black;
 | 
			
		||||
            Int32 tmpStitchCount = 0;
 | 
			
		||||
            stitchesLeft = 10; //give it kickstart to get over the beginning
 | 
			
		||||
            while (stitchesLeft >= 0)
 | 
			
		||||
            {
 | 
			
		||||
                int tmpx;
 | 
			
		||||
                int tmpy;
 | 
			
		||||
                Int32 realx;
 | 
			
		||||
                Int32 realy;
 | 
			
		||||
                if (fileIn.BaseStream.Position + 4 < fileIn.BaseStream.Length)
 | 
			
		||||
                {
 | 
			
		||||
                    realx = fileIn.ReadInt16();
 | 
			
		||||
                    realy = fileIn.ReadInt16();
 | 
			
		||||
                    if (realx == -32765)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        if (realy == 1) //end of block
 | 
			
		||||
                        {
 | 
			
		||||
                            stitchBlock tmp = new stitchBlock();
 | 
			
		||||
                            tmp.stitches = new Point[currentBlock.Count];
 | 
			
		||||
                            currentBlock.CopyTo(tmp.stitches);
 | 
			
		||||
                            if (blocks.Count > 0 && blocks[blocks.Count - 1].colorIndex != lastColorIndex)//don't need to change the color if next block is the same
 | 
			
		||||
                            {
 | 
			
		||||
                                tmp.color = currentColor;
 | 
			
		||||
                                currentColor = System.Drawing.Color.FromArgb((rnd.Next(0, 255)), (rnd.Next(0, 255)), (rnd.Next(0, 255)));
 | 
			
		||||
                            }
 | 
			
		||||
                            tmp.colorIndex = lastColorIndex;
 | 
			
		||||
                            tmp.stitchesTotal = tmpStitchCount;
 | 
			
		||||
                            blocks.Add(tmp);
 | 
			
		||||
                            tmpStitchCount = 0;
 | 
			
		||||
                            currentBlock = new List<Point>();
 | 
			
		||||
                        }
 | 
			
		||||
                        lastColorIndex = fileIn.ReadInt16();
 | 
			
		||||
                        stitchesLeft = fileIn.ReadInt16();
 | 
			
		||||
                        tmpStitchCount += stitchesLeft;
 | 
			
		||||
                        if (realy == 1)
 | 
			
		||||
                        {
 | 
			
		||||
                            skipStitches = stitchesLeft;//skip these stiches, since they just seem to get in the way
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        tmpx = realx;//x is ok
 | 
			
		||||
                        tmpy = realy + imageHeight;//y needs to be translated
 | 
			
		||||
                        if (skipStitches > 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            skipStitches--;
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            currentBlock.Add(new System.Drawing.Point(tmpx, tmpy));
 | 
			
		||||
                        }
 | 
			
		||||
                        stitchCount++;
 | 
			
		||||
                        stitchesLeft--;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //color index table
 | 
			
		||||
            intPair tmpPair = new intPair();
 | 
			
		||||
            tmpPair.a = fileIn.ReadInt16();
 | 
			
		||||
            tmpPair.b = fileIn.ReadInt16();
 | 
			
		||||
            while (tmpPair.a != 0)
 | 
			
		||||
            {
 | 
			
		||||
                afterStictchesTable.Add(tmpPair);
 | 
			
		||||
                tmpPair = new intPair();
 | 
			
		||||
                tmpPair.a = fileIn.ReadInt16();
 | 
			
		||||
                tmpPair.b = fileIn.ReadInt16();
 | 
			
		||||
            }
 | 
			
		||||
            fileIn.Close();
 | 
			
		||||
            _readyToUse = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int GetWidth()
 | 
			
		||||
        {
 | 
			
		||||
            return imageWidth;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int GetHeight()
 | 
			
		||||
        {
 | 
			
		||||
            return imageHeight;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string GetFileName()
 | 
			
		||||
        {
 | 
			
		||||
            if (_filename == null)
 | 
			
		||||
            {
 | 
			
		||||
                return "";
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                return _filename;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void saveDebugInfo()
 | 
			
		||||
        {
 | 
			
		||||
            System.IO.StreamWriter outfile = new System.IO.StreamWriter(System.IO.Path.ChangeExtension(_filename, ".txt"));
 | 
			
		||||
            string name = "";
 | 
			
		||||
            outfile.WriteLine("pes header");
 | 
			
		||||
            for (int i = 0; i < pesHeader.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                name = (i + 1).ToString();
 | 
			
		||||
                outfile.WriteLine(name + "\t" + pesHeader[i].ToString());
 | 
			
		||||
            }
 | 
			
		||||
            outfile.WriteLine("embone header");
 | 
			
		||||
            for (int i = 0; i < embOneHeader.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                switch (i + 1)
 | 
			
		||||
                {
 | 
			
		||||
                    case 24:
 | 
			
		||||
                        name = "width";
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 25:
 | 
			
		||||
                        name = "height";
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        name = (i + 1).ToString();
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                outfile.WriteLine(name + "\t" + embOneHeader[i].ToString());
 | 
			
		||||
            }
 | 
			
		||||
            outfile.WriteLine("csewseg header");
 | 
			
		||||
            for (int i = 0; i < csewsegHeader.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                switch (i + 1)
 | 
			
		||||
                {
 | 
			
		||||
                    case 4:
 | 
			
		||||
                        name = "base x";
 | 
			
		||||
                        outfile.WriteLine(name + "\t" + csewsegHeader[i].ToString());
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 5:
 | 
			
		||||
                        name = "base y";
 | 
			
		||||
                        outfile.WriteLine(name + "\t" + csewsegHeader[i].ToString() + " (" + (csewsegHeader[i] + imageHeight).ToString() + ")");
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 6:
 | 
			
		||||
                        name = "start x";
 | 
			
		||||
                        outfile.WriteLine(name + "\t" + csewsegHeader[i].ToString());
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 7:
 | 
			
		||||
                        name = "start y";
 | 
			
		||||
                        outfile.WriteLine(name + "\t" + csewsegHeader[i].ToString() + " (" + (csewsegHeader[i] + imageHeight).ToString() + ")");
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        name = (i + 1).ToString();
 | 
			
		||||
                        outfile.WriteLine(name + "\t" + csewsegHeader[i].ToString());
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
                //outfile.WriteLine(name + "\t" + csewsegHeader[i].ToString());
 | 
			
		||||
            }
 | 
			
		||||
            outfile.WriteLine("stitches start: " + startStitches.ToString());
 | 
			
		||||
            outfile.WriteLine("block info");
 | 
			
		||||
            for (int i = 0; i < this.blocks.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                outfile.WriteLine((i + 1).ToString() + "\t" + blocks[i].colorIndex.ToString() + "\t" + blocks[i].stitchesTotal.ToString());
 | 
			
		||||
            }
 | 
			
		||||
            outfile.WriteLine("after stitches table");
 | 
			
		||||
            for (int i = 0; i < afterStictchesTable.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                outfile.WriteLine((i + 1).ToString() + "\t" + afterStictchesTable[i].a.ToString() + ", " + afterStictchesTable[i].b.ToString());
 | 
			
		||||
            }
 | 
			
		||||
            outfile.Close();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool isReadyToUse()
 | 
			
		||||
        {
 | 
			
		||||
            return _readyToUse;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace embroideryInfo
 | 
			
		||||
{
 | 
			
		||||
    class Program
 | 
			
		||||
    {
 | 
			
		||||
        static void Main(string[] args)
 | 
			
		||||
        {
 | 
			
		||||
            if (args.Length > 0)
 | 
			
		||||
            {
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                    embroideryReader.PesFile design = new embroideryReader.PesFile(args[0]);
 | 
			
		||||
                    design.saveDebugInfo();
 | 
			
		||||
                }
 | 
			
		||||
                catch (Exception ex)
 | 
			
		||||
                {
 | 
			
		||||
                    Console.WriteLine(ex.ToString());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                Console.WriteLine("Specify input file");
 | 
			
		||||
                for (int x = 0; x < args.Length; x++)
 | 
			
		||||
                {
 | 
			
		||||
                    Console.WriteLine(args[x]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,33 @@
 | 
			
		|||
using System.Reflection;
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
using System.Runtime.InteropServices;
 | 
			
		||||
 | 
			
		||||
// General Information about an assembly is controlled through the following 
 | 
			
		||||
// set of attributes. Change these attribute values to modify the information
 | 
			
		||||
// associated with an assembly.
 | 
			
		||||
[assembly: AssemblyTitle("embroideryInfo")]
 | 
			
		||||
[assembly: AssemblyDescription("")]
 | 
			
		||||
[assembly: AssemblyConfiguration("")]
 | 
			
		||||
[assembly: AssemblyCompany("")]
 | 
			
		||||
[assembly: AssemblyProduct("embroideryInfo")]
 | 
			
		||||
[assembly: AssemblyCopyright("Copyright ©  2007")]
 | 
			
		||||
[assembly: AssemblyTrademark("")]
 | 
			
		||||
[assembly: AssemblyCulture("")]
 | 
			
		||||
 | 
			
		||||
// Setting ComVisible to false makes the types in this assembly not visible 
 | 
			
		||||
// to COM components.  If you need to access a type in this assembly from 
 | 
			
		||||
// COM, set the ComVisible attribute to true on that type.
 | 
			
		||||
[assembly: ComVisible(false)]
 | 
			
		||||
 | 
			
		||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
 | 
			
		||||
[assembly: Guid("4f0ed79b-33dc-4066-9a65-6d44d2b94332")]
 | 
			
		||||
 | 
			
		||||
// Version information for an assembly consists of the following four values:
 | 
			
		||||
//
 | 
			
		||||
//      Major Version
 | 
			
		||||
//      Minor Version 
 | 
			
		||||
//      Build Number
 | 
			
		||||
//      Revision
 | 
			
		||||
//
 | 
			
		||||
[assembly: AssemblyVersion("1.0.0.0")]
 | 
			
		||||
[assembly: AssemblyFileVersion("1.0.0.0")]
 | 
			
		||||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,49 @@
 | 
			
		|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
 | 
			
		||||
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 | 
			
		||||
    <ProductVersion>8.0.50727</ProductVersion>
 | 
			
		||||
    <SchemaVersion>2.0</SchemaVersion>
 | 
			
		||||
    <ProjectGuid>{1E3B0E33-E0BC-41C1-B1B3-7CADD39BE362}</ProjectGuid>
 | 
			
		||||
    <OutputType>Exe</OutputType>
 | 
			
		||||
    <AppDesignerFolder>Properties</AppDesignerFolder>
 | 
			
		||||
    <RootNamespace>embroideryInfo</RootNamespace>
 | 
			
		||||
    <AssemblyName>embroideryInfo</AssemblyName>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
 | 
			
		||||
    <DebugSymbols>true</DebugSymbols>
 | 
			
		||||
    <DebugType>full</DebugType>
 | 
			
		||||
    <Optimize>false</Optimize>
 | 
			
		||||
    <OutputPath>bin\Debug\</OutputPath>
 | 
			
		||||
    <DefineConstants>DEBUG;TRACE</DefineConstants>
 | 
			
		||||
    <ErrorReport>prompt</ErrorReport>
 | 
			
		||||
    <WarningLevel>4</WarningLevel>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
 | 
			
		||||
    <DebugType>pdbonly</DebugType>
 | 
			
		||||
    <Optimize>true</Optimize>
 | 
			
		||||
    <OutputPath>bin\Release\</OutputPath>
 | 
			
		||||
    <DefineConstants>TRACE</DefineConstants>
 | 
			
		||||
    <ErrorReport>prompt</ErrorReport>
 | 
			
		||||
    <WarningLevel>4</WarningLevel>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Reference Include="System" />
 | 
			
		||||
    <Reference Include="System.Data" />
 | 
			
		||||
    <Reference Include="System.Drawing" />
 | 
			
		||||
    <Reference Include="System.Xml" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Compile Include="PesFile.cs" />
 | 
			
		||||
    <Compile Include="Program.cs" />
 | 
			
		||||
    <Compile Include="Properties\AssemblyInfo.cs" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 | 
			
		||||
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
 | 
			
		||||
       Other similar extension points exist, see Microsoft.Common.targets.
 | 
			
		||||
  <Target Name="BeforeBuild">
 | 
			
		||||
  </Target>
 | 
			
		||||
  <Target Name="AfterBuild">
 | 
			
		||||
  </Target>
 | 
			
		||||
  -->
 | 
			
		||||
</Project>
 | 
			
		||||
| 
						 | 
				
			
			@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "embroideryReader", "embroid
 | 
			
		|||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "emroideryTester", "emroideryTester\emroideryTester.csproj", "{A80DF4D8-967D-4352-9E1D-F22D23236BE2}"
 | 
			
		||||
EndProject
 | 
			
		||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "embroideryInfo", "embroideryInfo\embroideryInfo.csproj", "{1E3B0E33-E0BC-41C1-B1B3-7CADD39BE362}"
 | 
			
		||||
EndProject
 | 
			
		||||
Global
 | 
			
		||||
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 | 
			
		||||
		Debug|Any CPU = Debug|Any CPU
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +21,10 @@ Global
 | 
			
		|||
		{A80DF4D8-967D-4352-9E1D-F22D23236BE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{A80DF4D8-967D-4352-9E1D-F22D23236BE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{A80DF4D8-967D-4352-9E1D-F22D23236BE2}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
		{1E3B0E33-E0BC-41C1-B1B3-7CADD39BE362}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 | 
			
		||||
		{1E3B0E33-E0BC-41C1-B1B3-7CADD39BE362}.Debug|Any CPU.Build.0 = Debug|Any CPU
 | 
			
		||||
		{1E3B0E33-E0BC-41C1-B1B3-7CADD39BE362}.Release|Any CPU.ActiveCfg = Release|Any CPU
 | 
			
		||||
		{1E3B0E33-E0BC-41C1-B1B3-7CADD39BE362}.Release|Any CPU.Build.0 = Release|Any CPU
 | 
			
		||||
	EndGlobalSection
 | 
			
		||||
	GlobalSection(SolutionProperties) = preSolution
 | 
			
		||||
		HideSolutionNode = FALSE
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -299,14 +299,21 @@ namespace embroideryReader
 | 
			
		|||
            }
 | 
			
		||||
            //_form2 = new Form2();
 | 
			
		||||
            //_form2.design = new PesFile(filename);
 | 
			
		||||
            design = new PesFile(filename);
 | 
			
		||||
            this.Text = System.IO.Path.GetFileName(filename) + " - Embroidery Reader";
 | 
			
		||||
            //_form2.DrawArea = new Bitmap(_form2.design.GetWidth(), _form2.design.GetHeight());
 | 
			
		||||
            DrawArea = new Bitmap(design.GetWidth(), design.GetHeight());
 | 
			
		||||
            setPanelSize(design.GetWidth(), design.GetHeight());
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                design = new PesFile(filename);
 | 
			
		||||
                this.Text = System.IO.Path.GetFileName(filename) + " - Embroidery Reader";
 | 
			
		||||
                //_form2.DrawArea = new Bitmap(_form2.design.GetWidth(), _form2.design.GetHeight());
 | 
			
		||||
                DrawArea = new Bitmap(design.GetWidth(), design.GetHeight());
 | 
			
		||||
                setPanelSize(design.GetWidth(), design.GetHeight());
 | 
			
		||||
 | 
			
		||||
            //_form2.Show();
 | 
			
		||||
            finishDesign();
 | 
			
		||||
                //_form2.Show();
 | 
			
		||||
                finishDesign();
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                MessageBox.Show("An error occured while reading the design file:" + Environment.NewLine + ex.ToString());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@ namespace embroideryReader
 | 
			
		|||
    public class stitchBlock
 | 
			
		||||
    {
 | 
			
		||||
        public System.Drawing.Color color;
 | 
			
		||||
        public Int32 unknownNumber;
 | 
			
		||||
        public Int32 colorIndex;
 | 
			
		||||
        public Int32 stitchesTotal;
 | 
			
		||||
        public Point[] stitches;
 | 
			
		||||
        public stitchBlock()
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ namespace embroideryReader
 | 
			
		|||
        //int maxY = int.MinValue;
 | 
			
		||||
        int imageWidth;
 | 
			
		||||
        int imageHeight;
 | 
			
		||||
        int lastStrangeNum = -1;
 | 
			
		||||
        int lastColorIndex = -1;
 | 
			
		||||
        string _filename;
 | 
			
		||||
        public List<Int16> pesHeader = new List<short>();
 | 
			
		||||
        public List<Int16> embOneHeader = new List<short>();
 | 
			
		||||
| 
						 | 
				
			
			@ -48,6 +48,8 @@ namespace embroideryReader
 | 
			
		|||
 | 
			
		||||
        Int64 startStitches = 0;
 | 
			
		||||
 | 
			
		||||
        bool _readyToUse = false;
 | 
			
		||||
 | 
			
		||||
        public PesFile(string filename)
 | 
			
		||||
        {
 | 
			
		||||
            OpenFile(filename);
 | 
			
		||||
| 
						 | 
				
			
			@ -147,12 +149,8 @@ namespace embroideryReader
 | 
			
		|||
 | 
			
		||||
            }
 | 
			
		||||
            startStitches = fileIn.BaseStream.Position;
 | 
			
		||||
            //MessageBox.Show(message);
 | 
			
		||||
 | 
			
		||||
            //start of point pairs
 | 
			
		||||
            //message = "";
 | 
			
		||||
            //long startPos = fileIn.BaseStream.Position;
 | 
			
		||||
            //bytesRead = fileIn.BaseStream.Position;
 | 
			
		||||
            List<Point> currentBlock = new List<Point>();
 | 
			
		||||
            Color currentColor = Color.Black;
 | 
			
		||||
            Int32 tmpStitchCount = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -170,23 +168,23 @@ namespace embroideryReader
 | 
			
		|||
                    if (realx == -32765)
 | 
			
		||||
                    {
 | 
			
		||||
 | 
			
		||||
                        if (realy == 1) //probably means change color
 | 
			
		||||
                        if (realy == 1) //end of block
 | 
			
		||||
                        {
 | 
			
		||||
                            //_form2.drawPen = new Pen(Color.FromArgb((rnd.Next(0, 255)), (rnd.Next(0, 255)), (rnd.Next(0, 255))), 4);
 | 
			
		||||
                            //_form2.prevPoint = new Point(-1, -1);
 | 
			
		||||
                            stitchBlock tmp = new stitchBlock();
 | 
			
		||||
                            tmp.stitches = new Point[currentBlock.Count];
 | 
			
		||||
                            currentBlock.CopyTo(tmp.stitches);
 | 
			
		||||
                            tmp.color = currentColor;
 | 
			
		||||
                            tmp.unknownNumber = lastStrangeNum;
 | 
			
		||||
                            if (blocks.Count > 0 && blocks[blocks.Count - 1].colorIndex != lastColorIndex)//don't need to change the color if next block is the same
 | 
			
		||||
                            {
 | 
			
		||||
                                tmp.color = currentColor;
 | 
			
		||||
                                currentColor = System.Drawing.Color.FromArgb((rnd.Next(0, 255)), (rnd.Next(0, 255)), (rnd.Next(0, 255)));
 | 
			
		||||
                            }
 | 
			
		||||
                            tmp.colorIndex = lastColorIndex;
 | 
			
		||||
                            tmp.stitchesTotal = tmpStitchCount;
 | 
			
		||||
                            blocks.Add(tmp);
 | 
			
		||||
                            tmpStitchCount = 0;
 | 
			
		||||
                            currentBlock = new List<Point>();
 | 
			
		||||
                            currentColor = System.Drawing.Color.FromArgb((rnd.Next(0, 255)), (rnd.Next(0, 255)), (rnd.Next(0, 255)));
 | 
			
		||||
                        }
 | 
			
		||||
                        lastStrangeNum = fileIn.ReadInt16();//don't know what this is, maybe stitching speed? Seems to be 1/100 sec values
 | 
			
		||||
                        //timer1.Interval = lastStrangeNum * 10;
 | 
			
		||||
                        lastColorIndex = fileIn.ReadInt16();
 | 
			
		||||
                        stitchesLeft = fileIn.ReadInt16();
 | 
			
		||||
                        tmpStitchCount += stitchesLeft;
 | 
			
		||||
                        if (realy == 1)
 | 
			
		||||
| 
						 | 
				
			
			@ -198,7 +196,6 @@ namespace embroideryReader
 | 
			
		|||
                    {
 | 
			
		||||
                        tmpx = realx;//x is ok
 | 
			
		||||
                        tmpy = realy + imageHeight;//y needs to be translated
 | 
			
		||||
                        //bytesRead += 4;
 | 
			
		||||
                        if (skipStitches > 0)
 | 
			
		||||
                        {
 | 
			
		||||
                            skipStitches--;
 | 
			
		||||
| 
						 | 
				
			
			@ -206,35 +203,14 @@ namespace embroideryReader
 | 
			
		|||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            currentBlock.Add(new System.Drawing.Point(tmpx, tmpy));
 | 
			
		||||
                            //_form2.addPoint(new Point(tmpx, tmpy));
 | 
			
		||||
                            //if (realx < minX)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    minX = realx;
 | 
			
		||||
                            //}
 | 
			
		||||
                            //if (realx > maxX)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    maxX = realx;
 | 
			
		||||
                            //}
 | 
			
		||||
                            //if (realy < minY)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    minY = realy;
 | 
			
		||||
                            //}
 | 
			
		||||
                            //if (realy > maxY)
 | 
			
		||||
                            //{
 | 
			
		||||
                            //    maxY = realy;
 | 
			
		||||
                            //}
 | 
			
		||||
                        }
 | 
			
		||||
                        stitchCount++;
 | 
			
		||||
                        stitchesLeft--;
 | 
			
		||||
                    }
 | 
			
		||||
                    //label1.Text = "file pos: " + fileIn.BaseStream.Position.ToString() + ", last values: " + realx.ToString() + ", " + realy.ToString() + ", total stiches: " + stitchCount.ToString() + ", stitches til next section: " + (stitchesLeft + 1).ToString() + ", min, max vals: " + minX.ToString() + "," + minY.ToString() + ";" + maxX.ToString() + "," + maxY.ToString() + ", strangenum: " + lastStrangeNum;
 | 
			
		||||
                    //if (stitchesLeft < 0)
 | 
			
		||||
                    //{
 | 
			
		||||
                    //    timer1.Enabled = false;
 | 
			
		||||
                    //    fileIn.Close();
 | 
			
		||||
                    //}
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //color index table
 | 
			
		||||
            intPair tmpPair = new intPair();
 | 
			
		||||
            tmpPair.a = fileIn.ReadInt16();
 | 
			
		||||
            tmpPair.b = fileIn.ReadInt16();
 | 
			
		||||
| 
						 | 
				
			
			@ -242,10 +218,11 @@ namespace embroideryReader
 | 
			
		|||
            {
 | 
			
		||||
                afterStictchesTable.Add(tmpPair);
 | 
			
		||||
                tmpPair = new intPair();
 | 
			
		||||
                tmpPair.a = fileIn.ReadInt16();//strange number
 | 
			
		||||
                tmpPair.b = fileIn.ReadInt16();//file block that strange number end at. Not the same as stichBlock.
 | 
			
		||||
                tmpPair.a = fileIn.ReadInt16();
 | 
			
		||||
                tmpPair.b = fileIn.ReadInt16();
 | 
			
		||||
            }
 | 
			
		||||
            fileIn.Close();
 | 
			
		||||
            _readyToUse = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public int GetWidth()
 | 
			
		||||
| 
						 | 
				
			
			@ -331,7 +308,7 @@ namespace embroideryReader
 | 
			
		|||
            outfile.WriteLine("block info");
 | 
			
		||||
            for (int i = 0; i < this.blocks.Count; i++)
 | 
			
		||||
            {
 | 
			
		||||
                outfile.WriteLine((i + 1).ToString() + "\t" + blocks[i].unknownNumber.ToString() + "\t" + blocks[i].stitchesTotal.ToString());
 | 
			
		||||
                outfile.WriteLine((i + 1).ToString() + "\t" + blocks[i].colorIndex.ToString() + "\t" + blocks[i].stitchesTotal.ToString());
 | 
			
		||||
            }
 | 
			
		||||
            outfile.WriteLine("after stitches table");
 | 
			
		||||
            for (int i = 0; i < afterStictchesTable.Count; i++)
 | 
			
		||||
| 
						 | 
				
			
			@ -340,5 +317,10 @@ namespace embroideryReader
 | 
			
		|||
            }
 | 
			
		||||
            outfile.Close();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool isReadyToUse()
 | 
			
		||||
        {
 | 
			
		||||
            return _readyToUse;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
 | 
			
		|||
//      Build Number
 | 
			
		||||
//      Revision
 | 
			
		||||
//
 | 
			
		||||
[assembly: AssemblyVersion("1.0.0.447")]
 | 
			
		||||
[assembly: AssemblyFileVersion("1.0.0.447")]
 | 
			
		||||
[assembly: AssemblyVersion("1.0.0.461")]
 | 
			
		||||
[assembly: AssemblyFileVersion("1.0.0.461")]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Plik binarny nie jest wyświetlany.
										
									
								
							
										
											Plik binarny nie jest wyświetlany.
										
									
								
							
										
											Plik binarny nie jest wyświetlany.
										
									
								
							
										
											Plik binarny nie jest wyświetlany.
										
									
								
							
		Ładowanie…
	
		Reference in New Issue