Advertisement
Guest User

Code

a guest
Sep 21st, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Drawing;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace ColorRetreiver
  13. {
  14.  
  15.     class Program
  16.     {
  17.         static OpenFileDialog file = new OpenFileDialog();
  18.         static Bitmap image;
  19.         [STAThread]
  20.         static void Main(string[] args)
  21.         {
  22.             Console.WriteLine("----- made by ya boii, juan --------");
  23.             Console.WriteLine("\nSelecteer een foto bestand, zorg dat dit een sprite is, dus niet teveel pixels heeft, anders heb je heel veel lines of code.");
  24.             Console.WriteLine("\n\nFoto bestand: ....");
  25.             Thread.Sleep(5000);
  26.         one:
  27.             using (var selectFileDialog = new OpenFileDialog())
  28.             {
  29.                 selectFileDialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.JPEG;*.PNG)|*.BMP;*.JPG;*.GIF;*.JPEG;*.PNG";
  30.                 if (selectFileDialog.ShowDialog() == DialogResult.OK)
  31.                 {
  32.                     Console.WriteLine(selectFileDialog.FileName);
  33.                     image = new Bitmap(selectFileDialog.FileName);
  34.                 }
  35.             }
  36.             if (image == null)
  37.                 goto one;
  38.             Console.WriteLine("\n\nVergroter: ");
  39.             List<string> code = new List<string>();
  40.             //Thread.Sleep(2500);
  41.             float multiplier = float.Parse(Console.ReadLine());
  42.             Console.WriteLine("\n\n Offset x: ");
  43.             float offsetx = float.Parse(Console.ReadLine());
  44.             Console.WriteLine("\n\n Offset y: ");
  45.             float offsety = float.Parse(Console.ReadLine());
  46.             Console.WriteLine("De originele foto is " + image.Width + " pixels breed en " + image.Height + " pixels hoog");
  47.             Color lastcolor = Color.AliceBlue;
  48.             for (int i = 0; i < image.Width; i++)
  49.             {
  50.                 for (int j = 0; j < image.Height; j++)
  51.                 {
  52.                     Color pixel = image.GetPixel(i, j);
  53.                     if (pixel != lastcolor && pixel != Color.Transparent)
  54.                     {
  55.                         code.Add("GAME_ENGINE.SetColor(" + pixel.R + "," + pixel.G + "," + pixel.B + "," + pixel.A + ");");
  56.                         lastcolor = pixel;
  57.                     }
  58.                     //GAME_ENGINE.FillRectangle(x, y, w, h);
  59.                     if (pixel != Color.Transparent)
  60.                         code.Add("GAME_ENGINE.FillRectangle(" + (i * multiplier + offsetx) + ", " + (j * multiplier + offsety) + ", " + 1 * multiplier + ", " + 1 * multiplier + ");");
  61.                 }
  62.             }
  63.  
  64.             using (FileStream fs = File.Open("thacodeboyyy.txt", FileMode.Create))
  65.             {
  66.                 StreamWriter sw = new StreamWriter(fs);
  67.                 code.ForEach(r => sw.WriteLine(r));
  68.             }
  69.             Console.WriteLine("Dooone");
  70.             Process.Start("thacodeboyyy.txt");
  71.  
  72.             Console.ReadLine();
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement