Esempio n. 1
0
        public Main_Form()
        {
            Gradients = new Color_Editor(true);
            Outline   = new Color_Editor(false);

            width  = 256;
            height = 32;

            InitializeComponent();
            Information = new WriteInfo(null, null, tckLetter.Value, tckWords.Value, cmbPrefix.Text.ToLower(), (double)tckSqueeze.Value / 100, chkboxPrefix.Checked, 2, false, chkColor.Checked, (double)tckVertical.Value / 100);


            //get scale factor for display
            int DispWidth = picText.Size.Width;

            scale = (double)DispWidth / (double)width;

            BaseImage = new Bitmap(width, height);
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    ((Bitmap)BaseImage).SetPixel(i, j, Color.FromArgb(0, 255, 255, 255));
                }
            }
        }
Esempio n. 2
0
        private void LoadSettings(object sender, EventArgs e)
        {
            OpenFileDialog opentxt = new OpenFileDialog();

            opentxt.Filter           = "json files(*.json)| *.json";
            opentxt.RestoreDirectory = true;
            if (opentxt.ShowDialog() == DialogResult.OK)
            {
                WriteInfo info = JsonConvert.DeserializeObject <WriteInfo>(File.ReadAllText(opentxt.FileName));
                Information = info;

                //update the gui
                cmbPrefix.SelectedItem = Information.Prefix;
                chkColor.Checked       = Information.HasColor;
                chkboxPrefix.Checked   = Information.PrefixSmall;
                tckLetter.Value        = Information.LetterSpacing;
                tckSqueeze.Value       = (int)(Information.SqueezeFactor * 100);
                tckWords.Value         = Information.WordSpacing;
            }
        }
Esempio n. 3
0
        //process shit IN ORDER
        public static int[] spacing(String[] text, WriteInfo Info)
        {
            //make the positions array
            int[] positions = new int[text.Length];
            positions[0] = 0;
            int TotLength = 0;

            //get the information
            Image image     = Info.image;
            int   btletters = Info.LetterSpacing;
            int   btwords   = Info.WordSpacing;

            //Console.WriteLine("Image height: " + image.Height);

            //iterate through the whole array to get the position of each character
            for (int i = 0; i < text.Length; i++)
            {
                String letter = text[i];

                if (!String.IsNullOrWhiteSpace(letter))
                {
                    String name       = "mariofont_" + letter + ".png";
                    String fileToRead = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\btis\" + name;
                    try
                    {
                        Bitmap imageLetter = new Bitmap(fileToRead);

                        if (i + 1 < text.Length)
                        {
                            if (letter.Length > 1)
                            {
                                double prefixScale = 1;
                                if (Info.PrefixSmall)
                                {
                                    prefixScale = .9;
                                }
                                positions[i + 1] = positions[i] + ((int)(imageLetter.Width * prefixScale) - btletters);
                                TotLength       += ((int)(imageLetter.Width * prefixScale) - btletters);
                            }
                            else
                            {
                                positions[i + 1] = positions[i] + ((int)(imageLetter.Width) - btletters);
                                TotLength       += imageLetter.Width - btletters;
                            }
                        }
                        else
                        {
                            TotLength += imageLetter.Width;
                        }


                        imageLetter.Dispose();
                    }
                    catch {  }
                }
                else
                {
                    positions[i + 1] = positions[i] + (btwords);
                    TotLength       += (btwords);
                }
            }
            //Console.WriteLine("");
            //Console.WriteLine(totalLength);

            totalLength = TotLength;

            return(positions);
        }
Esempio n. 4
0
        public static Image writeLetters(WriteInfo Info, Color_Editor Gradients, Color_Editor Outline, Image BaseImage)
        {
            //trim text and get the characters
            String text = Info.text;

            text.Trim();
            char[] characters = text.ToCharArray();

            String[] chars;

            //if there is a prefix, make the array of strings to write accomdate it

            String prefix = Info.Prefix;
            ///Debug.WriteLine(prefix);
            bool withPre = prefix.Equals("none") || prefix.Equals("None");

            int index;


            if (!withPre)
            {
                chars    = new String[characters.Length + 2];
                chars[0] = prefix;
                chars[1] = " ";
                index    = 2;
            }
            else
            {
                chars = new String[characters.Length];
                index = 0;
            }

            int cindex = -1;

            //write the char array to the string array
            for (int i = 0; i < characters.Length; i++)
            {
                chars[i + index] = characters[i].ToString();
                if (!String.IsNullOrWhiteSpace(chars[i + index]))
                {
                    cindex++;
                }
            }

            //thing for special characters here
            chars = Main_Form.specialCharacters(chars);

            //call the spacing function
            int[] xposes = spacing(chars, Info);

            Image thisImage = new Bitmap(totalLength + 3, 32);

            for (int i = 0; i < xposes.Length; i++)
            {
                xposes[i] = 1 + xposes[i];
            }

            //actually writing the letters
            for (int i = xposes.Length - 1; i > -1; i--)
            {
                String letter = chars[i];
                String chara  = letter.ToString().ToLower();

                if (!String.IsNullOrWhiteSpace(letter))
                {
                    //get the letter image files

                    String name       = "mariofont_" + chara + ".png";
                    String fileToRead = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\btis\" + name;

                    if (File.Exists(fileToRead))
                    {
                        Bitmap LetterImage = new Bitmap(fileToRead);

                        //if the color is on, edit the letter image
                        if (Info.HasColor && Gradients.Setting == 0)
                        {
                            int colorindex = cindex % Gradients.Colors.Count;
                            Debug.WriteLine(colorindex);
                            LetterImage = editColor(LetterImage, Gradients, Outline, colorindex, BaseImage);
                            LetterImage = (Bitmap)why(LetterImage);
                            //LetterImage = (Bitmap)makeOutline(LetterImage, Outline.Colors[0][0]);
                            cindex--;
                        }

                        Graphics mainImage = Graphics.FromImage(thisImage);
                        //Debug.WriteLine(withPre);
                        //drawing the actual image
                        if (chara.Length > 1 && !withPre)
                        {
                            double preScale = 1;
                            //Debug.WriteLine("prescale maybw");
                            if (Info.PrefixSmall)
                            {
                                preScale = .9;
                                //Debug.WriteLine("prescale changed");
                            }
                            mainImage.DrawImage(LetterImage, new Rectangle(xposes[i], 0, (int)(LetterImage.Width * preScale), (int)(LetterImage.Height * preScale)));
                        }
                        else
                        {
                            mainImage.DrawImage(LetterImage, new Rectangle(xposes[i], 0, LetterImage.Width, 32));
                        }

                        LetterImage.Dispose();
                    }
                }
            }

            //color the image if by image
            if (Info.HasColor && Gradients.Setting == 2)
            {
                thisImage = editColor(thisImage, Gradients, Outline, index, BaseImage);
            }

            //thisImage = makeOutline(thisImage, Outline.Colors[0][0]);
            if (Info.HasColor)
            {
                thisImage = makeOutline(thisImage, Outline);
            }
            else
            {
                Outline   = new Color_Editor(false);
                thisImage = makeOutline(thisImage, Outline);
            }

            //scale the image



            Image    newImage = new Bitmap(Info.image.Width, Info.image.Height);
            Graphics newgraph = Graphics.FromImage(newImage);

            int NewWidth  = (int)(thisImage.Width * Info.SqueezeFactor);
            int NewHeight = (int)(thisImage.Height * Info.VertiFactor);

            Rectangle DrawRectangle = new Rectangle(0, (Info.image.Height - NewHeight) / 2, NewWidth, NewHeight);


            //deal with alignment
            if (!Info.auto)
            {
                if (Info.align == 1)
                {
                    int HoriShift = Info.image.Width - (int)(thisImage.Width * Info.SqueezeFactor);
                    DrawRectangle.Offset(HoriShift, 0);
                }
                else if (Info.align == 2)
                {
                    int HoriShift = Info.image.Width - (int)(thisImage.Width * Info.SqueezeFactor);
                    DrawRectangle.Offset(HoriShift / 2, 0);
                }
            }
            else
            {
                newImage      = new Bitmap(NewWidth, NewHeight);
                newgraph      = Graphics.FromImage(newImage);
                DrawRectangle = new Rectangle(0, 0, NewWidth, NewHeight);
            }

            newgraph.DrawImage(thisImage, DrawRectangle);

            return(newImage);
        }