Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace ColorRetreiver
- {
- class Program
- {
- static OpenFileDialog file = new OpenFileDialog();
- static Bitmap image;
- [STAThread]
- static void Main(string[] args)
- {
- Console.WriteLine("----- made by ya boii, juan --------");
- 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.");
- Console.WriteLine("\n\nFoto bestand: ....");
- Thread.Sleep(5000);
- one:
- using (var selectFileDialog = new OpenFileDialog())
- {
- selectFileDialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.JPEG;*.PNG)|*.BMP;*.JPG;*.GIF;*.JPEG;*.PNG";
- if (selectFileDialog.ShowDialog() == DialogResult.OK)
- {
- Console.WriteLine(selectFileDialog.FileName);
- image = new Bitmap(selectFileDialog.FileName);
- }
- }
- if (image == null)
- goto one;
- Console.WriteLine("\n\nVergroter: ");
- List<string> code = new List<string>();
- //Thread.Sleep(2500);
- float multiplier = float.Parse(Console.ReadLine());
- Console.WriteLine("\n\n Offset x: ");
- float offsetx = float.Parse(Console.ReadLine());
- Console.WriteLine("\n\n Offset y: ");
- float offsety = float.Parse(Console.ReadLine());
- Console.WriteLine("De originele foto is " + image.Width + " pixels breed en " + image.Height + " pixels hoog");
- Color lastcolor = Color.AliceBlue;
- for (int i = 0; i < image.Width; i++)
- {
- for (int j = 0; j < image.Height; j++)
- {
- Color pixel = image.GetPixel(i, j);
- if (pixel != lastcolor && pixel != Color.Transparent)
- {
- code.Add("GAME_ENGINE.SetColor(" + pixel.R + "," + pixel.G + "," + pixel.B + "," + pixel.A + ");");
- lastcolor = pixel;
- }
- //GAME_ENGINE.FillRectangle(x, y, w, h);
- if (pixel != Color.Transparent)
- code.Add("GAME_ENGINE.FillRectangle(" + (i * multiplier + offsetx) + ", " + (j * multiplier + offsety) + ", " + 1 * multiplier + ", " + 1 * multiplier + ");");
- }
- }
- using (FileStream fs = File.Open("thacodeboyyy.txt", FileMode.Create))
- {
- StreamWriter sw = new StreamWriter(fs);
- code.ForEach(r => sw.WriteLine(r));
- }
- Console.WriteLine("Dooone");
- Process.Start("thacodeboyyy.txt");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement