├── CrossStitchCreator ├── .gitignore ├── Resources │ ├── cross.bmp │ ├── horz.bmp │ ├── plus.bmp │ ├── star.bmp │ ├── vert.bmp │ ├── whorz.bmp │ ├── wplus.bmp │ ├── wstar.bmp │ ├── wvert.bmp │ ├── bslash.bmp │ ├── circle.bmp │ ├── diamond.bmp │ ├── fslash.bmp │ ├── square2.bmp │ ├── wbslash.bmp │ ├── wcircle.bmp │ ├── wcross.bmp │ ├── wfslash.bmp │ ├── bsquare2.bmp │ ├── wdiamond.bmp │ └── DMC Cotton Floss converted to RGB Values.csv ├── CrossStitchCreator.csproj.user ├── app.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Patterns.resx │ └── Patterns1.Designer.cs ├── Program.cs ├── PatternCreator.cs ├── CrossStitchSettings.cs ├── DMCColourMap.cs ├── CSVReader.cs ├── AboutBox.cs ├── DMCColours.Designer.cs ├── ColourMapViewer.cs ├── PatternEditor.resx ├── DMCColours.resx ├── ColourMapViewer.resx ├── MainForm.resx ├── ColourMapViewer.Designer.cs ├── CrossStitchCreator.csproj ├── ColourMap.cs ├── PatternEditor.Designer.cs ├── AboutBox.Designer.cs ├── ImagingTool.cs ├── PatternEditor.cs └── MainForm.cs ├── BasicWindowsForm.zip ├── CrossStitchCreator.suo ├── Dependencies ├── DTALib.dll └── DTALib.pdb ├── CrossStitchCreator.v12.suo ├── readme.txt └── CrossStitchCreator.sln /CrossStitchCreator/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj -------------------------------------------------------------------------------- /BasicWindowsForm.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/BasicWindowsForm.zip -------------------------------------------------------------------------------- /CrossStitchCreator.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator.suo -------------------------------------------------------------------------------- /Dependencies/DTALib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/Dependencies/DTALib.dll -------------------------------------------------------------------------------- /Dependencies/DTALib.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/Dependencies/DTALib.pdb -------------------------------------------------------------------------------- /CrossStitchCreator.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator.v12.suo -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/cross.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/cross.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/horz.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/horz.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/plus.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/plus.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/star.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/star.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/vert.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/vert.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/whorz.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/whorz.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wplus.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wplus.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wstar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wstar.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wvert.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wvert.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/bslash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/bslash.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/circle.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/circle.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/diamond.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/diamond.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/fslash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/fslash.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/square2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/square2.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wbslash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wbslash.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wcircle.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wcircle.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wcross.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wcross.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wfslash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wfslash.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/bsquare2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/bsquare2.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/wdiamond.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adrianj/CrossStitchCreator/HEAD/CrossStitchCreator/Resources/wdiamond.bmp -------------------------------------------------------------------------------- /CrossStitchCreator/CrossStitchCreator.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /CrossStitchCreator/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /CrossStitchCreator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | CrossStitchCreator 2 | 3 | A fun little tool for converting images to cross stitch patterns. 4 | 5 | Todo: 6 | 7 | * Increase complexity of patterns. 8 | * Fix Undo feature, especially to the recolouring process. 9 | * Improve ZoomablePictureBox zoom resolution. 10 | * Add scroll/drag to Zoomable picturebox. 11 | * When Zooming in Zoomable picturebox, keep image centred on mouse click. 12 | * Context menu for PatternEditor, eg, to swap patterns. 13 | * Save patterns to *something* for later printing, with info. 14 | * Improve colour editing (like MS Paint) 15 | * Investigate why PatternEditor.UpdateColourMap() is so slow - use progress bar? -------------------------------------------------------------------------------- /CrossStitchCreator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | using DTALib; 6 | using System.ComponentModel; 7 | using System.Threading; 8 | 9 | namespace CrossStitchCreator 10 | { 11 | static class Program 12 | { 13 | /// 14 | /// The main entry point for the application. 15 | /// 16 | [STAThread] 17 | static void Main() 18 | { 19 | Application.EnableVisualStyles(); 20 | Application.SetCompatibleTextRenderingDefault(false); 21 | Application.Run(new MainForm()); 22 | } 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CrossStitchCreator.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C# Express 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossStitchCreator", "CrossStitchCreator\CrossStitchCreator.csproj", "{34959807-2C24-4D0F-8698-0FDA1F584CB6}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x86 = Debug|x86 9 | Release|x86 = Release|x86 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {34959807-2C24-4D0F-8698-0FDA1F584CB6}.Debug|x86.ActiveCfg = Debug|x86 13 | {34959807-2C24-4D0F-8698-0FDA1F584CB6}.Debug|x86.Build.0 = Debug|x86 14 | {34959807-2C24-4D0F-8698-0FDA1F584CB6}.Release|x86.ActiveCfg = Release|x86 15 | {34959807-2C24-4D0F-8698-0FDA1F584CB6}.Release|x86.Build.0 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /CrossStitchCreator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CrossStitchCreator.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CrossStitchCreator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Cross-Stitch Creator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Adrian Jongenelen")] 12 | [assembly: AssemblyProduct("Cross-Stitch Creator")] 13 | [assembly: AssemblyCopyright("Copyright © Adrian Jongenelen 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d48eb1b9-f0e8-4b6c-aa5e-6af3508ea52d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /CrossStitchCreator/PatternCreator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Drawing; 7 | using System.Drawing.Imaging; 8 | using System.Reflection; 9 | using System.Resources; 10 | using System.Globalization; 11 | 12 | namespace CrossStitchCreator 13 | { 14 | public class PatternCreator 15 | { 16 | 17 | private int count = 0; 18 | List patterns; 19 | 20 | public PatternCreator() 21 | { 22 | ResourceManager rm = Properties.Patterns.ResourceManager; 23 | ResourceSet rs = rm.GetResourceSet(new CultureInfo("en-US"), true, true); 24 | patterns = new List(); 25 | 26 | IDictionaryEnumerator mIterator = rs.GetEnumerator(); 27 | int count = 0; 28 | while(mIterator.MoveNext()) 29 | { 30 | object val = mIterator.Value; 31 | object key = mIterator.Key; 32 | if (val is Image) 33 | { 34 | Image img = (Image)val; 35 | patterns.Add(img); 36 | } 37 | count++; 38 | } 39 | Reset(); 40 | } 41 | 42 | public void Reset() { count = 0; } 43 | 44 | public Bitmap GetNextPattern() 45 | { 46 | Bitmap b = new Bitmap(PatternEditor.PATTERN_WIDTH, PatternEditor.PATTERN_WIDTH,PixelFormat.Format16bppRgb555); 47 | using (Graphics g = Graphics.FromImage(b)) 48 | { 49 | g.FillRectangle(Brushes.White, 0, 0, b.Width, b.Height); 50 | g.DrawRectangle(Pens.Gray, 0, 0, b.Width, b.Height); 51 | 52 | if(count == 0) 53 | { 54 | // Do nothing, already have a filled white rectangle. 55 | } 56 | else if (count == 1) 57 | { 58 | g.FillRectangle(Brushes.Black, 1, 1, b.Width-2, b.Height-2); 59 | } 60 | else if (count < patterns.Count + 2) 61 | { 62 | Bitmap bRes = (Bitmap)patterns[count-2]; 63 | g.DrawImage(bRes, 1, 1); 64 | } 65 | else if (count < patterns.Count + 54) 66 | { 67 | int cnt = count - patterns.Count - 2; 68 | char c = (char)('A' + cnt); 69 | if (cnt >= 26) 70 | c = (char)('A' + cnt-26); 71 | g.DrawString("" + c, new Font("Courier", 9), new SolidBrush(Color.Black), new Point(0, 0)); 72 | } 73 | } 74 | count++; 75 | return b; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /CrossStitchCreator/CrossStitchSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Reflection; 6 | using System.IO; 7 | using System.Drawing; 8 | using System.Drawing.Drawing2D; 9 | 10 | namespace CrossStitchCreator 11 | { 12 | [Serializable()] 13 | class CrossStitchSettings 14 | { 15 | private int mMaxColours = MainForm.MAX_COLOURS; 16 | public int MaxColours { get { return mMaxColours; } set { if (value >= 2 && value <= MainForm.MAX_COLOURS) mMaxColours = value; } } 17 | public static string FileExtension = "cse"; 18 | public string ProjectPath { get; set; } 19 | public string InputImagePath { get; set; } 20 | public string OutputImagePath { get; set; } 21 | public string PatternLegendPath { get; set; } 22 | public string PatternImagePath { get; set; } 23 | private bool mFixRatio = false; 24 | public bool FixSizeRatio { get { return mFixRatio; } set { mFixRatio = value; DoRatioFixing(true); } } 25 | public Size InputImageSize { get; set; } 26 | private Size mOutputSize = new Size(64, 48); 27 | public Size OutputImageSize 28 | { 29 | get { return mOutputSize; } 30 | set 31 | { 32 | OutputHeight = value.Height; 33 | OutputWidth = value.Width; 34 | } 35 | } 36 | public int OutputHeight 37 | { 38 | get { return mOutputSize.Height; } 39 | set 40 | { 41 | if (value > 0) 42 | { 43 | mOutputSize.Height = value; 44 | DoRatioFixing(false); 45 | } 46 | } 47 | } 48 | 49 | public int OutputWidth 50 | { 51 | get { return mOutputSize.Width; } 52 | set 53 | { 54 | if (value > 0) 55 | { 56 | mOutputSize.Width = value; 57 | DoRatioFixing(true); 58 | } 59 | } 60 | } 61 | 62 | public InterpolationMode IntMode { get; set; } 63 | 64 | public CrossStitchSettings() { } 65 | 66 | private void DoRatioFixing(bool keepWidth) 67 | { 68 | if (FixSizeRatio && mOutputSize.Width > 0 && mOutputSize.Height > 0 69 | && InputImageSize.Width > 0 && InputImageSize.Height > 0) 70 | { 71 | float ratio = (float)InputImageSize.Width / (float)InputImageSize.Height; 72 | if (keepWidth) 73 | { 74 | mOutputSize.Height = (int)((float)mOutputSize.Width / ratio); 75 | } 76 | else 77 | { 78 | mOutputSize.Width = (int)((float)mOutputSize.Height * ratio); 79 | } 80 | } 81 | } 82 | 83 | public bool WriteToFile() 84 | { 85 | 86 | return true; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /CrossStitchCreator/DMCColourMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Drawing; 7 | using System.IO; 8 | 9 | namespace CrossStitchCreator 10 | { 11 | 12 | 13 | 14 | public class DMCColourMap : SimpleColourMap 15 | { 16 | 17 | /// 18 | /// Initialises the colour map from a filename pointing to the .csv file with RGB values listed. 19 | /// 20 | /// 21 | public DMCColourMap() : this(false) { } 22 | 23 | public DMCColourMap(bool createEmpty) 24 | { 25 | Colours = new Dictionary(); 26 | if (!createEmpty) 27 | { 28 | byte[] bytes = Encoding.ASCII.GetBytes(DMCColours.DmcToRgb); 29 | MemoryStream stream = new MemoryStream(bytes); 30 | CSVReader reader = new CSVReader(stream); 31 | string[][] text = reader.ReadFile(); 32 | 33 | for (int i = 0; i < reader.NumberOfRows; i++) 34 | { 35 | int r = parse(text[2][i]); 36 | int g = parse(text[3][i]); 37 | int b = parse(text[4][i]); 38 | string name = text[1][i]; 39 | string dmcNum = text[0][i]; 40 | Color c = Color.FromArgb(255, r, g, b); 41 | if (!Colours.ContainsKey(c)) Colours[c] = (new DMCColour(name, i, c, dmcNum)); 42 | } 43 | } 44 | } 45 | 46 | private int parseFailures = 0; 47 | 48 | private int parse(string s) 49 | { 50 | try 51 | { 52 | return int.Parse(s); 53 | } 54 | catch 55 | { 56 | return parseFailures++; 57 | } 58 | } 59 | 60 | public override IColourMap Clone() 61 | { 62 | IColourMap cmap = new DMCColourMap(true); 63 | foreach (KeyValuePair pair in Colours) 64 | { 65 | cmap.Colours[pair.Key] = pair.Value.Clone(); 66 | } 67 | return cmap; 68 | } 69 | } 70 | 71 | public class DMCColour : SimpleColour 72 | { 73 | public string DMCNumber { get; set; } 74 | public string AnchorNumber { get; set; } 75 | 76 | public DMCColour(string name, int index, Color colour, string dmcNum) : base(name,index,colour) 77 | { 78 | DMCNumber = dmcNum; 79 | } 80 | public DMCColour(DMCColour d) :base(d) 81 | { 82 | DMCNumber = d.DMCNumber; 83 | AnchorNumber = d.AnchorNumber; 84 | } 85 | 86 | public override string PrintInfo() 87 | { 88 | string s = base.PrintInfo(); 89 | 90 | return s+Environment.NewLine+"DMC: "+DMCNumber+", Anchor: "+AnchorNumber; 91 | } 92 | 93 | 94 | public override IColourInfo Clone() 95 | { 96 | return new DMCColour(this); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /CrossStitchCreator/CSVReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | namespace CrossStitchCreator 8 | { 9 | /// 10 | /// A class for reading .CSV files 11 | /// 12 | public class CSVReader 13 | { 14 | 15 | public string[] FirstRow { get; set; } 16 | /// 17 | /// The number of rows, NOT including the first row that has header information. 18 | /// 19 | public int NumberOfRows { get; set; } 20 | public int NumberOfColumns { get; set; } 21 | 22 | private StreamReader mStream; 23 | 24 | /// 25 | /// Initialises a new CSVReader and sets up a FileStream on the given filename. 26 | /// Will throw some kind of Exception if the filename is no good. 27 | /// 28 | /// 29 | public CSVReader(string filename) 30 | { 31 | mStream = new StreamReader(filename); 32 | countRows(); 33 | } 34 | 35 | /// 36 | /// Initialises a new CVSReader around the given Stream. 37 | /// 38 | /// 39 | public CSVReader(Stream stream) 40 | { 41 | mStream = new StreamReader(stream); 42 | countRows(); 43 | } 44 | 45 | 46 | 47 | /// 48 | /// Reinitialises the stream back to the beginning 49 | /// 50 | private void initialise() 51 | { 52 | if (mStream.BaseStream.CanSeek) mStream.BaseStream.Seek(0, SeekOrigin.Begin); 53 | mStream.DiscardBufferedData(); 54 | } 55 | 56 | /// 57 | /// Reads through the stream once and populates properties like NumberOfRows, NumberOfColumns and FirstRow. 58 | /// 59 | private void countRows() 60 | { 61 | initialise(); 62 | NumberOfRows = -1; 63 | while (!mStream.EndOfStream) 64 | { 65 | string[] s = readLine(); 66 | NumberOfRows++; 67 | if (NumberOfRows == 0) 68 | { 69 | FirstRow = s; 70 | NumberOfColumns = FirstRow.Length; 71 | } 72 | } 73 | } 74 | 75 | /// 76 | /// Reads the file, and returns an array of strings organised [Column][Row] 77 | /// 78 | /// a 2Dimensional array structured [Column][Row] of decimal values. Values that could not be parsed are returned as -1. 79 | public string[][] ReadFile() 80 | { 81 | initialise(); 82 | string [][] ret = new string[NumberOfColumns][]; 83 | for (int c = 0; c < NumberOfColumns; c++) ret[c] = new string[NumberOfRows]; 84 | 85 | int row = 0; 86 | // skip first line 87 | mStream.ReadLine(); 88 | while (!mStream.EndOfStream) 89 | { 90 | string[] s = readLine(); 91 | for (int i = 0; i < s.Length; i++) ret[i][row] = s[i]; 92 | row++; 93 | } 94 | initialise(); 95 | return ret; 96 | } 97 | 98 | 99 | 100 | 101 | private string[] readLine() 102 | { 103 | string s = mStream.ReadLine(); 104 | return s.Split(new char[] { ',' }); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /CrossStitchCreator/AboutBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Windows.Forms; 8 | 9 | namespace CrossStitchCreator 10 | { 11 | partial class AboutBox : Form 12 | { 13 | public AboutBox() 14 | { 15 | InitializeComponent(); 16 | this.Text = String.Format("About {0}", AssemblyTitle); 17 | this.labelProductName.Text = AssemblyProduct; 18 | this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); 19 | this.labelCopyright.Text = AssemblyCopyright; 20 | this.labelCompanyName.Text = AssemblyCompany; 21 | this.textBoxDescription.Text = AssemblyDescription; 22 | } 23 | 24 | #region Assembly Attribute Accessors 25 | 26 | public string AssemblyTitle 27 | { 28 | get 29 | { 30 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); 31 | if (attributes.Length > 0) 32 | { 33 | AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; 34 | if (titleAttribute.Title != "") 35 | { 36 | return titleAttribute.Title; 37 | } 38 | } 39 | return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); 40 | } 41 | } 42 | 43 | public string AssemblyVersion 44 | { 45 | get 46 | { 47 | return Assembly.GetExecutingAssembly().GetName().Version.ToString(); 48 | } 49 | } 50 | 51 | public string AssemblyDescription 52 | { 53 | get 54 | { 55 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); 56 | if (attributes.Length == 0) 57 | { 58 | return ""; 59 | } 60 | return ((AssemblyDescriptionAttribute)attributes[0]).Description; 61 | } 62 | } 63 | 64 | public string AssemblyProduct 65 | { 66 | get 67 | { 68 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); 69 | if (attributes.Length == 0) 70 | { 71 | return ""; 72 | } 73 | return ((AssemblyProductAttribute)attributes[0]).Product; 74 | } 75 | } 76 | 77 | public string AssemblyCopyright 78 | { 79 | get 80 | { 81 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); 82 | if (attributes.Length == 0) 83 | { 84 | return ""; 85 | } 86 | return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; 87 | } 88 | } 89 | 90 | public string AssemblyCompany 91 | { 92 | get 93 | { 94 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); 95 | if (attributes.Length == 0) 96 | { 97 | return ""; 98 | } 99 | return ((AssemblyCompanyAttribute)attributes[0]).Company; 100 | } 101 | } 102 | #endregion 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /CrossStitchCreator/DMCColours.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CrossStitchCreator { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class DMCColours { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal DMCColours() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CrossStitchCreator.DMCColours", typeof(DMCColours).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Floss#,Description,Red,Green,Blue,RGB code,Row 65 | ///3713,Salmon Very Light,255,226,226,FFE2E2,row 01-01 66 | ///761,Salmon Light,255,201,201,FFC9C9,row 01-02 67 | ///760,Salmon,245,173,173,F5ADAD,row 01-03 68 | ///3712,Salmon Medium,241,135,135,F18787,row 01-04 69 | ///3328,Salmon Dark,227,109,109,E36D6D,row 01-05 70 | ///347,Salmon Very Dark,191,45,45,BF2D2D,row 01-06 71 | ///353,Peach,254,215,204,FED7CC,row 01-07 72 | ///352,Coral Light,253,156,151,FD9C97,row 01-08 73 | ///351,Coral,233,106,103,E96A67,row 01-09 74 | ///350,Coral Medium,224,72,72,E04848,row 01-10 75 | ///349,Cor [rest of string was truncated]";. 76 | /// 77 | internal static string DmcToRgb { 78 | get { 79 | return ResourceManager.GetString("DmcToRgb", resourceCulture); 80 | } 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /CrossStitchCreator/ColourMapViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace CrossStitchCreator 11 | { 12 | public partial class ColourMapViewer : Form 13 | { 14 | 15 | private IColourMap mColourMap; 16 | private bool mReplacing = false; 17 | private Color mColorToReplace; 18 | private bool enableEvents = false; 19 | 20 | public ColourMapViewer(IColourMap cmap) 21 | { 22 | InitializeComponent(); 23 | UpdateColourMap(cmap); 24 | } 25 | 26 | public void UpdateColourMap(IColourMap cmap) 27 | { 28 | enableEvents = false; 29 | Color previouslySelected = Color.Wheat; 30 | bool pSel = false; 31 | if (listView.SelectedIndices.Count > 0) 32 | { 33 | pSel = true; 34 | previouslySelected = listView.SelectedItems[0].BackColor; 35 | } 36 | mColourMap = cmap; 37 | if (mColourMap.Count > 0) 38 | { 39 | listView.Items.Clear(); 40 | foreach (KeyValuePair pair in mColourMap.Colours) 41 | { 42 | ListViewItem lvi = new ListViewItem(pair.Value.Name); 43 | lvi.BackColor = pair.Value.Colour; 44 | lvi.Checked = pair.Value.IsChecked; 45 | lvi.Tag = pair.Value; 46 | listView.Items.Add(lvi); 47 | 48 | } 49 | enableEvents = true; 50 | if (pSel && cmap.Colours.ContainsKey(previouslySelected)) 51 | { 52 | SelectColour(previouslySelected); 53 | } 54 | } 55 | enableEvents = true; 56 | } 57 | 58 | public void SelectColour(Color colour) 59 | { 60 | foreach(ListViewItem lvi in listView.Items) 61 | { 62 | if (lvi.BackColor == colour) lvi.Selected = true; 63 | } 64 | 65 | } 66 | private void updateInfo(ListViewItem lvi) 67 | { 68 | if (lvi == null) 69 | { 70 | pictureBox.Image = null; 71 | infoBox.Text = ""; 72 | return; 73 | } 74 | IColourInfo c = (IColourInfo)lvi.Tag; 75 | //c.IsChecked = lvi.Checked; 76 | infoBox.Text = c.PrintInfo(); 77 | statusLabel.Text = c.Name; 78 | Bitmap b = new Bitmap(pictureBox.Width, pictureBox.Height); 79 | Graphics g = Graphics.FromImage(b); 80 | g.FillRectangle(new SolidBrush(lvi.BackColor), 0, 0, b.Width, b.Height); 81 | g.Dispose(); 82 | pictureBox.Image = b; 83 | } 84 | 85 | private void listView_ItemChecked(object sender, ItemCheckedEventArgs e) 86 | { 87 | if (enableEvents) 88 | { 89 | IColourInfo c = (IColourInfo)e.Item.Tag; 90 | c.IsChecked = e.Item.Checked; 91 | updateInfo(e.Item); 92 | } 93 | } 94 | 95 | private void listView_SelectedIndexChanged(object sender, EventArgs e) 96 | { 97 | if (listView.SelectedIndices.Count < 1) return; 98 | ListViewItem lvi = listView.SelectedItems[0]; 99 | if (mReplacing) 100 | { 101 | mReplacing = false; 102 | OnColourChangeEvent(new ColourChangeEventArgs(mColorToReplace, lvi.BackColor)); 103 | } 104 | updateInfo(lvi); 105 | 106 | } 107 | 108 | private void listView_KeyDown(object sender, KeyEventArgs e) 109 | { 110 | if (e.KeyCode == Keys.Delete) 111 | { 112 | if (listView.SelectedIndices.Count < 1) return; 113 | ListViewItem lvi = listView.SelectedItems[0]; 114 | if(!lvi.Checked) OnColourChangeEvent(new ColourChangeEventArgs(lvi.BackColor)); 115 | } 116 | } 117 | 118 | public event ColourChangeEventHandler ColourChangeEvent; 119 | public virtual void OnColourChangeEvent(ColourChangeEventArgs e) 120 | { 121 | ColourChangeEvent(this, e); 122 | } 123 | 124 | private void deleteToolStripMenuItem_Click(object sender, EventArgs e) 125 | { 126 | if (listView.SelectedIndices.Count < 1) return; 127 | ListViewItem lvi = listView.SelectedItems[0]; 128 | if(!lvi.Checked) OnColourChangeEvent(new ColourChangeEventArgs(lvi.BackColor)); 129 | } 130 | 131 | private void replaceToolStripMenuItem_Click(object sender, EventArgs e) 132 | { 133 | if (listView.SelectedIndices.Count < 1) return; 134 | ListViewItem lvi = listView.SelectedItems[0]; 135 | if (!lvi.Checked) 136 | { 137 | mReplacing = true; 138 | mColorToReplace = lvi.BackColor; 139 | statusLabel.Text = "Select Colour to replace this one"; 140 | } 141 | } 142 | } 143 | 144 | public class ColourChangeEventArgs : EventArgs 145 | { 146 | private Color mColour; 147 | public Color Colour { get { return mColour; } } 148 | private Color mReplacement; 149 | public Color ReplacementColour {get { return mReplacement;}} 150 | public bool DoReplace { get { return mDoReplace; } } 151 | private bool mDoReplace = false; 152 | 153 | public ColourChangeEventArgs(Color colour) { mColour = colour; } 154 | public ColourChangeEventArgs(Color colour, Color replacement) { 155 | mColour = colour; 156 | mDoReplace = true; 157 | mReplacement = replacement; 158 | } 159 | } 160 | public delegate void ColourChangeEventHandler(object sender, ColourChangeEventArgs e); 161 | } 162 | -------------------------------------------------------------------------------- /CrossStitchCreator/PatternEditor.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /CrossStitchCreator/DMCColours.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | Resources\DMC Cotton Floss converted to RGB Values.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 123 | 124 | -------------------------------------------------------------------------------- /CrossStitchCreator/ColourMapViewer.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 124, 17 122 | 123 | 124 | 17, 17 125 | 126 | -------------------------------------------------------------------------------- /CrossStitchCreator/MainForm.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 141, 17 125 | 126 | 127 | 256, 17 128 | 129 | 130 | 378, 17 131 | 132 | -------------------------------------------------------------------------------- /CrossStitchCreator/ColourMapViewer.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CrossStitchCreator 2 | { 3 | partial class ColourMapViewer 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.listView = new System.Windows.Forms.ListView(); 33 | this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 34 | this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | this.infoBox = new System.Windows.Forms.TextBox(); 37 | this.pictureBox = new System.Windows.Forms.PictureBox(); 38 | this.colorDialog = new System.Windows.Forms.ColorDialog(); 39 | this.statusLabel = new System.Windows.Forms.Label(); 40 | this.contextMenu.SuspendLayout(); 41 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); 42 | this.SuspendLayout(); 43 | // 44 | // listView 45 | // 46 | this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 47 | | System.Windows.Forms.AnchorStyles.Left) 48 | | System.Windows.Forms.AnchorStyles.Right))); 49 | this.listView.CheckBoxes = true; 50 | this.listView.ContextMenuStrip = this.contextMenu; 51 | this.listView.Location = new System.Drawing.Point(12, 178); 52 | this.listView.MultiSelect = false; 53 | this.listView.Name = "listView"; 54 | this.listView.Size = new System.Drawing.Size(489, 229); 55 | this.listView.TabIndex = 0; 56 | this.listView.UseCompatibleStateImageBehavior = false; 57 | this.listView.View = System.Windows.Forms.View.List; 58 | this.listView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listView_ItemChecked); 59 | this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged); 60 | this.listView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listView_KeyDown); 61 | // 62 | // contextMenu 63 | // 64 | this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 65 | this.deleteToolStripMenuItem, 66 | this.replaceToolStripMenuItem}); 67 | this.contextMenu.Name = "contextMenu"; 68 | this.contextMenu.Size = new System.Drawing.Size(113, 48); 69 | // 70 | // deleteToolStripMenuItem 71 | // 72 | this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; 73 | this.deleteToolStripMenuItem.Size = new System.Drawing.Size(112, 22); 74 | this.deleteToolStripMenuItem.Text = "Delete"; 75 | this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click); 76 | // 77 | // replaceToolStripMenuItem 78 | // 79 | this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem"; 80 | this.replaceToolStripMenuItem.Size = new System.Drawing.Size(112, 22); 81 | this.replaceToolStripMenuItem.Text = "Replace"; 82 | this.replaceToolStripMenuItem.Click += new System.EventHandler(this.replaceToolStripMenuItem_Click); 83 | // 84 | // infoBox 85 | // 86 | this.infoBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 87 | | System.Windows.Forms.AnchorStyles.Right))); 88 | this.infoBox.Location = new System.Drawing.Point(12, 12); 89 | this.infoBox.Multiline = true; 90 | this.infoBox.Name = "infoBox"; 91 | this.infoBox.ReadOnly = true; 92 | this.infoBox.Size = new System.Drawing.Size(404, 160); 93 | this.infoBox.TabIndex = 1; 94 | // 95 | // pictureBox 96 | // 97 | this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 98 | this.pictureBox.BackColor = System.Drawing.SystemColors.ActiveCaptionText; 99 | this.pictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 100 | this.pictureBox.Location = new System.Drawing.Point(422, 12); 101 | this.pictureBox.Name = "pictureBox"; 102 | this.pictureBox.Size = new System.Drawing.Size(79, 160); 103 | this.pictureBox.TabIndex = 2; 104 | this.pictureBox.TabStop = false; 105 | // 106 | // statusLabel 107 | // 108 | this.statusLabel.AutoSize = true; 109 | this.statusLabel.Location = new System.Drawing.Point(13, 414); 110 | this.statusLabel.Name = "statusLabel"; 111 | this.statusLabel.Size = new System.Drawing.Size(37, 13); 112 | this.statusLabel.TabIndex = 3; 113 | this.statusLabel.Text = "Status"; 114 | // 115 | // ColourMapViewer 116 | // 117 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 118 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 119 | this.ClientSize = new System.Drawing.Size(513, 436); 120 | this.Controls.Add(this.statusLabel); 121 | this.Controls.Add(this.pictureBox); 122 | this.Controls.Add(this.infoBox); 123 | this.Controls.Add(this.listView); 124 | this.Name = "ColourMapViewer"; 125 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 126 | this.Text = "Colour Map Viewer"; 127 | this.contextMenu.ResumeLayout(false); 128 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); 129 | this.ResumeLayout(false); 130 | this.PerformLayout(); 131 | 132 | } 133 | 134 | #endregion 135 | 136 | private System.Windows.Forms.ListView listView; 137 | private System.Windows.Forms.TextBox infoBox; 138 | private System.Windows.Forms.PictureBox pictureBox; 139 | private System.Windows.Forms.ColorDialog colorDialog; 140 | private System.Windows.Forms.ContextMenuStrip contextMenu; 141 | private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; 142 | private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem; 143 | private System.Windows.Forms.Label statusLabel; 144 | } 145 | } -------------------------------------------------------------------------------- /CrossStitchCreator/CrossStitchCreator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {34959807-2C24-4D0F-8698-0FDA1F584CB6} 9 | Exe 10 | Properties 11 | CrossStitchCreator 12 | CrossStitchCreator 13 | v4.0 14 | 15 | 16 | 512 17 | 18 | 19 | x86 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | x86 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | ..\Dependencies\DTALib.dll 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | Form 59 | 60 | 61 | AboutBox.cs 62 | 63 | 64 | 65 | 66 | 67 | 68 | True 69 | True 70 | DMCColours.resx 71 | 72 | 73 | 74 | Form 75 | 76 | 77 | MainForm.cs 78 | 79 | 80 | Form 81 | 82 | 83 | ColourMapViewer.cs 84 | 85 | 86 | 87 | Form 88 | 89 | 90 | PatternEditor.cs 91 | 92 | 93 | 94 | 95 | AboutBox.cs 96 | 97 | 98 | ResXFileCodeGenerator 99 | DMCColours.Designer.cs 100 | 101 | 102 | MainForm.cs 103 | 104 | 105 | ColourMapViewer.cs 106 | 107 | 108 | PatternEditor.cs 109 | 110 | 111 | ResXFileCodeGenerator 112 | Patterns1.Designer.cs 113 | Designer 114 | 115 | 116 | True 117 | Patterns.resx 118 | True 119 | 120 | 121 | 122 | PublicSettingsSingleFileGenerator 123 | Settings.Designer.cs 124 | 125 | 126 | True 127 | Settings.settings 128 | True 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | readme.txt 195 | 196 | 197 | 198 | 205 | -------------------------------------------------------------------------------- /CrossStitchCreator/ColourMap.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Drawing; 6 | 7 | namespace CrossStitchCreator 8 | { 9 | public interface IColourMap 10 | { 11 | Color GetNearestColour(Color c); 12 | /// 13 | /// Finds the least common colour. If parameter matchWhenChecked is true, then the search will ignore ColourInfos that are checked 14 | /// (typically to indicate that this colour is not to be removed). 15 | /// 16 | /// 17 | /// 18 | Color GetLeastCommonColour(bool matchWhenChecked); 19 | IColourInfo GetLeastCommonColourInfo(bool matchWhenChecked); 20 | void ClearFrequencies(); 21 | void RemoveColour(Color c); 22 | Dictionary Colours { get; set; } 23 | int Count { get; } 24 | /// 25 | /// Returns a (preferably deep) clone of the ColourMap array. 26 | /// 27 | /// 28 | IColourInfo[] ToArray(); 29 | /// 30 | /// Returns a (preferably deep) cloned list of the ColourMap array. 31 | /// 32 | /// 33 | List ToList(); 34 | List GetPalette(); 35 | IColourMap Clone(); 36 | } 37 | 38 | public interface IColourInfo 39 | { 40 | Color Colour { get; set; } 41 | string Name { get; set; } 42 | bool IsChecked { get; set; } 43 | string PrintInfo(); 44 | object Tag { get; set; } 45 | int Frequency { get; set; } 46 | IColourInfo Clone(); 47 | } 48 | /// 49 | /// A simple colourmap that implements RGB444 50 | /// 51 | public class SimpleColourMap : IColourMap 52 | { 53 | public Dictionary Colours { get; set; } 54 | public int Count { get { return Colours.Count; } } 55 | 56 | public SimpleColourMap() : this(false) { } 57 | 58 | public SimpleColourMap(bool createEmpty) 59 | { 60 | Colours = new Dictionary(); 61 | if (!createEmpty) 62 | { 63 | int index = 0; 64 | for (int r = 0; r < 256; r += 16) 65 | for (int g = 0; g < 256; g += 16) 66 | for (int b = 0; b < 256; b += 16) 67 | { 68 | Color c = Color.FromArgb(255, r, g, b); 69 | SimpleColour s = new SimpleColour("" + c, index, c); 70 | Colours[c] = s; 71 | } 72 | } 73 | } 74 | 75 | public virtual IColourMap Clone() 76 | { 77 | IColourMap cmap = new SimpleColourMap(true); 78 | Colours = new Dictionary(); 79 | foreach (KeyValuePair pair in cmap.Colours) 80 | { 81 | Colours[pair.Key] = pair.Value.Clone(); 82 | } 83 | return cmap; 84 | } 85 | 86 | public Color GetNearestColour(Color colourToMatch) 87 | { 88 | byte minDiff = byte.MaxValue; 89 | Color c = Color.Black; 90 | foreach (KeyValuePair col in Colours) 91 | { 92 | byte diff = getMaxDiff(colourToMatch, col.Key); 93 | if (diff < minDiff) 94 | { 95 | minDiff = diff; 96 | c = col.Key; 97 | } 98 | } 99 | return c; 100 | } 101 | 102 | private byte getMaxDiff(Color c1, Color c2) 103 | { 104 | // Get difference between components ( red green blue ) 105 | // of given color and appropriate components of pallete color 106 | byte bDiff = c1.B > c2.B ? (byte)(c1.B - c2.B) : (byte)(c2.B - c1.B); 107 | byte gDiff = c1.G > c2.G ? (byte)(c1.G - c2.G) : (byte)(c2.G - c1.G); 108 | byte rDiff = c1.R > c2.R ? (byte)(c1.R - c2.R) : (byte)(c2.R - c1.R); 109 | byte aDiff = c1.A > c2.A ? (byte)(c1.A - c2.A) : (byte)(c2.A - c1.A); 110 | 111 | // Get max difference 112 | byte max = bDiff > gDiff ? bDiff : gDiff; 113 | max = max > rDiff ? max : rDiff; 114 | max = max > aDiff ? max : aDiff; 115 | 116 | return max; 117 | 118 | } 119 | 120 | /// 121 | /// Finds the least common colour. If parameter matchWhenChecked is true, then the search will ignore ColourInfos that are checked 122 | /// (typically to indicate that this colour is not to be removed). 123 | /// 124 | /// 125 | /// 126 | public Color GetLeastCommonColour(bool matchWhenChecked) 127 | { 128 | if (Colours.Count == 0) return Color.Black; 129 | Color c = Color.Black; 130 | int min = int.MaxValue; 131 | foreach (KeyValuePair col in Colours) 132 | { 133 | if (matchWhenChecked && col.Value.IsChecked) continue; 134 | // can quit early if the frequency is 1. 135 | if (col.Value.Frequency == 1) 136 | return col.Key; 137 | if (col.Value.Frequency < min) 138 | { 139 | min = col.Value.Frequency; 140 | c = col.Key; 141 | } 142 | } 143 | return c; 144 | } 145 | 146 | public IColourInfo GetLeastCommonColourInfo(bool matchWhenChecked) 147 | { 148 | Color c = GetLeastCommonColour(matchWhenChecked); 149 | if (Colours.ContainsKey(c)) return Colours[c]; 150 | return null; 151 | 152 | } 153 | 154 | 155 | 156 | public IColourInfo[] ToArray() 157 | { 158 | IColourInfo[] ret = new IColourInfo[Colours.Count]; 159 | int i = 0; 160 | foreach (KeyValuePair pair in Colours) 161 | { 162 | ret[i] = pair.Value.Clone(); 163 | i++; 164 | } 165 | return ret; 166 | } 167 | public List ToList() 168 | { 169 | List ret = new List(); 170 | foreach (KeyValuePair pair in Colours) 171 | ret.Add(pair.Value.Clone()); 172 | return ret; 173 | } 174 | 175 | public void RemoveColour(Color c) 176 | { 177 | if (Colours.ContainsKey(c)) Colours.Remove(c); 178 | } 179 | 180 | public void ClearFrequencies() 181 | { 182 | foreach (KeyValuePair pair in Colours) 183 | pair.Value.Frequency = 0; 184 | } 185 | 186 | public List GetPalette() 187 | { 188 | return Colours.Keys.ToList(); 189 | } 190 | } 191 | 192 | public class SimpleColour : IColourInfo 193 | { 194 | public Color Colour { get; set; } 195 | public int Index { get; set; } 196 | public string Name { get; set; } 197 | private bool mChecked = false; 198 | public bool IsChecked 199 | { 200 | get 201 | { 202 | return mChecked; 203 | } 204 | set 205 | { 206 | mChecked = value; 207 | } 208 | } 209 | public object Tag { get; set; } 210 | public int Frequency { get; set; } 211 | 212 | public SimpleColour(string name, int index, Color colour) 213 | { 214 | Name = name; 215 | Index = index; 216 | Colour = colour; 217 | } 218 | public SimpleColour(SimpleColour d) 219 | { 220 | Name = d.Name; 221 | Index = d.Index; 222 | Colour = d.Colour; 223 | Tag = d.Tag; 224 | Frequency = d.Frequency; 225 | IsChecked = d.IsChecked; 226 | } 227 | 228 | public virtual string PrintInfo() 229 | { 230 | return Name + Environment.NewLine + 231 | "Checked: " + IsChecked + Environment.NewLine + 232 | "Tag: " + Tag + Environment.NewLine + 233 | "Colour: " + Colour + Environment.NewLine + 234 | "Frequency: " + Frequency + Environment.NewLine + 235 | "Index: " + Index + Environment.NewLine; 236 | } 237 | 238 | public virtual IColourInfo Clone() 239 | { 240 | return new SimpleColour(this); 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /CrossStitchCreator/PatternEditor.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CrossStitchCreator 2 | { 3 | partial class PatternEditor 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.pictureBox = new System.Windows.Forms.PictureBox(); 32 | this.patternList = new System.Windows.Forms.ListView(); 33 | this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 34 | this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 35 | this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 36 | this.addButton = new System.Windows.Forms.Button(); 37 | this.updateButton = new System.Windows.Forms.Button(); 38 | this.label1 = new System.Windows.Forms.Label(); 39 | this.colourBox = new System.Windows.Forms.PictureBox(); 40 | this.sortingCombo = new System.Windows.Forms.ComboBox(); 41 | this.label2 = new System.Windows.Forms.Label(); 42 | this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 43 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); 44 | ((System.ComponentModel.ISupportInitialize)(this.colourBox)).BeginInit(); 45 | this.SuspendLayout(); 46 | // 47 | // pictureBox 48 | // 49 | this.pictureBox.BackColor = System.Drawing.Color.White; 50 | this.pictureBox.Location = new System.Drawing.Point(12, 12); 51 | this.pictureBox.Name = "pictureBox"; 52 | this.pictureBox.Size = new System.Drawing.Size(240, 240); 53 | this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; 54 | this.pictureBox.TabIndex = 0; 55 | this.pictureBox.TabStop = false; 56 | this.pictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox_MouseDown); 57 | this.pictureBox.MouseLeave += new System.EventHandler(this.pictureBox_MouseLeave); 58 | this.pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox_MouseMove); 59 | this.pictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox_MouseUp); 60 | // 61 | // patternList 62 | // 63 | this.patternList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 64 | | System.Windows.Forms.AnchorStyles.Left) 65 | | System.Windows.Forms.AnchorStyles.Right))); 66 | this.patternList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 67 | this.columnHeader1, 68 | this.columnHeader2, 69 | this.columnHeader3, 70 | this.columnHeader4}); 71 | this.patternList.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 72 | this.patternList.GridLines = true; 73 | this.patternList.Location = new System.Drawing.Point(12, 277); 74 | this.patternList.MultiSelect = false; 75 | this.patternList.Name = "patternList"; 76 | this.patternList.ShowItemToolTips = true; 77 | this.patternList.Size = new System.Drawing.Size(446, 262); 78 | this.patternList.TabIndex = 1; 79 | this.patternList.UseCompatibleStateImageBehavior = false; 80 | this.patternList.View = System.Windows.Forms.View.Details; 81 | this.patternList.SelectedIndexChanged += new System.EventHandler(this.patternList_SelectedIndexChanged); 82 | // 83 | // columnHeader1 84 | // 85 | this.columnHeader1.Text = "Colour"; 86 | this.columnHeader1.Width = 74; 87 | // 88 | // columnHeader2 89 | // 90 | this.columnHeader2.Text = "Name"; 91 | this.columnHeader2.Width = 155; 92 | // 93 | // columnHeader3 94 | // 95 | this.columnHeader3.Text = "Frequency"; 96 | this.columnHeader3.Width = 98; 97 | // 98 | // addButton 99 | // 100 | this.addButton.Location = new System.Drawing.Point(258, 42); 101 | this.addButton.Name = "addButton"; 102 | this.addButton.Size = new System.Drawing.Size(75, 23); 103 | this.addButton.TabIndex = 2; 104 | this.addButton.Text = "Add New"; 105 | this.addButton.UseVisualStyleBackColor = true; 106 | this.addButton.Click += new System.EventHandler(this.addButton_Click); 107 | // 108 | // updateButton 109 | // 110 | this.updateButton.Location = new System.Drawing.Point(257, 13); 111 | this.updateButton.Name = "updateButton"; 112 | this.updateButton.Size = new System.Drawing.Size(75, 23); 113 | this.updateButton.TabIndex = 3; 114 | this.updateButton.Text = "Update"; 115 | this.updateButton.UseVisualStyleBackColor = true; 116 | this.updateButton.Click += new System.EventHandler(this.updateButton_Click); 117 | // 118 | // label1 119 | // 120 | this.label1.AutoSize = true; 121 | this.label1.Location = new System.Drawing.Point(12, 258); 122 | this.label1.Name = "label1"; 123 | this.label1.Size = new System.Drawing.Size(92, 13); 124 | this.label1.TabIndex = 4; 125 | this.label1.Text = "Associated Colour"; 126 | // 127 | // colourBox 128 | // 129 | this.colourBox.BackColor = System.Drawing.SystemColors.ActiveCaptionText; 130 | this.colourBox.Location = new System.Drawing.Point(111, 258); 131 | this.colourBox.Name = "colourBox"; 132 | this.colourBox.Size = new System.Drawing.Size(60, 13); 133 | this.colourBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; 134 | this.colourBox.TabIndex = 5; 135 | this.colourBox.TabStop = false; 136 | // 137 | // sortingCombo 138 | // 139 | this.sortingCombo.FormattingEnabled = true; 140 | this.sortingCombo.Location = new System.Drawing.Point(258, 255); 141 | this.sortingCombo.Name = "sortingCombo"; 142 | this.sortingCombo.Size = new System.Drawing.Size(75, 21); 143 | this.sortingCombo.TabIndex = 6; 144 | this.sortingCombo.DropDownClosed += new System.EventHandler(this.sortingCombo_DropDownClosed); 145 | // 146 | // label2 147 | // 148 | this.label2.AutoSize = true; 149 | this.label2.Location = new System.Drawing.Point(212, 258); 150 | this.label2.Name = "label2"; 151 | this.label2.Size = new System.Drawing.Size(40, 13); 152 | this.label2.TabIndex = 7; 153 | this.label2.Text = "Sorting"; 154 | // 155 | // columnHeader4 156 | // 157 | this.columnHeader4.Text = "Note"; 158 | this.columnHeader4.Width = 133; 159 | // 160 | // PatternEditor 161 | // 162 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 163 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 164 | this.ClientSize = new System.Drawing.Size(470, 551); 165 | this.Controls.Add(this.label2); 166 | this.Controls.Add(this.sortingCombo); 167 | this.Controls.Add(this.colourBox); 168 | this.Controls.Add(this.label1); 169 | this.Controls.Add(this.updateButton); 170 | this.Controls.Add(this.addButton); 171 | this.Controls.Add(this.patternList); 172 | this.Controls.Add(this.pictureBox); 173 | this.Name = "PatternEditor"; 174 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 175 | this.Text = "PatternEditor"; 176 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); 177 | ((System.ComponentModel.ISupportInitialize)(this.colourBox)).EndInit(); 178 | this.ResumeLayout(false); 179 | this.PerformLayout(); 180 | 181 | } 182 | 183 | #endregion 184 | 185 | private System.Windows.Forms.PictureBox pictureBox; 186 | private System.Windows.Forms.ListView patternList; 187 | private System.Windows.Forms.Button addButton; 188 | private System.Windows.Forms.Button updateButton; 189 | private System.Windows.Forms.Label label1; 190 | private System.Windows.Forms.PictureBox colourBox; 191 | private System.Windows.Forms.ComboBox sortingCombo; 192 | private System.Windows.Forms.Label label2; 193 | private System.Windows.Forms.ColumnHeader columnHeader1; 194 | private System.Windows.Forms.ColumnHeader columnHeader2; 195 | private System.Windows.Forms.ColumnHeader columnHeader3; 196 | private System.Windows.Forms.ColumnHeader columnHeader4; 197 | } 198 | } -------------------------------------------------------------------------------- /CrossStitchCreator/AboutBox.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CrossStitchCreator 2 | { 3 | partial class AboutBox 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | protected override void Dispose(bool disposing) 14 | { 15 | if (disposing && (components != null)) 16 | { 17 | components.Dispose(); 18 | } 19 | base.Dispose(disposing); 20 | } 21 | 22 | #region Windows Form Designer generated code 23 | 24 | /// 25 | /// Required method for Designer support - do not modify 26 | /// the contents of this method with the code editor. 27 | /// 28 | private void InitializeComponent() 29 | { 30 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox)); 31 | this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 32 | this.logoPictureBox = new System.Windows.Forms.PictureBox(); 33 | this.labelProductName = new System.Windows.Forms.Label(); 34 | this.labelVersion = new System.Windows.Forms.Label(); 35 | this.labelCopyright = new System.Windows.Forms.Label(); 36 | this.labelCompanyName = new System.Windows.Forms.Label(); 37 | this.textBoxDescription = new System.Windows.Forms.TextBox(); 38 | this.okButton = new System.Windows.Forms.Button(); 39 | this.tableLayoutPanel.SuspendLayout(); 40 | ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit(); 41 | this.SuspendLayout(); 42 | // 43 | // tableLayoutPanel 44 | // 45 | this.tableLayoutPanel.ColumnCount = 2; 46 | this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F)); 47 | this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67F)); 48 | this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0); 49 | this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0); 50 | this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1); 51 | this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2); 52 | this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3); 53 | this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4); 54 | this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5); 55 | this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; 56 | this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9); 57 | this.tableLayoutPanel.Name = "tableLayoutPanel"; 58 | this.tableLayoutPanel.RowCount = 6; 59 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 60 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 61 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 62 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 63 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); 64 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 65 | this.tableLayoutPanel.Size = new System.Drawing.Size(417, 265); 66 | this.tableLayoutPanel.TabIndex = 0; 67 | // 68 | // logoPictureBox 69 | // 70 | this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; 71 | this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("logoPictureBox.Image"))); 72 | this.logoPictureBox.Location = new System.Drawing.Point(3, 3); 73 | this.logoPictureBox.Name = "logoPictureBox"; 74 | this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 6); 75 | this.logoPictureBox.Size = new System.Drawing.Size(131, 259); 76 | this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 77 | this.logoPictureBox.TabIndex = 12; 78 | this.logoPictureBox.TabStop = false; 79 | // 80 | // labelProductName 81 | // 82 | this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; 83 | this.labelProductName.Location = new System.Drawing.Point(143, 0); 84 | this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); 85 | this.labelProductName.MaximumSize = new System.Drawing.Size(0, 17); 86 | this.labelProductName.Name = "labelProductName"; 87 | this.labelProductName.Size = new System.Drawing.Size(271, 17); 88 | this.labelProductName.TabIndex = 19; 89 | this.labelProductName.Text = "Product Name"; 90 | this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 91 | // 92 | // labelVersion 93 | // 94 | this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; 95 | this.labelVersion.Location = new System.Drawing.Point(143, 26); 96 | this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); 97 | this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17); 98 | this.labelVersion.Name = "labelVersion"; 99 | this.labelVersion.Size = new System.Drawing.Size(271, 17); 100 | this.labelVersion.TabIndex = 0; 101 | this.labelVersion.Text = "Version"; 102 | this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 103 | // 104 | // labelCopyright 105 | // 106 | this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; 107 | this.labelCopyright.Location = new System.Drawing.Point(143, 52); 108 | this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); 109 | this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 17); 110 | this.labelCopyright.Name = "labelCopyright"; 111 | this.labelCopyright.Size = new System.Drawing.Size(271, 17); 112 | this.labelCopyright.TabIndex = 21; 113 | this.labelCopyright.Text = "Copyright"; 114 | this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 115 | // 116 | // labelCompanyName 117 | // 118 | this.labelCompanyName.Dock = System.Windows.Forms.DockStyle.Fill; 119 | this.labelCompanyName.Location = new System.Drawing.Point(143, 78); 120 | this.labelCompanyName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); 121 | this.labelCompanyName.MaximumSize = new System.Drawing.Size(0, 17); 122 | this.labelCompanyName.Name = "labelCompanyName"; 123 | this.labelCompanyName.Size = new System.Drawing.Size(271, 17); 124 | this.labelCompanyName.TabIndex = 22; 125 | this.labelCompanyName.Text = "Company Name"; 126 | this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 127 | // 128 | // textBoxDescription 129 | // 130 | this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; 131 | this.textBoxDescription.Location = new System.Drawing.Point(143, 107); 132 | this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); 133 | this.textBoxDescription.Multiline = true; 134 | this.textBoxDescription.Name = "textBoxDescription"; 135 | this.textBoxDescription.ReadOnly = true; 136 | this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both; 137 | this.textBoxDescription.Size = new System.Drawing.Size(271, 126); 138 | this.textBoxDescription.TabIndex = 23; 139 | this.textBoxDescription.TabStop = false; 140 | this.textBoxDescription.Text = "Description"; 141 | // 142 | // okButton 143 | // 144 | this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 145 | this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; 146 | this.okButton.Location = new System.Drawing.Point(339, 239); 147 | this.okButton.Name = "okButton"; 148 | this.okButton.Size = new System.Drawing.Size(75, 23); 149 | this.okButton.TabIndex = 24; 150 | this.okButton.Text = "&OK"; 151 | // 152 | // AboutBox 153 | // 154 | this.AcceptButton = this.okButton; 155 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 156 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 157 | this.ClientSize = new System.Drawing.Size(435, 283); 158 | this.Controls.Add(this.tableLayoutPanel); 159 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 160 | this.MaximizeBox = false; 161 | this.MinimizeBox = false; 162 | this.Name = "AboutBox"; 163 | this.Padding = new System.Windows.Forms.Padding(9); 164 | this.ShowIcon = false; 165 | this.ShowInTaskbar = false; 166 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 167 | this.Text = "AboutBox"; 168 | this.tableLayoutPanel.ResumeLayout(false); 169 | this.tableLayoutPanel.PerformLayout(); 170 | ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit(); 171 | this.ResumeLayout(false); 172 | 173 | } 174 | 175 | #endregion 176 | 177 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; 178 | private System.Windows.Forms.PictureBox logoPictureBox; 179 | private System.Windows.Forms.Label labelProductName; 180 | private System.Windows.Forms.Label labelVersion; 181 | private System.Windows.Forms.Label labelCopyright; 182 | private System.Windows.Forms.Label labelCompanyName; 183 | private System.Windows.Forms.TextBox textBoxDescription; 184 | private System.Windows.Forms.Button okButton; 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /CrossStitchCreator/Properties/Patterns.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\resources\bslash.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\resources\bsquare2.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\resources\circle.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\resources\cross.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | 134 | ..\resources\diamond.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 135 | 136 | 137 | ..\resources\fslash.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 138 | 139 | 140 | ..\resources\horz.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 141 | 142 | 143 | ..\resources\plus.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 144 | 145 | 146 | ..\resources\square2.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 147 | 148 | 149 | ..\resources\star.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 150 | 151 | 152 | ..\resources\vert.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 153 | 154 | 155 | ..\resources\wbslash.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 156 | 157 | 158 | ..\resources\wcircle.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 159 | 160 | 161 | ..\resources\wcross.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 162 | 163 | 164 | ..\resources\wdiamond.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 165 | 166 | 167 | ..\resources\wfslash.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 168 | 169 | 170 | ..\resources\whorz.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 171 | 172 | 173 | ..\resources\wplus.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 174 | 175 | 176 | ..\resources\wstar.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 177 | 178 | 179 | ..\resources\wvert.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 180 | 181 | -------------------------------------------------------------------------------- /CrossStitchCreator/Properties/Patterns1.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CrossStitchCreator.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Patterns { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Patterns() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CrossStitchCreator.Properties.Patterns", typeof(Patterns).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap p_bslash { 67 | get { 68 | object obj = ResourceManager.GetObject("p_bslash", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap p_bsquare2 { 77 | get { 78 | object obj = ResourceManager.GetObject("p_bsquare2", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap p_circle { 87 | get { 88 | object obj = ResourceManager.GetObject("p_circle", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Drawing.Bitmap. 95 | /// 96 | internal static System.Drawing.Bitmap p_cross { 97 | get { 98 | object obj = ResourceManager.GetObject("p_cross", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// Looks up a localized resource of type System.Drawing.Bitmap. 105 | /// 106 | internal static System.Drawing.Bitmap p_diamond { 107 | get { 108 | object obj = ResourceManager.GetObject("p_diamond", resourceCulture); 109 | return ((System.Drawing.Bitmap)(obj)); 110 | } 111 | } 112 | 113 | /// 114 | /// Looks up a localized resource of type System.Drawing.Bitmap. 115 | /// 116 | internal static System.Drawing.Bitmap p_fslash { 117 | get { 118 | object obj = ResourceManager.GetObject("p_fslash", resourceCulture); 119 | return ((System.Drawing.Bitmap)(obj)); 120 | } 121 | } 122 | 123 | /// 124 | /// Looks up a localized resource of type System.Drawing.Bitmap. 125 | /// 126 | internal static System.Drawing.Bitmap p_horz { 127 | get { 128 | object obj = ResourceManager.GetObject("p_horz", resourceCulture); 129 | return ((System.Drawing.Bitmap)(obj)); 130 | } 131 | } 132 | 133 | /// 134 | /// Looks up a localized resource of type System.Drawing.Bitmap. 135 | /// 136 | internal static System.Drawing.Bitmap p_plus { 137 | get { 138 | object obj = ResourceManager.GetObject("p_plus", resourceCulture); 139 | return ((System.Drawing.Bitmap)(obj)); 140 | } 141 | } 142 | 143 | /// 144 | /// Looks up a localized resource of type System.Drawing.Bitmap. 145 | /// 146 | internal static System.Drawing.Bitmap p_square2 { 147 | get { 148 | object obj = ResourceManager.GetObject("p_square2", resourceCulture); 149 | return ((System.Drawing.Bitmap)(obj)); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized resource of type System.Drawing.Bitmap. 155 | /// 156 | internal static System.Drawing.Bitmap p_star { 157 | get { 158 | object obj = ResourceManager.GetObject("p_star", resourceCulture); 159 | return ((System.Drawing.Bitmap)(obj)); 160 | } 161 | } 162 | 163 | /// 164 | /// Looks up a localized resource of type System.Drawing.Bitmap. 165 | /// 166 | internal static System.Drawing.Bitmap p_vert { 167 | get { 168 | object obj = ResourceManager.GetObject("p_vert", resourceCulture); 169 | return ((System.Drawing.Bitmap)(obj)); 170 | } 171 | } 172 | 173 | /// 174 | /// Looks up a localized resource of type System.Drawing.Bitmap. 175 | /// 176 | internal static System.Drawing.Bitmap p_wbslash { 177 | get { 178 | object obj = ResourceManager.GetObject("p_wbslash", resourceCulture); 179 | return ((System.Drawing.Bitmap)(obj)); 180 | } 181 | } 182 | 183 | /// 184 | /// Looks up a localized resource of type System.Drawing.Bitmap. 185 | /// 186 | internal static System.Drawing.Bitmap p_wcircle { 187 | get { 188 | object obj = ResourceManager.GetObject("p_wcircle", resourceCulture); 189 | return ((System.Drawing.Bitmap)(obj)); 190 | } 191 | } 192 | 193 | /// 194 | /// Looks up a localized resource of type System.Drawing.Bitmap. 195 | /// 196 | internal static System.Drawing.Bitmap p_wcross { 197 | get { 198 | object obj = ResourceManager.GetObject("p_wcross", resourceCulture); 199 | return ((System.Drawing.Bitmap)(obj)); 200 | } 201 | } 202 | 203 | /// 204 | /// Looks up a localized resource of type System.Drawing.Bitmap. 205 | /// 206 | internal static System.Drawing.Bitmap p_wdiamond { 207 | get { 208 | object obj = ResourceManager.GetObject("p_wdiamond", resourceCulture); 209 | return ((System.Drawing.Bitmap)(obj)); 210 | } 211 | } 212 | 213 | /// 214 | /// Looks up a localized resource of type System.Drawing.Bitmap. 215 | /// 216 | internal static System.Drawing.Bitmap p_wfslash { 217 | get { 218 | object obj = ResourceManager.GetObject("p_wfslash", resourceCulture); 219 | return ((System.Drawing.Bitmap)(obj)); 220 | } 221 | } 222 | 223 | /// 224 | /// Looks up a localized resource of type System.Drawing.Bitmap. 225 | /// 226 | internal static System.Drawing.Bitmap p_whorz { 227 | get { 228 | object obj = ResourceManager.GetObject("p_whorz", resourceCulture); 229 | return ((System.Drawing.Bitmap)(obj)); 230 | } 231 | } 232 | 233 | /// 234 | /// Looks up a localized resource of type System.Drawing.Bitmap. 235 | /// 236 | internal static System.Drawing.Bitmap p_wplus { 237 | get { 238 | object obj = ResourceManager.GetObject("p_wplus", resourceCulture); 239 | return ((System.Drawing.Bitmap)(obj)); 240 | } 241 | } 242 | 243 | /// 244 | /// Looks up a localized resource of type System.Drawing.Bitmap. 245 | /// 246 | internal static System.Drawing.Bitmap p_wstar { 247 | get { 248 | object obj = ResourceManager.GetObject("p_wstar", resourceCulture); 249 | return ((System.Drawing.Bitmap)(obj)); 250 | } 251 | } 252 | 253 | /// 254 | /// Looks up a localized resource of type System.Drawing.Bitmap. 255 | /// 256 | internal static System.Drawing.Bitmap p_wvert { 257 | get { 258 | object obj = ResourceManager.GetObject("p_wvert", resourceCulture); 259 | return ((System.Drawing.Bitmap)(obj)); 260 | } 261 | } 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /CrossStitchCreator/ImagingTool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Drawing; 6 | using System.Drawing.Imaging; 7 | using System.Drawing.Drawing2D; 8 | using System.Windows.Media.Imaging; // PresentationCore.dll 9 | using DTALib; 10 | using System.ComponentModel; 11 | 12 | namespace CrossStitchCreator 13 | { 14 | [Serializable()] 15 | public class ImagingTool 16 | { 17 | public Bitmap InputImage { get; set; } 18 | private Bitmap mOutput; 19 | public Bitmap OutputImage { get { return mOutput; } } 20 | public IColourMap ColourMap { get; set; } 21 | public int TargetColours { get; set; } 22 | 23 | public ImagingTool(Image inputImage) : this(inputImage, null) { } 24 | 25 | public ImagingTool(Image inputImage, IColourMap cmap) 26 | { 27 | InputImage = (Bitmap)inputImage; 28 | mOutput = InputImage; 29 | ColourMap = cmap; 30 | } 31 | 32 | public void ReplaceColour(Color colorToReplace, Color newColor) 33 | { 34 | Bitmap original = OutputImage; 35 | for (int x = 0; x < original.Width; x++) 36 | for (int y = 0; y < original.Height; y++) 37 | { 38 | if (original.GetPixel(x, y) == colorToReplace) 39 | original.SetPixel(x, y, newColor); 40 | } 41 | } 42 | 43 | public void RemoveFromPalette(IColourInfo colorToRemove) { if(colorToRemove != null) RemoveFromPalette(colorToRemove.Colour); } 44 | public void RemoveFromPalette(Color colorToRemove) 45 | { 46 | ColourMap.RemoveColour(colorToRemove); 47 | ReplaceColour(colorToRemove, ColourMap.GetNearestColour(colorToRemove)); 48 | } 49 | 50 | public Bitmap FitToControl(System.Windows.Forms.Control ctrl) { return FitToControl(ctrl, InterpolationMode.Invalid); } 51 | /// 52 | /// The idea here is to stop image from stretching. 53 | /// 54 | /// 55 | /// 56 | /// 57 | public Bitmap FitToControl(System.Windows.Forms.Control ctrl, InterpolationMode iMode) 58 | { 59 | float aspectCtrl = (float)ctrl.Width / (float)ctrl.Height; 60 | float aspectImg = (float)OutputImage.Width / (float)OutputImage.Height; 61 | Size newSize = new Size(ctrl.Width, (int)((float)ctrl.Width / aspectImg)); 62 | if (aspectCtrl / aspectImg > 1) 63 | { 64 | newSize = new Size((int)((float)ctrl.Height * aspectImg),ctrl.Height); 65 | } 66 | ResizeImage(newSize,iMode); 67 | return OutputImage; 68 | } 69 | 70 | 71 | public void ResizeImage(Size size) { ResizeImage(size, InterpolationMode.Invalid); } 72 | public void ResizeImage(Size size, InterpolationMode iMode) 73 | { 74 | Bitmap original = OutputImage; 75 | Bitmap b = new Bitmap(size.Width, size.Height, PixelFormat.Format24bppRgb); 76 | Graphics g = Graphics.FromImage((Image)b); 77 | if (iMode != InterpolationMode.Invalid) 78 | { 79 | g.InterpolationMode = iMode; 80 | g.DrawImage(original, 0, 0, size.Width, size.Height); 81 | } 82 | else 83 | { 84 | // If going from low res to high res, I want to keep it pixelated 85 | if (size.Width > original.Width && size.Height > original.Height) 86 | { 87 | float scaleW = (float)size.Width / (float)original.Width; 88 | float scaleH = (float)size.Height / (float)original.Height; 89 | for (int x = 0; x < original.Width; x++) 90 | for (int y = 0; y < original.Height; y++) 91 | { 92 | Color c = original.GetPixel(x, y); 93 | g.FillRectangle(new SolidBrush(c), x * scaleW, y * scaleH, scaleW, scaleH); 94 | } 95 | } 96 | else 97 | { 98 | g.DrawImage(original, 0, 0, size.Width, size.Height); 99 | } 100 | } 101 | g.Dispose(); 102 | 103 | mOutput = b; 104 | } 105 | 106 | /// 107 | /// Resets ColourInfo.Frequency fields to the number of times that colour appears in the image. 108 | /// If Image has N pixels, and ColourMap has M colours, total time = M + Nlog(M) ~= N 109 | /// 110 | public void UpdateColourMapFrequency() 111 | { 112 | if (mOutput == null || ColourMap == null) return; 113 | ColourMap.ClearFrequencies(); // M 114 | Bitmap b = mOutput; 115 | for (int x = 0; x < b.Width; x++) // this loop iterates N times 116 | for (int y = 0; y < b.Height; y++) 117 | { 118 | Color c = b.GetPixel(x, y); 119 | ColourMap.Colours[c].Frequency++; // Dictionary access is log(M)? 120 | } 121 | } 122 | 123 | /// 124 | /// Resets ColourInfo.Frequency fields, and removes colour not present in Colourmap. 125 | /// If Image has N pixels, and ColourMap has M colours, total time = 3M + Nlog(M) ~= N 126 | /// 127 | public void UpdateColourMapFromImage() 128 | { 129 | if (mOutput == null || ColourMap == null) return; 130 | UpdateColourMapFrequency(); 131 | IColourInfo[] temp = ColourMap.ToArray(); 132 | foreach (IColourInfo col in temp) 133 | { 134 | if (col.Frequency < 1 && !col.IsChecked) 135 | { 136 | ColourMap.RemoveColour(col.Colour); 137 | } 138 | } 139 | } 140 | 141 | 142 | /// 143 | /// This is the simplest method - it just truncates to RGB555. 144 | /// if Image has N pixels, total time ~= N. 145 | /// 146 | public void ReduceColourDepth() 147 | { 148 | Bitmap orig = mOutput; 149 | Bitmap b = new Bitmap(orig.Width, orig.Height, PixelFormat.Format24bppRgb); 150 | 151 | for (int x = 0; x < b.Width; x++) 152 | for (int y = 0; y < b.Height; y++) 153 | { 154 | Color c = orig.GetPixel(x, y); 155 | Color newC = Color.FromArgb(c.A & 0xF8, c.R & 0xF8, c.G & 0xF8, c.B & 0xF8); 156 | b.SetPixel(x, y, newC); 157 | } 158 | mOutput = b; 159 | 160 | UpdateColourMapFromImage(); 161 | } 162 | 163 | 164 | public object ReduceColourDepth(object o, BackgroundWorker w, DoWorkEventArgs e) { 165 | Console.WriteLine("Worker thread: " + this + ","+TargetColours+","+ColourMap +","+ColourMap.Count); 166 | // This case we're removing colours one at a time, replacing them with closest colours 167 | if (TargetColours > 0) 168 | { 169 | Console.WriteLine("ReduceColourDepth: initial nColours = " + ColourMap.Count + ", Target: " + TargetColours); 170 | int toRemove = ColourMap.Count - TargetColours; 171 | 172 | for (int i = 0; i < toRemove; i++) 173 | { 174 | if (w.CancellationPending) 175 | { 176 | e.Cancel = true; 177 | return this; 178 | } 179 | IColourInfo least = ColourMap.GetLeastCommonColourInfo(true); 180 | RemoveFromPalette(least); 181 | UpdateColourMapFromImage(); 182 | w.ReportProgress(i * 100 / toRemove); 183 | } 184 | Console.WriteLine("ReduceColourDepth: final number of colours = " + ColourMap.Count); 185 | } 186 | else // This case we have no idea how many colours, we just want to fit the colour map. 187 | { 188 | Bitmap orig = mOutput; 189 | Bitmap b = new Bitmap(orig.Width, orig.Height, PixelFormat.Format24bppRgb); 190 | 191 | Console.WriteLine("ReduceColourDepth: initial nColours = " + ColourMap.Count); 192 | int i = 0; 193 | for (int x = 0; x < b.Width; x++) 194 | for (int y = 0; y < b.Height; y++) 195 | { 196 | if (w.CancellationPending) 197 | { 198 | e.Cancel = true; 199 | return this; 200 | } 201 | Color c = orig.GetPixel(x, y); 202 | Color newC = ColourMap.GetNearestColour(c); 203 | b.SetPixel(x, y, newC); 204 | w.ReportProgress((i++) * 100 / (b.Width*b.Height)); 205 | } 206 | mOutput = b; 207 | } 208 | return this; 209 | } 210 | 211 | /// 212 | /// 213 | /// 214 | /// 215 | /// 216 | public void ReduceColourDepth(int maxColours) 217 | { 218 | if (ColourMap == null) return; 219 | this.TargetColours = maxColours; 220 | UpdateColourMapFromImage(); 221 | int toRemove = ColourMap.Count - TargetColours; 222 | // Don't bother if we're already less than the target or have no ColourMap. 223 | if (toRemove <= 0) return; 224 | 225 | Bitmap saved = new Bitmap(mOutput); 226 | ProgressBarForm prog = new ProgressBarForm("Reducing Colour Depth..."); 227 | prog.StartWorker(ReduceColourDepth, this); 228 | if (prog.DialogResult != System.Windows.Forms.DialogResult.OK) 229 | { 230 | mOutput = saved; 231 | UpdateColourMapFromImage(); 232 | } 233 | 234 | } 235 | 236 | /// 237 | /// Convert colours to fit a given colourmap 238 | /// 239 | /// The colourmap to fit. 240 | public void ReduceColourDepth(IColourMap cmap) 241 | { 242 | ColourMap = cmap; 243 | this.TargetColours = 0; 244 | Bitmap saved = new Bitmap(mOutput); 245 | ProgressBarForm prog = new ProgressBarForm("Fitting Image to Colour Map..."); 246 | prog.CanCancel = false; 247 | prog.StartWorker(ReduceColourDepth, this); 248 | Console.WriteLine("ReduceColourDepth: final number of colours = " + ColourMap.Count); 249 | } 250 | 251 | private Dictionary mPatterns = null; 252 | public void ReplaceColoursWithPatterns(PatternEditor patterns) 253 | { 254 | mPatterns = patterns.GetPatterns(); 255 | Bitmap saved = new Bitmap(mOutput); 256 | ProgressBarForm prog = new ProgressBarForm("Replacing Colours With Patterns..."); 257 | prog.StartWorker(ReplaceColoursWithPatterns, this); 258 | if (prog.DialogResult != System.Windows.Forms.DialogResult.OK) 259 | { 260 | mOutput = saved; 261 | } 262 | } 263 | public object ReplaceColoursWithPatterns(object p, BackgroundWorker w, DoWorkEventArgs e) 264 | { 265 | if (mPatterns == null) { e.Cancel = true; return this; } 266 | int pScale = PatternEditor.PATTERN_WIDTH; 267 | Bitmap orig = mOutput; 268 | Bitmap b = new Bitmap(orig.Width * pScale, orig.Height * pScale, PixelFormat.Format24bppRgb); 269 | 270 | 271 | Graphics g = Graphics.FromImage(b); 272 | //AdriansLib.ProgressBarForm prog = new AdriansLib.ProgressBarForm("Replacing Colours With Patterns...", orig.Width * orig.Height); 273 | //prog.Show(); 274 | int co = 0; 275 | for (int x = 0; x < orig.Width; x++) 276 | for (int y = 0; y < orig.Height; y++) 277 | { 278 | if (w.CancellationPending) { e.Cancel = true; return this; } 279 | Color c = orig.GetPixel(x, y); 280 | Bitmap i = mPatterns[c]; 281 | g.DrawImage(i, x * pScale, y * pScale); 282 | if (x % 5 == 0) 283 | g.DrawLine(Pens.Gray, x * pScale - 1, y * pScale - 1, (x) * pScale - 1, (y + 1) * pScale - 1); 284 | if (y % 5 == 0) 285 | g.DrawLine(Pens.Gray, x * pScale - 1, y * pScale - 1, (x + 1) * pScale - 1, (y) * pScale - 1); 286 | w.ReportProgress((co++) * 100 / (b.Width * b.Height)); 287 | } 288 | g.Dispose(); 289 | mOutput = b; 290 | return this; 291 | } 292 | 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /CrossStitchCreator/PatternEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Drawing.Imaging; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Windows.Forms; 11 | 12 | namespace CrossStitchCreator 13 | { 14 | public partial class PatternEditor : Form 15 | { 16 | public const int PATTERN_WIDTH = 12 + 2; // Nominal size of the icon resources + 1 each side for border 17 | 18 | private int drawing = 0; 19 | private Bitmap mCurrentImage = new Bitmap(PATTERN_WIDTH, PATTERN_WIDTH, PixelFormat.Format16bppRgb555); 20 | 21 | private MainForm mParent; 22 | 23 | private PatternCreator patternCreator = null; 24 | 25 | public ListView ColourList { get { return this.patternList; } } 26 | 27 | 28 | 29 | /// 30 | /// Associates each of the colours in the pattern list with the number of times the colour appears. 31 | /// Will not set if number of entries exceeds MainForm.MAX_COLOURS 32 | /// 33 | public void UpdateColourMap() 34 | { 35 | patternList.Items.Clear(); 36 | if (mParent.ColourMap.Count > MainForm.MAX_COLOURS) 37 | { 38 | MessageBox.Show("Too many colours!"); 39 | return; 40 | } 41 | patternCreator = new PatternCreator(); 42 | List temp = mParent.ColourMap.ToList(); 43 | // loop through ColourMap, adding max frequency first. 44 | while (temp.Count > 0) 45 | { 46 | int max = int.MinValue; 47 | IColourInfo maxC = temp[0]; 48 | foreach (IColourInfo col in temp) 49 | { 50 | if (col.Frequency > max) 51 | { 52 | max = col.Frequency; 53 | maxC = col; 54 | } 55 | } 56 | AddPattern(maxC); 57 | temp.Remove(maxC); 58 | } 59 | patternList.Sort(); 60 | } 61 | 62 | 63 | public PatternEditor(MainForm parent) 64 | { 65 | mParent = parent; 66 | InitializeComponent(); 67 | sortingCombo.DataSource = Enum.GetValues(typeof(PatternListComparer.SortOptions)); 68 | patternList.SmallImageList = new ImageList(); 69 | patternList.SmallImageList.ImageSize = new Size(PATTERN_WIDTH, PATTERN_WIDTH); 70 | patternList.ListViewItemSorter = new PatternListComparer(); 71 | patternCreator = new PatternCreator(); 72 | if (parent.ColourMap != null && parent.ColourMap.Count > 0) 73 | { 74 | //Palette = parent.OutputImagePalette; 75 | patternList.Items[0].Selected = true; 76 | } 77 | } 78 | 79 | public void AddPattern(IColourInfo c) 80 | { 81 | 82 | // find out if Color already exists in list. 83 | foreach (ListViewItem lvi in patternList.Items) 84 | { 85 | if (lvi.BackColor == c.Colour) 86 | { 87 | lvi.Tag = c.Frequency; 88 | return; 89 | } 90 | } 91 | // Colour wasn't in list. Add a new one. 92 | AddPattern(c, CreateNewPattern()); 93 | } 94 | public void AddPattern(IColourInfo c, Bitmap b) 95 | { 96 | // find an index i that is unique in patternList. 97 | int i = 0; 98 | string key = ("" + i).PadLeft(4, '0'); 99 | bool keyFree = false; 100 | while (!keyFree) 101 | { 102 | keyFree = true; 103 | foreach (ListViewItem lvi in patternList.Items) 104 | { 105 | key = ("" + i).PadLeft(4, '0'); 106 | string imageKey = lvi.ImageKey; 107 | 108 | if (key.Equals(imageKey)) 109 | { 110 | keyFree = false; 111 | break; 112 | } 113 | } 114 | i++; 115 | } 116 | AddPattern(c, b, key); 117 | } 118 | 119 | public Dictionary GetPatterns() 120 | { 121 | Dictionary ret = new Dictionary(); 122 | foreach (ListViewItem lvi in patternList.Items) 123 | { 124 | if (!ret.ContainsKey(lvi.BackColor)) 125 | { 126 | int imageIndex = patternList.SmallImageList.Images.IndexOfKey(lvi.ImageKey); 127 | ret.Add(lvi.BackColor, (Bitmap)patternList.SmallImageList.Images[imageIndex]); 128 | } 129 | } 130 | return ret; 131 | } 132 | 133 | public Bitmap GetPattern(Color c) 134 | { 135 | foreach (ListViewItem lvi in patternList.Items) 136 | { 137 | if (lvi.BackColor.Equals(c)) 138 | { 139 | int imageIndex = patternList.SmallImageList.Images.IndexOfKey(lvi.ImageKey); 140 | return (Bitmap)patternList.SmallImageList.Images[imageIndex]; 141 | } 142 | } 143 | return null; 144 | } 145 | 146 | public void AddPattern(IColourInfo c, Bitmap bm, string imageKey) 147 | { 148 | ListViewItem lvi = new ListViewItem(" ",imageKey); 149 | patternList.SmallImageList.Images.Add(imageKey,bm); 150 | Color col = c.Colour; 151 | string r = String.Format("{0:X}", col.R); 152 | string g = String.Format("{0:X}", col.G); 153 | string b = String.Format("{0:X}", col.B); 154 | lvi.ToolTipText = String.Format("Colour: 0x" + r.PadLeft(2, '0') + g.PadLeft(2, '0') + b.PadLeft(2, '0')+ 155 | ", frequency: "+c.Frequency+", imageKey: "+lvi.ImageKey); 156 | lvi.BackColor = col; 157 | 158 | lvi.Tag = c.Frequency; 159 | lvi.SubItems.Add(c.Name); 160 | lvi.SubItems.Add(""+c.Frequency); 161 | if(c is DMCColour) 162 | { 163 | lvi.SubItems.Add("DMC: "+(c as DMCColour).DMCNumber); 164 | } 165 | 166 | lvi.UseItemStyleForSubItems = false; 167 | 168 | patternList.Items.Add(lvi); 169 | } 170 | 171 | private Bitmap CreateNewPattern() 172 | { 173 | return patternCreator.GetNextPattern(); 174 | } 175 | 176 | private void addButton_Click(object sender, EventArgs e) 177 | { 178 | byte b = (byte)(patternList.Items.Count * 30); 179 | //AddPattern(Color.FromArgb(255, b, b, b)); 180 | patternList.Items[patternList.Items.Count - 1].Selected = true; 181 | } 182 | 183 | private void setImage(Bitmap b) 184 | { 185 | ImagingTool tool = new ImagingTool(b); 186 | tool.ResizeImage(pictureBox.Size); 187 | pictureBox.Image = tool.OutputImage; 188 | } 189 | 190 | private void setListItem(int listIndex) 191 | { 192 | if (listIndex >= patternList.Items.Count) return; 193 | ListViewItem lvi = patternList.Items[listIndex]; 194 | int imageIndex = patternList.SmallImageList.Images.IndexOfKey(lvi.ImageKey); 195 | Image img = patternList.SmallImageList.Images[imageIndex]; 196 | mCurrentImage = (Bitmap)img; 197 | setImage((Bitmap)img); 198 | if (colourBox.Image == null) colourBox.Image = new Bitmap(colourBox.Width, colourBox.Height,PixelFormat.Format16bppRgb555); 199 | Bitmap b = (Bitmap)colourBox.Image; 200 | using (Graphics g = Graphics.FromImage(b)) 201 | { 202 | g.FillRectangle(new SolidBrush(lvi.BackColor), 0, 0, 100, 100); 203 | } 204 | Refresh(); 205 | } 206 | 207 | #region PictureBoxMouseEvents 208 | 209 | 210 | private void pictureBox_MouseDown(object sender, MouseEventArgs e) 211 | { 212 | if (e.Button == System.Windows.Forms.MouseButtons.Left) 213 | drawing = 1; 214 | else if (e.Button == System.Windows.Forms.MouseButtons.Right) 215 | drawing = 2; 216 | } 217 | 218 | private void pictureBox_MouseMove(object sender, MouseEventArgs e) 219 | { 220 | if (drawing > 0) 221 | { 222 | int x = (int)((float)e.X * (float)PATTERN_WIDTH / (float)pictureBox.Width); 223 | int y = (int)((float)e.Y * (float)PATTERN_WIDTH / (float)pictureBox.Height); 224 | if (x >= 0 && x < PATTERN_WIDTH && y >= 0 && y < PATTERN_WIDTH) 225 | { 226 | if (drawing == 1) mCurrentImage.SetPixel(x, y, Color.Black); 227 | else if (drawing == 2) mCurrentImage.SetPixel(x, y, Color.White); 228 | setImage(mCurrentImage); 229 | } 230 | } 231 | } 232 | 233 | private void pictureBox_MouseUp(object sender, MouseEventArgs e) 234 | { 235 | if (drawing > 0) 236 | { 237 | int x = (int)((float)e.X * (float)PATTERN_WIDTH / (float)pictureBox.Width); 238 | int y = (int)((float)e.Y * (float)PATTERN_WIDTH / (float)pictureBox.Height); 239 | if (x >= 0 && x < PATTERN_WIDTH && y >= 0 && y < PATTERN_WIDTH) 240 | { 241 | if (drawing == 1) mCurrentImage.SetPixel(x, y, Color.Black); 242 | else if (drawing == 2) mCurrentImage.SetPixel(x, y, Color.White); 243 | setImage(mCurrentImage); 244 | } 245 | } 246 | drawing = 0; 247 | } 248 | 249 | private void pictureBox_MouseLeave(object sender, EventArgs e) 250 | { 251 | drawing = 0; 252 | } 253 | #endregion 254 | 255 | private void updateButton_Click(object sender, EventArgs e) 256 | { 257 | if (patternList.SelectedIndices.Count > 0) 258 | { 259 | ListViewItem lvi = patternList.Items[patternList.SelectedIndices[0]]; 260 | int imageIndex = patternList.SmallImageList.Images.IndexOfKey(lvi.ImageKey); 261 | patternList.SmallImageList.Images[imageIndex] = new Bitmap(mCurrentImage); 262 | Bitmap b = (Bitmap)colourBox.Image; 263 | lvi.BackColor = b.GetPixel(0, 0); 264 | Refresh(); 265 | } 266 | } 267 | 268 | private void patternList_SelectedIndexChanged(object sender, EventArgs e) 269 | { 270 | if (patternList.SelectedItems.Count > 0) 271 | { 272 | setListItem(patternList.SelectedIndices[0]); 273 | } 274 | } 275 | 276 | private void sortingCombo_DropDownClosed(object sender, EventArgs e) 277 | { 278 | patternList.ListViewItemSorter = new PatternListComparer((PatternListComparer.SortOptions)sortingCombo.SelectedItem); 279 | patternList.Sort(); 280 | } 281 | 282 | } 283 | 284 | class PatternListComparer : IComparer 285 | { 286 | public enum SortOptions { ByTagAscending, ByTagDescending, ByIndexAscending, ByIndexDescending, ByImageKeyAscending, ByImageKeyDescending }; 287 | 288 | public SortOptions SortOption { get; set; } 289 | 290 | public PatternListComparer() : this(SortOptions.ByTagDescending) { } 291 | public PatternListComparer(SortOptions s) { SortOption = s; } 292 | 293 | public int Compare(object x, object y) 294 | { 295 | if (x == null) return 1; 296 | if (y == null) return -1; 297 | if (x.GetType() != typeof(ListViewItem)) return 1; 298 | if(y.GetType() != typeof(ListViewItem)) return -1; 299 | ListViewItem lx = (ListViewItem)x; 300 | ListViewItem ly = (ListViewItem)y; 301 | 302 | if (SortOption == SortOptions.ByTagAscending) 303 | { 304 | int fx = (int)lx.Tag; 305 | int fy = (int)ly.Tag; 306 | return fx.CompareTo(fy); 307 | } 308 | else if (SortOption == SortOptions.ByTagDescending) 309 | { 310 | int fx = (int)lx.Tag; 311 | int fy = (int)ly.Tag; 312 | return fy.CompareTo(fx); 313 | } 314 | else if (SortOption == SortOptions.ByIndexAscending) 315 | { 316 | return lx.Index.CompareTo(ly.Index); 317 | } 318 | else if (SortOption == SortOptions.ByIndexDescending) 319 | { 320 | return ly.Index.CompareTo(lx.Index); 321 | } 322 | else if (SortOption == SortOptions.ByImageKeyAscending) 323 | { 324 | return lx.ImageKey.CompareTo(ly.ImageKey); 325 | } 326 | else if (SortOption == SortOptions.ByImageKeyDescending) 327 | { 328 | return ly.ImageKey.CompareTo(lx.ImageKey); 329 | } 330 | return 0; 331 | } 332 | } 333 | } 334 | -------------------------------------------------------------------------------- /CrossStitchCreator/Resources/DMC Cotton Floss converted to RGB Values.csv: -------------------------------------------------------------------------------- 1 | Floss#,Description,Red,Green,Blue,RGB code,Row 2 | 3713,Salmon Very Light,255,226,226,FFE2E2,row 01-01 3 | 761,Salmon Light,255,201,201,FFC9C9,row 01-02 4 | 760,Salmon,245,173,173,F5ADAD,row 01-03 5 | 3712,Salmon Medium,241,135,135,F18787,row 01-04 6 | 3328,Salmon Dark,227,109,109,E36D6D,row 01-05 7 | 347,Salmon Very Dark,191,45,45,BF2D2D,row 01-06 8 | 353,Peach,254,215,204,FED7CC,row 01-07 9 | 352,Coral Light,253,156,151,FD9C97,row 01-08 10 | 351,Coral,233,106,103,E96A67,row 01-09 11 | 350,Coral Medium,224,72,72,E04848,row 01-10 12 | 349,Coral Dark,210,16,53,D21035,row 01-11 13 | 817,Coral Red Very Dark,187,5,31,BB051F,row 01-12 14 | 3708,Melon Light,255,203,213,FFCBD5,row 01-13 15 | 3706,Melon Medium,255,173,188,FFADBC,row 01-14 16 | 3705,Melon Dark,255,121,146,FF7992,row 01-15 17 | 3801,Melon Very Dark,231,73,103,E74967,row 01-16 18 | 666,Bright Red,227,29,66,E31D42,row 01-17 19 | 321,Red,199,43,59,C72B3B,row 01-18 20 | 304,Red Medium,183,31,51,B71F33,row 01-19 21 | 498,Red Dark,167,19,43,A7132B,row 01-20 22 | 816,Garnet,151,11,35,970B23,row 01-21 23 | 815,Garnet Medium,135,7,31,87071F,row 01-22 24 | 814,Garnet Dark,123,0,27,7B001B,row 01-23 25 | 894,Carnation Very Light,255,178,187,FFB2BB,row 02-01 26 | 893,Carnation Light,252,144,162,FC90A2,row 02-02 27 | 892,Carnation Medium,255,121,140,FF798C,row 02-03 28 | 891,Carnation Dark,255,87,115,FF5773,row 02-04 29 | 818,Baby Pink,255,223,217,FFDFD9,row 02-05 30 | 957,Geranium Pale,253,181,181,FDB5B5,row 02-06 31 | 956,Geranium,255,145,145,FF9191,row 02-07 32 | 309,Rose Dark,86,74,74,BA4A4A,row 02-08 33 | 963,Dusty Rose Ult Vy Lt,255,215,215,FFD7D7,row 02-09 34 | 3716,Dusty Rose Med Vy Lt,255,189,189,FFBDBD,row 02-10 35 | 962,Dusty Rose Medium,230,138,138,E68A8A,row 02-11 36 | 961,Dusty Rose Dark,207,115,115,CF7373,row 02-12 37 | 3833,Raspberry Light,234,134,153,EA8699,row 02-13 38 | 3832,Raspberry Medium,219,85,110,DB556E,row 02-14 39 | 3831,Raspberry Dark,179,47,72,B32F48,row 02-15 40 | 777,Raspberry Very Dark,145,53,70,913546,row 02-16 41 | 819,Baby Pink Light,255,238,235,FFEEEB,row 02-17 42 | 3326,Rose Light,251,173,180,FBADB4,row 02-18 43 | 776,Pink Medium,252,176,185,FCB0B9,row 02-19 44 | 899,Rose Medium,242,118,136,F27688,row 02-20 45 | 335,Rose,238,84,110,EE546E,row 02-21 46 | 326,Rose Very Dark,179,59,75,B33B4B,row 02-22 47 | 151,Dusty Rose Vry Lt,240,206,212,F0CED4,row 03-01 48 | 3354,Dusty Rose Light,228,166,172,E4A6AC,row 03-02 49 | 3733,Dusty Rose,232,135,155,E8879B,row 03-03 50 | 3731,Dusty Rose Very Dark,218,103,131,DA6783,row 03-04 51 | 3350,Dusty Rose Ultra Dark,188,67,101,BC4365,row 03-05 52 | 150,Dusty Rose Ult Vy Dk,171,2,73,AB0249,row 03-06 53 | 3689,Mauve Light,251,191,194,FBBFC2,row 03-07 54 | 3688,Mauve Medium,231,169,172,E7A9AC,row 03-08 55 | 3687,Mauve,201,107,112,C96B70,row 03-09 56 | 3803,Mauve Dark,171,51,87,AB3357,row 03-10 57 | 3685,Mauve Very Dark,136,21,49,881531,row 03-11 58 | 605,Cranberry Very Light,255,192,205,FFC0CD,row 03-12 59 | 604,Cranberry Light,255,176,190,FFB0BE,row 03-13 60 | 603,Cranberry,255,164,190,FFA4BE,row 03-14 61 | 602,Cranberry Medium,226,72,116,E24874,row 03-15 62 | 601,Cranberry Dark,209,40,106,D1286A,row 03-16 63 | 600,Cranberry Very Dark,205,47,99,CD2F63,row 03-17 64 | 3806,Cyclamen Pink Light,255,140,174,FF8CAE,row 03-18 65 | 3805,Cyclamen Pink,243,71,139,F3478B,row 03-19 66 | 3804,Cyclamen Pink Dark,224,40,118,E02876,row 03-20 67 | 3609,Plum Ultra Light,244,174,213,F4AED7,row 03-21 68 | 3608,Plum Very Light,234,156,196,EA9CC4,row 03-22 69 | 3607,Plum Light,197,73,137,C54989,row 03-23 70 | 718,Plum,156,36,98,9C2462,row 03-24 71 | 917,Plum Medium,155,19,89,9B1359,row 03-25 72 | 915,Plum Dark,130,0,67,820043,row 03-26 73 | 225,Shell Pink Ult Vy Lt,255,223,213,FFDFD7,row 04-01 74 | 224,Shell Pink Very Light,235,183,175,EBB7AF,row 04-02 75 | 152,Shell Pink Med Light,226,160,153,E2A099,row 04-03 76 | 223,Shell Pink Light,204,132,124,CC847C,row 04-04 77 | 3722,Shell Pink Med,188,108,100,BC6C64,row 04-05 78 | 3721,Shell Pink Dark,161,75,81,A14B51,row 04-06 79 | 221,Shell Pink Vy Dk,136,62,67,8.83E+45,row 04-07 80 | 778,Antique Mauve Vy Lt,223,179,187,DFB3BB,row 04-08 81 | 3727,Antique Mauve Light,219,169,178,DBA9B2,row 04-09 82 | 316,Antique Mauve Med,183,115,127,B7737F,row 04-10 83 | 3726,Antique Mauve Dark,155,91,102,9B5B66,row 04-11 84 | 315,Antique Mauve Md Dk,129,73,82,814952,row 04-12 85 | 3802,Antique Mauve Vy Dk,113,65,73,714149,row 04-13 86 | 902,Garnet Very Dark,130,38,55,822637,row 04-14 87 | 3743,Antique Violet Vy Lt,215,203,211,D7CBD3,row 04-15 88 | 3042,Antique Violet Light,183,157,167,B79DA7,row 04-16 89 | 3041,Antique Violet Medium,149,111,124,956F7C,row 04-17 90 | 3740,Antique Violet Dark,120,87,98,785762,row 04-18 91 | 3836,Grape Light,186,145,170,BA91AA,row 04-19 92 | 3835,Grape Medium,148,96,131,946083,row 04-20 93 | 3834,Grape Dark,114,55,93,72375D,row 04-21 94 | 154,Grape Very Dark,87,36,51,572433,row 04-22 95 | 211,Lavender Light,227,203,227,E3CBE3,row 05-01 96 | 210,Lavender Medium,195,159,195,D29FC3,row 05-02 97 | 209,Lavender Dark,163,123,167,A37BA7,row 05-03 98 | 208,Lavender Very Dark,131,91,139,835B8B,row 05-04 99 | 3837,Lavender Ultra Dark,108,58,110,6C3A6E,row 05-05 100 | 327,Violet Dark,99,54,102,633666,row 05-06 101 | 153,Violet Very Light,230,204,217,E6CCD9,row 05-07 102 | 554,Violet Light,219,179,203,DBB3CB,row 05-08 103 | 553,Violet,163,99,139,A3638B,row 05-09 104 | 552,Violet Medium,128,58,107,803A6B,row 05-10 105 | 550,Violet Very Dark,92,24,78,5C184E,row 05-11 106 | 3747,Blue Violet Vy Lt,211,215,237,D3D7ED,row 05-12 107 | 341,Blue Violet Light,183,191,221,B7BFDD,row 05-13 108 | 156,Blue Violet Med Lt,163,174,209,A3AED1,row 05-14 109 | 340,Blue Violet Medium,173,167,199,ADA7C7,row 05-15 110 | 155,Blue Violet Med Dark,152,145,182,9891B6,row 05-16 111 | 3746,Blue Violet Dark,119,107,152,776B98,row 05-17 112 | 333,Blue Violet Very Dark,92,84,120,5C5478,row 05-18 113 | 157,Cornflower Blue Vy Lt,187,195,217,BBC3D9,row 05-19 114 | 794,Cornflower Blue Light,143,156,193,8F9CC1,row 05-20 115 | 793,Cornflower Blue Med,112,125,162,707DA2,row 05-21 116 | 3807,Cornflower Blue,96,103,140,60678C,row 05-22 117 | 792,Cornflower Blue Dark,85,91,123,555B7B,row 05-23 118 | 158,Cornflower Blu M V D,76,82,110,4C526E,row 05-24 119 | 791,Cornflower Blue V D,70,69,99,464563,row 05-25 120 | 3840,Lavender Blue Light,176,192,218,B0C0DA,row 06-01 121 | 3839,Lavender Blue Med,123,142,171,7B8EAB,row 06-02 122 | 3838,Lavender Blue Dark,92,114,148,5C7294,row 06-03 123 | 800,Delft Blue Pale,192,204,222,C0CCDE,row 06-04 124 | 809,Delft Blue,148,168,198,94A8C6,row 06-05 125 | 799,Delft Blue Medium,116,142,182,748EB6,row 06-06 126 | 798,Delft Blue Dark,70,106,142,466A8E,row 06-07 127 | 797,Royal Blue,19,71,125,13477D,row 06-08 128 | 796,Royal Blue Dark,17,65,109,11416D,row 06-09 129 | 820,Royal Blue Very Dark,14,54,92,0E365C,row 06-10 130 | 162,Blue Ultra Very Light,219,236,245,DBECF5,row 06-11 131 | 827,Blue Very Light,189,221,237,BDDDED,row 06-12 132 | 813,Blue Light,161,194,215,A1C2D7,row 06-13 133 | 826,Blue Medium,107,158,191,6B9EBF,row 06-14 134 | 825,Blue Dark,71,129,165,4781A5,row 06-15 135 | 824,Blue Very Dark,57,105,135,396987,row 06-16 136 | 996,Electric Blue Medium,48,194,236,30C2EC,row 06-17 137 | 3843,Electric Blue,20,170,208,14AAD0,row 06-18 138 | 995,Electric Blue Dark,38,150,182,2696B6,row 06-19 139 | 3846,Turquoise Bright Light,6,227,230,06E3E6,row 06-20 140 | 3845,Turquoise Bright Med,4,196,202,04C4CA,row 06-21 141 | 3844,Turquoise Bright Dark,18,174,186,12AEBA,row 06-22 142 | 159,Blue Gray Light,199,202,215,C7CAD7,row 07-01 143 | 160,Blue Gray Medium,153,159,183,999FB7,row 07-02 144 | 161,Blue Gray,120,128,164,7880A4,row 07-03 145 | 3756,Baby Blue Ult Vy Lt,238,252,252,EEFCFC,row 07-04 146 | 775,Baby Blue Very Light,217,235,241,D9EBF1,row 07-05 147 | 3841,Baby Blue Pale,205,223,237,CDDFED,row 07-06 148 | 3325,Baby Blue Light,184,210,230,B8D2E6,row 07-07 149 | 3755,Baby Blue,147,180,206,92B4CE,row 07-08 150 | 334,Baby Blue Medium,115,159,193,739FC1,row 07-09 151 | 322,Baby Blue Dark,90,143,184,5A8FB8,row 07-10 152 | 312,Baby Blue Very Dark,53,102,139,35668B,row 07-11 153 | 803,Baby Blue Ult Vy Dk,44,89,124,2C597C,row 07-12 154 | 336,Navy Blue,37,59,115,253B73,row 07-13 155 | 823,Navy Blue Dark,33,48,99,213063,row 07-14 156 | 939,Navy Blue Very Dark,27,40,83,1B2853,row 07-15 157 | 3753,Antique Blue Ult Vy Lt,219,226,233,DBE2E9,row 07-16 158 | 3752,Antique Blue Very Lt,199,209,219,C7D1DB,row 07-17 159 | 932,Antique Blue Light,162,181,198,A2B5C6,row 07-18 160 | 931,Antique Blue Medium,106,133,158,6A859E,row 07-19 161 | 930,Antique Blue Dark,69,92,113,455C71,row 07-20 162 | 3750,Antique Blue Very Dk,56,76,94,384C5E,row 07-21 163 | 828,Sky Blue Vy Lt,197,232,237,C5E8ED,row 08-01 164 | 3761,Sky Blue Light,172,216,226,ACD8E2,row 08-02 165 | 519,Sky Blue,126,177,200,7EB1C8,row 08-03 166 | 518,Wedgewood Light,79,147,167,4F93A7,row 08-04 167 | 3760,Wedgewood Med,62,133,162,3E85A2,row 08-05 168 | 517,Wedgewood Dark,59,118,143,3B768F,row 08-06 169 | 3842,Wedgewood Vry Dk,50,102,124,32667C,row 08-07 170 | 311,Wedgewood Ult VyDk,28,80,102,1C5066,row 08-08 171 | 747,Peacock Blue Vy Lt,229,252,253,E5FCFD,row 08-09 172 | 3766,Peacock Blue Light,153,207,217,99CFD9,row 08-10 173 | 807,Peacock Blue,100,171,186,64ABBA,row 08-11 174 | 806,Peacock Blue Dark,61,149,165,3D95A5,row 08-12 175 | 3765,Peacock Blue Vy Dk,52,127,140,347F8C,row 08-13 176 | 3811,Turquoise Very Light,188,227,230,BCE3E6,row 08-14 177 | 598,Turquoise Light,144,195,204,90C3CC,row 08-15 178 | 597,Turquoise,91,163,179,5BA3B3,row 08-16 179 | 3810,Turquoise Dark,72,142,154,488E9A,row 08-17 180 | 3809,Turquoise Vy Dark,63,124,133,3F7C85,row 08-18 181 | 3808,Turquoise Ult Vy Dk,54,105,112,366970,row 08-19 182 | 928,Gray Green Vy Lt,221,227,227,DDE3E3,row 08-20 183 | 927,Gray Green Light,189,203,203,BDCBCB,row 08-21 184 | 926,Gray Green Med,152,174,174,98AEAE,row 08-22 185 | 3768,Gray Green Dark,101,127,127,657F7F,row 08-23 186 | 924,Gray Green Vy Dark,86,106,106,566A6A,row 08-24 187 | 3849,Teal Green Light,82,179,164,52B3AE,row 08-25 188 | 3848,Teal Green Med,85,147,146,419392,row 08-26 189 | 3847,Teal Green Dark,52,125,117,347D75,row 08-27 190 | 964,Sea Green Light,169,226,216,A9E2D8,row 09-01 191 | 959,Sea Green Med,89,199,180,59C7B4,row 09-02 192 | 958,Sea Green Dark,62,182,161,3EB6A1,row 09-03 193 | 3812,Sea Green Vy Dk,47,140,132,2F8C84,row 09-04 194 | 3851,Green Bright Lt,73,179,161,49B3A1,row 09-05 195 | 943,Green Bright Md,61,147,132,3D9384,row 09-06 196 | 3850,Green Bright Dk,55,132,119,378477,row 09-07 197 | 993,Aquamarine Vy Lt,144,192,180,90C0B4,row 09-08 198 | 992,Aquamarine Lt,111,174,159,6FAE9F,row 09-09 199 | 3814,Aquamarine,80,139,125,508B7D,row 09-10 200 | 991,Aquamarine Dk,71,123,110,477B6E,row 09-11 201 | 966,Jade Ultra Vy Lt,185,215,192,B9D7C0,row 09-12 202 | 564,Jade Very Light,167,205,175,A7CDAF,row 09-13 203 | 563,Jade Light,143,192,152,8FC098,row 09-14 204 | 562,Jade Medium,83,151,106,53976A,row 09-15 205 | 505,Jade Green,51,131,98,338362,row 09-16 206 | 3817,Celadon Green Lt,153,195,170,99C3AA,row 09-17 207 | 3816,Celadon Green,101,165,125,65A57D,row 09-18 208 | 163,Celadon Green Md,77,131,97,4D8361,row 09-19 209 | 3815,Celadon Green Dk,71,119,89,477759,row 09-20 210 | 561,Celadon Green VD,44,106,69,2C6A45,row 09-21 211 | 504,Blue Green Vy Lt,196,222,204,C4DECC,row 09-22 212 | 3813,Blue Green Lt,178,212,189,B2D4BD,row 09-23 213 | 503,Blue Green Med,123,172,148,7BAC94,row 09-24 214 | 502,Blue Green,91,144,113,5B9071,row 09-25 215 | 501,Blue Green Dark,57,111,82,396F52,row 09-26 216 | 500,Blue Green Vy Dk,4,77,51,044D33,row 09-27 217 | 955,Nile Green Light,162,214,173,A2D6AD,row 10-01 218 | 954,Nile Green,136,186,145,88BA91,row 10-02 219 | 913,Nile Green Med,109,171,119,6DAB77,row 10-03 220 | 912,Emerald Green Lt,27,157,107,1B9D6B,row 10-04 221 | 911,Emerald Green Med,24,144,101,189065,row 10-05 222 | 910,Emerald Green Dark,24,126,86,1.87E+58,row 10-06 223 | 909,Emerald Green Vy Dk,21,111,73,156F49,row 10-07 224 | 3818,Emerald Grn Ult V Dk,17,90,59,115A3B,row 10-08 225 | 369,Pistachio Green Vy Lt,215,237,204,D7EDCC,row 10-09 226 | 368,Pistachio Green Lt,166,194,152,A6C298,row 10-10 227 | 320,Pistachio Green Med,105,136,90,69885A,row 10-11 228 | 367,Pistachio Green Dk,97,122,82,617A52,row 10-12 229 | 319,Pistachio Grn Vy Dk,32,95,46,205F2E,row 10-13 230 | 890,Pistachio Grn Ult V D,23,73,35,184923,row 10-14 231 | 164,Forest Green Lt,200,216,184,C8D8B8,row 10-15 232 | 989,Forest Green ,141,166,117,8DA675,row 10-16 233 | 988,Forest Green Med,115,139,91,738B5B,row 10-17 234 | 987,Forest Green Dk,88,113,65,587141,row 10-18 235 | 986,Forest Green Vy Dk,64,82,48,405230,row 10-19 236 | 772,Yellow Green Vy Lt,228,236,212,E4ECD4,row 10-20 237 | 3348,Yellow Green Lt,204,217,177,CCD9B1,row 10-21 238 | 3347,Yellow Green Med,113,147,92,71935C,row 10-22 239 | 3346,Hunter Green,64,106,58,406A3A,row 10-23 240 | 3345,Hunter Green Dk,27,89,21,1B5915,row 10-24 241 | 895,Hunter Green Vy Dk,27,83,0,1B5300,row 10-25 242 | 704,Chartreuse Bright,158,207,52,9ECF34,row 11-01 243 | 703,Chartreuse,123,181,71,7BB547,row 11-02 244 | 702,Kelly Green,71,167,47,47A72F,row 11-03 245 | 701,Green Light,63,143,41,3F8F29,row 11-04 246 | 700,Green Bright,7,115,27,07731B,row 11-05 247 | 699,Green,5,101,23,56517,row 11-06 248 | 907,Parrot Green Lt,199,230,102,C7E666,row 11-07 249 | 906,Parrot Green Md,127,179,53,7FB335,row 11-08 250 | 905,Parrot Green Dk,98,138,40,628A28,row 11-09 251 | 904,Parrot Green V Dk,85,120,34,557822,row 11-10 252 | 472,Avocado Grn U Lt,216,228,152,D8E498,row 11-11 253 | 471,Avocado Grn V Lt,174,191,121,AEBF79,row 11-12 254 | 470,Avocado Grn Lt,148,171,79,94AB4F,row 11-13 255 | 469,Avocado Green,114,132,60,72843C,row 11-14 256 | 937,Avocado Green Md,98,113,51,627133,row 11-15 257 | 936,Avocado Grn V Dk,76,88,38,4C5826,row 11-16 258 | 935,Avocado Green Dk,66,77,33,424D21,row 11-17 259 | 934,Avocado Grn Black,49,57,25,313919,row 11-18 260 | 523,Fern Green Lt,171,177,151,ABB197,row 11-19 261 | 3053,Green Gray,156,164,130,9CA482,row 11-20 262 | 3052,Green Gray Md,136,146,104,889268,row 11-21 263 | 3051,Green Gray Dk,95,102,72,5F6648,row 11-22 264 | 524,Fern Green Vy Lt,196,205,172,C4CDAC,row 11-23 265 | 522,Fern Green,150,158,126,969E7E,row 11-24 266 | 520,Fern Green Dark,102,109,79,666D4F,row 11-25 267 | 3364,Pine Green,131,151,95,83975F,row 12-01 268 | 3363,Pine Green Md,114,130,86,728256,row 12-02 269 | 3362,Pine Green Dk,94,107,71,5E6B47,row 12-03 270 | 165,Moss Green Vy Lt,239,244,164,EFF4A4,row 12-04 271 | 3819,Moss Green Lt,224,232,104,E0E868,row 12-05 272 | 166,Moss Green Md Lt,192,200,64,C0C840,row 12-06 273 | 581,Moss Green,167,174,56,A7AE38,row 12-07 274 | 580,Moss Green Dk,136,141,51,888D33,row 12-08 275 | 734,Olive Green Lt,199,192,119,C7C077,row 12-09 276 | 733,Olive Green Md,188,179,76,BCB34C,row 12-10 277 | 732,Olive Green,148,140,54,948C36,row 12-11 278 | 731,Olive Green Dk,147,139,55,938B37,row 12-12 279 | 730,Olive Green V Dk,130,123,48,827B30,row 12-13 280 | 3013,Khaki Green Lt,185,185,130,B9B982,row 12-14 281 | 3012,Khaki Green Md,166,167,93,A6A75D,row 12-15 282 | 3011,Khaki Green Dk,137,138,88,898A58,row 12-16 283 | 372,Mustard Lt,204,183,132,CCB784,row 12-17 284 | 371,Mustard,191,166,113,BFA671,row 12-18 285 | 370,Mustard Medium,184,157,100,B89D64,row 12-19 286 | 834,Golden Olive Vy Lt,219,190,127,DBBE7F,row 12-20 287 | 833,Golden Olive Lt,200,171,108,C8AB6C,row 12-21 288 | 832,Golden Olive,189,155,81,BD9B51,row 12-22 289 | 831,Golden Olive Md,170,143,86,AA8F56,row 12-23 290 | 830,Golden Olive Dk,141,120,75,8D784B,row 12-24 291 | 829,Golden Olive Vy Dk,126,107,66,7E6B42,row 12-25 292 | 613,Drab Brown V Lt,220,196,170,DCC4AA,row 13-01 293 | 612,Drab Brown Lt,188,154,120,BC9A78,row 13-02 294 | 611,Drab Brown,150,118,86,967656,row 13-03 295 | 610,Drab Brown Dk,121,96,71,796047,row 13-04 296 | 3047,Yellow Beige Lt,231,214,193,E7D6C1,row 13-05 297 | 3046,Yellow Beige Md,216,188,154,D8BC9A,row 13-06 298 | 3045,Yellow Beige Dk,188,150,106,BC966A,row 13-07 299 | 167,Yellow Beige V Dk,167,124,73,A77C49,row 13-08 300 | 746,Off White,252,252,238,FCFCEE,row 13-09 301 | 677,Old Gold Vy Lt,245,236,203,F5ECCB,row 13-10 302 | 422,Hazelnut Brown Lt,198,159,123,C69F7B,row 13-11 303 | 3828,Hazelnut Brown,183,139,97,B78B61,row 13-12 304 | 420,Hazelnut Brown Dk,160,112,66,A07042,row 13-13 305 | 869,Hazelnut Brown V Dk,131,94,57,8.35E+41,row 13-14 306 | 728,Topaz,228,180,104,E4B468,row 13-15 307 | 783,Topaz Medium,206,145,36,CE9124,row 13-16 308 | 782,Topaz Dark,174,119,32,AE7720,row 13-17 309 | 781,Topaz Very Dark,162,109,32,A26D20,row 13-18 310 | 780,Topaz Ultra Vy Dk,148,99,26,94631A,row 13-19 311 | 676,Old Gold Lt,229,206,151,E5CE97,row 13-20 312 | 729,Old Gold Medium,208,165,62,D0A53E,row 13-21 313 | 680,Old Gold Dark,188,141,14,BC8D0E,row 13-22 314 | 3829,Old Gold Vy Dark,169,130,4,A98204,row 13-23 315 | 3822,Straw Light,246,220,152,F6DC98,row 13-24 316 | 3821,Straw,243,206,117,F3CE75,row 13-25 317 | 3820,Straw Dark,223,182,95,DFB65F,row 13-26 318 | 3852,Straw Very Dark,205,157,55,CD9D37,row 13-27 319 | 445,Lemon Light,255,251,139,FFFB8B,row 14-01 320 | 307,Lemon,253,237,84,FDED54,row 14-02 321 | 973,Canary Bright,255,227,0,FFE300,row 14-03 322 | 444,Lemon Dark,255,214,0,FFD600,row 14-04 323 | 3078,Golden Yellow Vy Lt,253,249,205,FDF9CD,row 14-05 324 | 727,Topaz Vy Lt,255,241,175,FFF1AF,row 14-06 325 | 726,Topaz Light,253,215,85,FDD755,row 14-07 326 | 725,Topaz Med Lt,255,200,64,FFC840,row 14-08 327 | 972,Canary Deep,255,181,21,FFB515,row 14-09 328 | 745,Yellow Pale Light,255,233,173,FFE9AD,row 14-10 329 | 744,Yellow Pale,255,231,147,FFE793,row 14-11 330 | 743,Yellow Med,254,211,118,FED376,row 14-12 331 | 742,Tangerine Light,255,191,87,FFBF57,row 14-13 332 | 741,Tangerine Med,255,163,43,FFA32B,row 14-14 333 | 740,Tangerine,255,139,0,FF8B00,row 14-15 334 | 970,Pumpkin Light,247,139,19,F78B13,row 14-16 335 | 971,Pumpkin,246,127,0,F67F00,row 14-17 336 | 947,Burnt Orange,255,123,77,FF7B4D,row 14-18 337 | 946,Burnt Orange Med,235,99,7,EB6307,row 14-19 338 | 900,Burnt Orange Dark,209,88,7,D15807,row 14-20 339 | 967,Apricot Very Light,255,222,213,FFDED5,row 14-21 340 | 3824,Apricot Light,254,205,194,FECDC2,row 14-22 341 | 3341,Apricot,252,171,152,FCAB98,row 14-23 342 | 3340,Apricot Med,255,131,111,FF836F,row 14-24 343 | 608,Burnt Orange Bright,253,93,53,FD5D35,row 14-25 344 | 606,Orange?Red Bright,250,50,3,FA3203,row 14-26 345 | 951,Tawny Light,255,226,207,FFE2CF,row 15-01 346 | 3856,Mahogany Ult Vy Lt,255,211,181,FFD3B5,row 15-02 347 | 722,Orange Spice Light,247,151,111,F7976F,row 15-03 348 | 721,Orange Spice Med,242,120,66,F27842,row 15-04 349 | 720,Orange Spice Dark,229,92,31,E55C1F,row 15-05 350 | 3825,Pumpkin Pale,253,189,150,FDBD96,row 15-06 351 | 922,Copper Light,226,115,35,E27323,row 15-07 352 | 921,Copper,198,98,24,C66218,row 15-08 353 | 920,Copper Med,172,84,20,AC5414,row 15-09 354 | 919,Red?Copper,166,69,16,A64510,row 15-10 355 | 918,Red?Copper Dark,130,52,10,82340A,row 15-11 356 | 3770,Tawny Vy Light,255,238,227,FFEEE3,row 15-12 357 | 945,Tawny,251,213,187,FBD5BB,row 15-13 358 | 402,Mahogany Vy Lt,247,167,119,F7A777,row 15-14 359 | 3776,Mahogany Light,207,121,57,CF7939,row 15-15 360 | 301,Mahogany Med,179,95,43,B35F2B,row 15-16 361 | 400,Mahogany Dark,143,67,15,8F430F,row 15-17 362 | 300,Mahogany Vy Dk,111,47,0,6F2F00,row 15-18 363 | 3823,Yellow Ultra Pale,255,253,227,FFFDE3,row 15-19 364 | 3855,Autumn Gold Lt,250,211,150,FAD396,row 15-20 365 | 3854,Autumn Gold Med,242,175,104,F2AF68,row 15-21 366 | 3853,Autumn Gold Dk,242,151,70,F29746,row 15-22 367 | 3827,Golden Brown Pale,247,187,119,F7BB77,row 16-01 368 | 977,Golden Brown Light,220,156,86,DC9C56,row 16-02 369 | 976,Golden Brown Med,194,129,66,C28142,row 16-03 370 | 3826,Golden Brown,173,114,57,AD7239,row 16-04 371 | 975,Golden Brown Dk,145,79,18,914F12,row 16-05 372 | 948,Peach Very Light,254,231,218,FEE7DA,row 16-06 373 | 754,Peach Light,247,203,191,F7CBBF,row 16-07 374 | 3771,Terra Cotta Ult Vy Lt,244,187,169,F4BBA9,row 16-08 375 | 758,Terra Cotta Vy Lt,238,170,155,EEAA9B,row 16-09 376 | 3778,Terra Cotta Light,217,137,120,D98978,row 16-10 377 | 356,Terra Cotta Med,197,106,91,C56A5B,row 16-11 378 | 3830,Terra Cotta,185,85,68,BC5544,row 16-12 379 | 355,Terra Cotta Dark,152,68,54,984436,row 16-13 380 | 3777,Terra Cotta Vy Dk,134,48,34,863022,row 16-14 381 | 3779,Rosewood Ult Vy Lt,248,202,200,F8CAC8,row 16-15 382 | 3859,Rosewood Light,186,139,124,BA8B7C,row 16-16 383 | 3858,Rosewood Med,150,74,63,964A3F,row 16-17 384 | 3857,Rosewood Dark,104,37,26,68251A,row 16-18 385 | 3774,Desert Sand Vy Lt,243,225,215,F3E1D7,row 16-19 386 | 950,Desert Sand Light,238,211,196,EED3C4,row 16-20 387 | 3064,Desert Sand,196,142,112,C48E70,row 16-21 388 | 407,Desert Sand Med,187,129,97,BB8161,row 16-22 389 | 3773,Desert Sand Dark,182,117,82,B67552,row 16-23 390 | 3772,Desert Sand Vy Dk,160,108,80,A06C50,row 16-24 391 | 632,Desert Sand Ult Vy Dk,135,85,57,875539,row 16-25 392 | 453,Shell Gray Light,215,206,203,D7CECB,row 17-01 393 | 452,Shell Gray Med,192,179,174,C0B3AE,row 17-02 394 | 451,Shell Gray Dark,145,123,115,917B73,row 17-03 395 | 3861,Cocoa Light,166,136,129,A68881,row 17-04 396 | 3860,Cocoa,125,93,87,7D5D57,row 17-05 397 | 779,Cocoa Dark,98,75,69,624B45,row 17-06 398 | 712,Cream,255,251,239,FFFBEF,row 17-07 399 | 739,Tan Ult Vy Lt,248,228,200,F8E4C8,row 17-08 400 | 738,Tan Very Light,236,204,158,ECCC9E,row 17-09 401 | 437,Tan Light,228,187,142,E4BB8E,row 17-10 402 | 436,Tan,203,144,81,CB9051,row 17-11 403 | 435,Brown Very Light,184,119,72,B87748,row 17-12 404 | 434,Brown Light,152,94,51,9.85E+35,row 17-13 405 | 433,Brown Med,122,69,31,7A451F,row 17-14 406 | 801,Coffee Brown Dk,101,57,25,653919,row 17-15 407 | 898,Coffee Brown Vy Dk,73,42,19,492A13,row 17-16 408 | 938,Coffee Brown Ult Dk,54,31,14,361F0E,row 17-17 409 | 3371,Black Brown,30,17,8,1E1108,row 17-18 410 | 543,Beige Brown Ult Vy Lt,242,227,206,F2E3CE,row 17-18 411 | 3864,Mocha Beige Light,203,182,156,CBB69C,row 17-20 412 | 3863,Mocha Beige Med,164,131,92,A4835C,row 17-21 413 | 3862,Mocha Beige Dark,138,110,78,8A6E4E,row 17-22 414 | 3031,Mocha Brown Vy Dk,75,60,42,4B3C2A,row 17-23 415 | B5200,Snow White,255,255,255,FFFFFF,row 18-01 416 | White,White,252,251,248,FCFBF8,row 18-02 417 | 3865,Winter White,249,247,241,F9F7F1,row 18-03 418 | Ecru,Ecru,240,234,218,F0EADA,row 18-04 419 | 822,Beige Gray Light,231,226,211,E7E2D3,row 18-05 420 | 644,Beige Gray Med,221,216,203,DDD8CB,row 18-06 421 | 642,Beige Gray Dark,164,152,120,A49878,row 18-07 422 | 640,Beige Gray Vy Dk,133,123,97,857B61,row 18-08 423 | 3787,Brown Gray Dark,98,93,80,625D50,row 18-09 424 | 3021,Brown Gray Vy Dk,79,75,65,4F4B41,row 18-10 425 | 3024,Brown Gray Vy Lt,235,234,231,EBEAE7,row 18-11 426 | 3023,Brown Gray Light,177,170,151,B1AA97,row 18-12 427 | 3022,Brown Gray Med,142,144,120,8E9078,row 18-13 428 | 535,Ash Gray Vy Lt,99,100,88,636458,row 18-14 429 | 3033,Mocha Brown Vy Lt,227,216,204,E3D8CC,row 18-15 430 | 3782,Mocha Brown Lt,210,188,166,D2BCA6,row 18-16 431 | 3032,Mocha Brown Med,179,159,139,B39F8B,row 18-17 432 | 3790,Beige Gray Ult Dk,127,106,85,7F6A55,row 18-18 433 | 3781,Mocha Brown Dk,107,87,67,6B5743,row 18-19 434 | 3866,Mocha Brn Ult Vy Lt,250,246,240,FAF6F0,row 18-20 435 | 842,Beige Brown Vy Lt,209,186,161,D1BAA1,row 18-21 436 | 841,Beige Brown Lt,182,155,126,B69B7E,row 18-22 437 | 840,Beige Brown Med,154,124,92,9A7C5C,row 18-23 438 | 839,Beige Brown Dk,103,85,65,675541,row 18-24 439 | 838,Beige Brown Vy Dk,89,73,55,594937,row 18-25 440 | 3072,Beaver Gray Vy Lt,230,232,232,E6E8E8,row 19-01 441 | 648,Beaver Gray Lt,188,180,172,BCB4AC,row 19-02 442 | 647,Beaver Gray Med,176,166,156,B0A69C,row 19-03 443 | 646,Beaver Gray Dk,135,125,115,877D73,row 19-04 444 | 645,Beaver Gray Vy Dk,110,101,92,6E655C,row 19-05 445 | 844,Beaver Gray Ult Dk,72,72,72,484848,row 19-06 446 | 762,Pearl Gray Vy Lt,236,236,236,ECECEC,row 19-07 447 | 415,Pearl Gray,211,211,214,D3D3D6,row 19-08 448 | 318,Steel Gray Lt,171,171,171,ABABAB,row 19-09 449 | 414,Steel Gray Dk,140,140,140,8C8C8C,row 19-10 450 | 168,Pewter Very Light,209,209,209,D1D1D1,row 19-11 451 | 169,Pewter Light,132,132,132,848484,row 19-12 452 | 317,Pewter Gray,108,108,108,6C6C6C,row 19-13 453 | 413,Pewter Gray Dark,86,86,86,565656,row 19-14 454 | 3799,Pewter Gray Vy Dk,66,66,66,424242,row 19-15 455 | 310,Black,0,0,0,0,row 19-16 456 | -------------------------------------------------------------------------------- /CrossStitchCreator/MainForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Drawing.Drawing2D; 7 | using System.Drawing.Imaging; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Windows.Forms; 11 | using System.Reflection; 12 | using System.IO; 13 | 14 | 15 | namespace CrossStitchCreator 16 | { 17 | 18 | public partial class MainForm : Form 19 | { 20 | 21 | private AboutBox aboutBox = new AboutBox(); 22 | private CrossStitchSettings mSettings = new CrossStitchSettings(); 23 | private bool eventsEnabled = true; 24 | private PatternEditor patternEditor = null; 25 | private int maxUndos = 5; 26 | private bool suspendUndo = false; 27 | 28 | private Bitmap mInputImage; 29 | private Bitmap mCroppedImage; 30 | private Bitmap mResizedImage; 31 | private Bitmap[] undoRecolours; 32 | //private IColourMap[] undoMaps; 33 | private Bitmap recolouredImage; 34 | private Bitmap mRecolouredImage 35 | { 36 | get 37 | { 38 | return recolouredImage; 39 | } 40 | set 41 | { 42 | if (!suspendUndo) 43 | { 44 | for (int i = maxUndos - 1; i > 0; i--) 45 | { 46 | //undoMaps[i] = undoMaps[i - 1]; 47 | undoRecolours[i] = undoRecolours[i - 1]; 48 | } 49 | if (recolouredImage != null) 50 | { 51 | undoRecolours[0] = new Bitmap(recolouredImage); 52 | undoRecolours[0].Tag = recolouredImage.Tag; 53 | } 54 | else undoRecolours[0] = null; 55 | } 56 | recolouredImage = value; 57 | if (recolouredImage != null) 58 | { 59 | UpdateColourMap(); 60 | if (ColourMap != null) recolouredImage.Tag = ColourMap.Clone(); 61 | else recolouredImage.Tag = null; 62 | } 63 | } 64 | } 65 | private Bitmap mPatternImage; 66 | 67 | public IColourMap ColourMap {get;set;} 68 | private ColourMapViewer mColourViewer; 69 | 70 | public const int MAX_COLOURS = 100; 71 | 72 | public MainForm() 73 | { 74 | undoRecolours = new Bitmap[maxUndos]; 75 | //undoMaps = new IColourMap[maxUndos]; 76 | 77 | InitializeComponent(); 78 | patternEditor = new PatternEditor(this); 79 | interpCombo.DataSource = Enum.GetValues(typeof(InterpolationMode)); 80 | patternEditor.FormClosing += new FormClosingEventHandler(patternEditor_FormClosing); 81 | colourMapCombo.Items.Add(typeof(DMCColourMap)); 82 | colourMapCombo.Items.Add(typeof(SimpleColourMap)); 83 | colourMapCombo.SelectedIndex = 0; 84 | } 85 | 86 | public void CreateNewColourMap() 87 | { 88 | Type t = (Type)colourMapCombo.SelectedItem; 89 | //ConstructorInfo c = t.GetConstructor(new Type[] { }); 90 | //object[] ps = new object[] { }; 91 | 92 | object cmap = Activator.CreateInstance(t); 93 | ColourMap = (IColourMap)cmap; 94 | 95 | // Add black and white, because they are awesome. 96 | Color White = Color.FromArgb(255, 255, 255, 255); 97 | Color Black = Color.FromArgb(255, 0, 0, 0); 98 | if (!ColourMap.Colours.ContainsKey(White)) 99 | { 100 | SimpleColour s = new SimpleColour("White", ColourMap.Colours.Count, White); 101 | ColourMap.Colours[White] = s; 102 | } 103 | if (!ColourMap.Colours.ContainsKey(Black)) 104 | { 105 | SimpleColour s = new SimpleColour("Black", ColourMap.Colours.Count, Black); 106 | ColourMap.Colours[Black] = s; 107 | } 108 | ColourMap.Colours[White].IsChecked = true; 109 | ColourMap.Colours[Black].IsChecked = true; 110 | } 111 | 112 | 113 | #region Form Stuff 114 | private void updateSettingsFromForm() 115 | { 116 | mSettings.OutputHeight = (int)heightUpDown.Value; 117 | mSettings.OutputWidth = (int)widthUpDown.Value; 118 | mSettings.FixSizeRatio = fixRatioCheck.Checked; 119 | if (ColourMap == null) 120 | mSettings.MaxColours = MAX_COLOURS; 121 | else 122 | mSettings.MaxColours = ColourMap.Count; 123 | } 124 | 125 | private void updateFormFromSettings() 126 | { 127 | eventsEnabled = false; 128 | heightUpDown.Value = mSettings.OutputHeight; 129 | widthUpDown.Value = mSettings.OutputWidth; 130 | fixRatioCheck.Checked = mSettings.FixSizeRatio; 131 | maxColoursUpDown.Value = mSettings.MaxColours; 132 | eventsEnabled = true; 133 | } 134 | 135 | private void MainForm_Load(object sender, EventArgs e) 136 | { 137 | updateSettingsFromForm(); 138 | } 139 | #endregion 140 | 141 | #region Main Menu Stuff 142 | 143 | string imageFileFilter = "PNG (*.png)|*.png|24bit Bitmap (*.bmp)|*.bmp|JPEG (*.jpeg)|*.jpeg|TIFF (*.tiff)|*.tiff,*.tif|Gif (*.gif)|*.gif|All Files (*.*)|*.*"; 144 | 145 | private void aboutToolStripMenuItem_Click(object sender, EventArgs e) 146 | { 147 | aboutBox.ShowDialog(); 148 | } 149 | 150 | private void exitToolStripMenuItem_Click(object sender, EventArgs e) 151 | { 152 | this.Close(); 153 | } 154 | 155 | private void openToolStripMenuItem_Click(object sender, EventArgs e) 156 | { 157 | openFileDialog.Filter = imageFileFilter; 158 | openFileDialog.Title = "Open Image File..."; 159 | openFileDialog.Multiselect = false; 160 | openFileDialog.ShowDialog(); 161 | } 162 | 163 | private void openFileDialog_FileOk(object sender, CancelEventArgs e) 164 | { 165 | mSettings.InputImagePath = openFileDialog.FileName; 166 | LoadImage(); 167 | } 168 | 169 | 170 | private void savePatternImageAs(object sender, EventArgs e) 171 | { 172 | if (mPatternImage == null) return; 173 | 174 | saveFileDialog.Filter = imageFileFilter; 175 | saveFileDialog.FileName = mSettings.PatternImagePath; 176 | if(saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 177 | { 178 | mSettings.PatternImagePath = saveFileDialog.FileName; 179 | SaveImage(mPatternImage, mSettings.PatternImagePath); 180 | } 181 | 182 | } 183 | 184 | 185 | private void SaveImage(Bitmap bmp, string path) 186 | { 187 | try 188 | { 189 | ImageFormat format = GetImageFormatFromExtension(path); 190 | if (format != ImageFormat.MemoryBmp) 191 | bmp.Save(path, format); 192 | else 193 | { 194 | MessageBox.Show("No Codec to save to this format"); 195 | return; 196 | } 197 | } 198 | catch (IOException ioe) 199 | { 200 | MessageBox.Show("Saving Image Failed: " + ioe); 201 | } 202 | } 203 | 204 | private static ImageFormat GetImageFormatFromExtension(string path) 205 | { 206 | string extension = Path.GetExtension(path).Substring(1); 207 | ImageFormat format = ImageFormat.MemoryBmp; 208 | 209 | if (extension.Equals("bmp")) 210 | format = ImageFormat.Bmp; 211 | else if (extension.Equals("gif")) 212 | format = ImageFormat.Gif; 213 | else if (extension.Equals("tiff") || extension.Equals("tif")) 214 | format = ImageFormat.Tiff; 215 | else if (extension.Equals("jpeg") || extension.Equals("jpg")) 216 | format = ImageFormat.Jpeg; 217 | else if (extension.Equals("png")) 218 | format = ImageFormat.Png; 219 | return format; 220 | } 221 | 222 | 223 | private void savePatternLegendAsToolStripMenuItem_Click(object sender, EventArgs e) 224 | { 225 | saveFileDialog.Filter = imageFileFilter; 226 | saveFileDialog.FileName = mSettings.PatternLegendPath; 227 | if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 228 | { 229 | mSettings.PatternLegendPath = saveFileDialog.FileName; 230 | SavePatternLegend(); 231 | } 232 | } 233 | 234 | 235 | private void SavePatternLegend() 236 | { 237 | Control con = this.patternEditor.ColourList; 238 | Size oldSize = con.Size; 239 | if(oldSize.Width < 400 || oldSize.Height < 600) 240 | con.Size = new System.Drawing.Size(500, 750); 241 | Bitmap bmp = new Bitmap(con.Width, con.Height); 242 | con.DrawToBitmap(bmp, new Rectangle(0, 0, con.Width, con.Height)); 243 | SaveImage(bmp, mSettings.PatternLegendPath); 244 | con.Size = oldSize; 245 | } 246 | 247 | private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) 248 | { 249 | if (mRecolouredImage == null) return; 250 | 251 | saveFileDialog.Filter = imageFileFilter; 252 | saveFileDialog.FileName = mSettings.OutputImagePath; 253 | if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 254 | { 255 | mSettings.OutputImagePath = saveFileDialog.FileName; 256 | SaveImage(mRecolouredImage, mSettings.OutputImagePath); 257 | } 258 | } 259 | 260 | public void LoadImage() 261 | { 262 | this.Cursor = Cursors.WaitCursor; 263 | try 264 | { 265 | disposeColourViewer(); 266 | mColourViewer = null; 267 | mInputImage = (Bitmap)Image.FromFile(mSettings.InputImagePath); 268 | if (mInputImage.Height > 1000 || mInputImage.Width > 1000) 269 | { 270 | // too big. resize to be smaller. 271 | float maxDim = Math.Max(mInputImage.Width, mInputImage.Height); 272 | float scale = maxDim / 1000; 273 | Size newSize = new Size((int)((float)mInputImage.Width / scale),(int)((float) mInputImage.Height / scale)); 274 | ImagingTool tool = new ImagingTool(mInputImage); 275 | tool.ResizeImage(newSize,InterpolationMode.Default); 276 | mInputImage = tool.OutputImage; 277 | 278 | } 279 | mSettings.InputImageSize = mInputImage.Size; 280 | mSettings.FixSizeRatio = fixRatioCheck.Checked; 281 | mResizedImage = null; 282 | //mCroppedImage = null; 283 | mRecolouredImage = null; 284 | mPatternImage = null; 285 | } 286 | catch (ArgumentException e) 287 | { 288 | MessageBox.Show("Ooops! Bad Argument" + Environment.NewLine + "Filename = " + mSettings.InputImagePath 289 | + Environment.NewLine + e + Environment.NewLine + e.StackTrace); 290 | } 291 | finally { this.Cursor = Cursors.Default; } 292 | RedrawTab1Images(); 293 | RedrawTab2Images(); 294 | RedrawTab3Images(); 295 | } 296 | 297 | 298 | private void undoToolStripMenuItem_Click(object sender, EventArgs e) 299 | { 300 | for (int i = 0; i < maxUndos; i++) 301 | { 302 | if (undoRecolours[i] != null) 303 | { 304 | Console.Write("Undo: " + i + ", " + undoRecolours[i].Tag); 305 | if (undoRecolours[i].Tag != null) 306 | { 307 | IColourMap cmap = (IColourMap)undoRecolours[i].Tag; 308 | Console.WriteLine(", " + cmap.Count); 309 | } 310 | else Console.WriteLine(", null"); 311 | } 312 | else Console.WriteLine("Undo: " + i + ", null, null"); 313 | } 314 | if (undoRecolours[0] != null) 315 | { 316 | Console.WriteLine("Undo tag: " + undoRecolours[0].Tag); 317 | // shift undo arrays to the left. 318 | ColourMap = (IColourMap)undoRecolours[0].Tag; 319 | recolouredImage = undoRecolours[0]; 320 | for (int i = 0; i < maxUndos - 1; i++) 321 | { 322 | undoRecolours[i] = undoRecolours[i + 1]; 323 | //undoMaps[i] = undoMaps[i + 1]; 324 | } 325 | undoRecolours[maxUndos - 1] = null; 326 | //undoMaps[maxUndos - 1] = null; 327 | UpdateColourMap(); 328 | RedrawTab2Images(); 329 | } 330 | } 331 | 332 | #endregion 333 | 334 | #region Tab1 Stuff 335 | 336 | public void ResizeImage(object sender, EventArgs e) 337 | { 338 | if (mInputImage == null) return; 339 | this.Cursor = Cursors.WaitCursor; 340 | ImagingTool tool; 341 | if (mCroppedImage == null) 342 | tool = new ImagingTool(mInputImage, ColourMap); 343 | else 344 | tool = new ImagingTool(mCroppedImage, ColourMap); 345 | //mSettings.InputImageSize = mInputImage.Size; 346 | tool.ResizeImage(mSettings.OutputImageSize, (InterpolationMode)interpCombo.SelectedItem); 347 | mResizedImage = tool.OutputImage; 348 | this.Cursor = Cursors.Default; 349 | RedrawTab1Images(); 350 | } 351 | 352 | public void CropImage(object sender, EventArgs e) 353 | { 354 | mResizedImage = null; 355 | RedrawTab1Images(); 356 | } 357 | 358 | private void RedrawTab1Images() 359 | { 360 | this.Cursor = Cursors.WaitCursor; 361 | if (mInputImage != null) 362 | { 363 | ImagingTool tool1 = new ImagingTool(mInputImage); 364 | pictureBoxOriginal.Image = tool1.FitToControl(pictureBoxOriginal); 365 | } 366 | else 367 | { 368 | pictureBoxOriginal.Image = null; 369 | } 370 | if (mResizedImage != null) 371 | { 372 | ImagingTool tool2 = new ImagingTool(mResizedImage); 373 | pictureBoxResized.Image = tool2.FitToControl(pictureBoxOriginal); 374 | } 375 | else 376 | { 377 | pictureBoxResized.Image = null; 378 | } 379 | 380 | updateFormFromSettings(); 381 | this.Cursor = Cursors.Default; 382 | } 383 | 384 | private void modifyOutputSize(object sender, EventArgs e) 385 | { 386 | if (eventsEnabled) 387 | { 388 | if (sender == widthUpDown) 389 | { 390 | mSettings.OutputWidth = (int)widthUpDown.Value; 391 | } 392 | else if (sender == heightUpDown) 393 | { 394 | mSettings.OutputHeight = (int)heightUpDown.Value; 395 | } 396 | else if (sender == fixRatioCheck) 397 | { 398 | mSettings.FixSizeRatio = fixRatioCheck.Checked; 399 | } 400 | else if (sender == interpCombo) 401 | { 402 | mSettings.IntMode = (InterpolationMode)interpCombo.SelectedItem; 403 | } 404 | updateFormFromSettings(); 405 | } 406 | } 407 | 408 | #endregion 409 | 410 | #region Tab2 Stuff 411 | 412 | private void showPalette(object sender, EventArgs e) 413 | { 414 | if (mColourViewer == null) 415 | { 416 | if (ColourMap != null) 417 | { 418 | mColourViewer = new ColourMapViewer(ColourMap); 419 | mColourViewer.FormClosing += new FormClosingEventHandler(mColourViewer_FormClosing); 420 | mColourViewer.ColourChangeEvent += new ColourChangeEventHandler(mColourViewer_ColourChangeEvent); 421 | } 422 | else return; 423 | } 424 | UpdateColourMap(); 425 | mColourViewer.Show(); 426 | mColourViewer.Focus(); 427 | } 428 | 429 | void mColourViewer_ColourChangeEvent(object sender, ColourChangeEventArgs e) 430 | { 431 | if (mRecolouredImage == null) return; 432 | ImagingTool tool = new ImagingTool(mRecolouredImage, ColourMap); 433 | if (!e.DoReplace) 434 | { 435 | tool.RemoveFromPalette(e.Colour); 436 | } 437 | else 438 | { 439 | tool.ReplaceColour(e.Colour, e.ReplacementColour); 440 | } 441 | mRecolouredImage = tool.OutputImage; 442 | //UpdateColourMap(); 443 | //showPalette(null, null); 444 | RedrawTab2Images(); 445 | } 446 | 447 | private void UpdateColourMap() 448 | { 449 | if (mRecolouredImage != null && ColourMap != null) 450 | { 451 | ImagingTool tool = new ImagingTool(mRecolouredImage, ColourMap); 452 | tool.UpdateColourMapFromImage(); 453 | mSettings.MaxColours = ColourMap.Count; 454 | updateFormFromSettings(); 455 | if (mColourViewer != null) 456 | { 457 | mColourViewer.UpdateColourMap(ColourMap); 458 | } 459 | } 460 | } 461 | 462 | private void RedrawTab2Images() 463 | { 464 | this.Cursor = Cursors.WaitCursor; 465 | if (mResizedImage != null) 466 | { 467 | ImagingTool tool1 = new ImagingTool(mResizedImage); 468 | pictureBoxResized2.Image = tool1.FitToControl(pictureBoxOriginal); 469 | } 470 | else 471 | { 472 | pictureBoxResized2.Image = null; 473 | } 474 | if (mRecolouredImage != null) 475 | { 476 | ImagingTool tool2 = new ImagingTool(mRecolouredImage); 477 | pictureBoxRecoloured.Image = tool2.FitToControl(pictureBoxOriginal); 478 | } 479 | else 480 | { 481 | pictureBoxRecoloured.Image = null; 482 | } 483 | updateFormFromSettings(); 484 | this.Cursor = Cursors.Default; 485 | } 486 | 487 | private void modifyColours(object sender, EventArgs e) 488 | { 489 | if (eventsEnabled && mResizedImage != null) 490 | { 491 | if (sender == maxColoursUpDown) 492 | { 493 | updateSettingsFromForm(); 494 | } 495 | if (sender == recolourButton) RecolourImage(true); 496 | else RecolourImage(false); 497 | } 498 | } 499 | 500 | public void RecolourImage(bool startAgain) 501 | { 502 | this.Cursor = Cursors.WaitCursor; 503 | ImagingTool tool; 504 | if (mRecolouredImage == null || startAgain) 505 | { 506 | CreateNewColourMap(); 507 | tool = new ImagingTool(mResizedImage, ColourMap); 508 | //tool.ReduceColourDepth(); 509 | tool.ReduceColourDepth(ColourMap); 510 | mRecolouredImage = tool.OutputImage; 511 | } 512 | else 513 | { 514 | tool = new ImagingTool(mRecolouredImage, ColourMap); 515 | tool.ReduceColourDepth((int)maxColoursUpDown.Value); 516 | mRecolouredImage = tool.OutputImage; 517 | } 518 | //UpdateColourMap(); 519 | this.Cursor = Cursors.Default; 520 | RedrawTab2Images(); 521 | } 522 | 523 | 524 | private void disposeColourViewer() 525 | { 526 | if (mColourViewer != null) 527 | { 528 | mColourViewer.FormClosing -= mColourViewer_FormClosing; 529 | mColourViewer.ColourChangeEvent -= mColourViewer_ColourChangeEvent; 530 | mColourViewer.Close(); 531 | mColourViewer.Dispose(); 532 | } 533 | } 534 | 535 | void mColourViewer_FormClosing(object sender, FormClosingEventArgs e) 536 | { 537 | e.Cancel = true; 538 | mColourViewer.Hide(); 539 | } 540 | 541 | private Color mPaintingColor; 542 | private bool mPainting = false; 543 | private bool lastClickWasRight = false; 544 | 545 | private void pictureBoxNew_MouseClick(object sender, MouseEventArgs e) 546 | { 547 | if (mRecolouredImage != null) 548 | { 549 | float xScale = (float)pictureBoxResized.Image.Width / (float)mRecolouredImage.Width; 550 | float yScale = (float)pictureBoxResized.Image.Height / (float)mRecolouredImage.Height; 551 | int x = (int)((float)e.X / xScale); 552 | int y = (int)((float)e.Y / yScale); 553 | if (x >= 0 && x < mRecolouredImage.Width && y >= 0 && y < mRecolouredImage.Height) 554 | { 555 | if (e.Button == MouseButtons.Right) 556 | { 557 | if (mColourViewer == null || mColourViewer.Visible == false) 558 | { 559 | showPalette(null, null); 560 | } 561 | Color c = mRecolouredImage.GetPixel(x, y); 562 | mColourViewer.SelectColour(c); 563 | mPainting = true; 564 | suspendUndo = true; 565 | mPaintingColor = c; 566 | lastClickWasRight = true; 567 | } 568 | else if (e.Button == MouseButtons.Left) 569 | { 570 | lastClickWasRight = false; 571 | if (mPainting && mRecolouredImage.GetPixel(x, y) != mPaintingColor) 572 | { 573 | mRecolouredImage.SetPixel(x, y, mPaintingColor); 574 | RedrawTab2Images(); 575 | } 576 | } 577 | else 578 | { 579 | if (mPainting && !lastClickWasRight) 580 | { 581 | if (suspendUndo) 582 | { 583 | suspendUndo = false; 584 | mRecolouredImage = mRecolouredImage; 585 | } 586 | } 587 | } 588 | } 589 | } 590 | } 591 | 592 | private void StopPainting(object sender, EventArgs e) 593 | { 594 | mPainting = false; 595 | if (suspendUndo) 596 | { 597 | suspendUndo = false; 598 | mRecolouredImage = mRecolouredImage; 599 | } 600 | } 601 | 602 | 603 | private void tabPageRecolour_Enter(object sender, EventArgs e) 604 | { 605 | RedrawTab2Images(); 606 | } 607 | #endregion 608 | 609 | #region Tab3 Stuff 610 | private void tabPage2_Enter(object sender, EventArgs e) 611 | { 612 | RedrawTab3Images(); 613 | ShowPatternEditor(); 614 | } 615 | 616 | 617 | void patternEditor_FormClosing(object sender, FormClosingEventArgs e) 618 | { 619 | e.Cancel = true; 620 | patternEditor.Hide(); 621 | } 622 | 623 | private void editButton_Click(object sender, EventArgs e) 624 | { 625 | ShowPatternEditor(); 626 | } 627 | 628 | public void ShowPatternEditor() 629 | { 630 | if (mRecolouredImage != null) 631 | { 632 | this.Cursor = Cursors.WaitCursor; 633 | ImagingTool tool = new ImagingTool(mRecolouredImage); 634 | patternEditor.UpdateColourMap(); 635 | this.Cursor = Cursors.Default; 636 | patternEditor.Show(); 637 | patternEditor.Focus(); 638 | } 639 | } 640 | 641 | private void RedrawTab3Images() 642 | { 643 | this.Cursor = Cursors.WaitCursor; 644 | if (mRecolouredImage != null) 645 | { 646 | ImagingTool tool1 = new ImagingTool(mRecolouredImage); 647 | pictureBoxRecoloured2.Image = tool1.FitToControl(pictureBoxRecoloured2); 648 | } 649 | else 650 | { 651 | pictureBoxRecoloured2.Image = null; 652 | } 653 | if (mPatternImage != null) 654 | { 655 | ImagingTool tool2 = new ImagingTool(mPatternImage); 656 | pictureBoxPattern.Image = tool2.FitToControl(pictureBoxPattern); 657 | } 658 | else 659 | { 660 | pictureBoxPattern.Image = null; 661 | } 662 | updateFormFromSettings(); 663 | this.Cursor = Cursors.Default; 664 | } 665 | private void RedrawPattern() 666 | { 667 | if (mRecolouredImage != null) 668 | { 669 | ImagingTool tool3 = new ImagingTool(mRecolouredImage); 670 | tool3.ReplaceColoursWithPatterns(patternEditor); 671 | mPatternImage = tool3.OutputImage; 672 | pictureBoxPattern.Image = mPatternImage; 673 | } 674 | } 675 | 676 | private void updateButton_Click(object sender, EventArgs e) 677 | { 678 | ShowPatternEditor(); 679 | RedrawPattern(); 680 | } 681 | #endregion 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | } 692 | } 693 | --------------------------------------------------------------------------------