static void PikselCiz(Piksel Piksel) { SetCursorPosition(Piksel.XPoz, Piksel.YPoz); ForegroundColor = Piksel.EkranRengi; Write("@"); SetCursorPosition(0, 0); }
static void Main(string[] args) { for (int i = 0; i < filenames.Length; i++) { Console.WriteLine("{0} - {1}", i + 1, filenames[i]); } Console.Write("Select a cover image from list up above: "); int selection = Convert.ToInt32(Console.ReadLine()); Bitmap original_bmp = new Bitmap(".\\cover-images\\" + filenames[selection - 1]); int width = original_bmp.Width, height = original_bmp.Height, totalArea = width * height; Bitmap stego_image = new Bitmap(width, height); Piksel[,] pArr_original = new Piksel[width, height]; Piksel[,] pArr = new Piksel[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { pArr_original[i, j] = pArr[i, j] = new Piksel(original_bmp.GetPixel(i, j).R); } } //Random R = new Random(totalArea); //HashSet<Piksel> hashP = new HashSet<Piksel>(); //while (hashP.Count != totalArea) //{ // int rndWi = R.Next(0, width); // int rndHe = R.Next(0, height); // hashP.Add(pArr[rndWi, rndHe]); //} Console.WriteLine("\nDecoded Message:\n" + DecodeMessage(width, height, pArr)); //1011 1010 Console.Write("\nEnter Message: "); string s = Console.ReadLine() + EOM; //string s = File.ReadAllText(@"message.txt") + EOM; int[] message = EncodeMessage(s); WriteMessage(selection, width, height, stego_image, pArr, message); Console.WriteLine("\nCapacity:\t\t\t{0} (bpp)", CalculateCapacity(message.Length, width, height).ToString()); Console.WriteLine("Mean Square Error:\t\t{0} ", CalculateMSE(pArr, pArr_original, width, height).ToString()); Console.WriteLine("Pixel Signal Noise Ratio:\t{0} (dB)", CalculatePSNR(pArr, pArr_original, width, height).ToString()); Console.WriteLine("Structural Similarity Index:\t{0}", CalculateSSIM(pArr, pArr_original, width, height, message.Length).ToString()); Console.WriteLine("Done!"); Console.ReadKey(); }
private static void NodeA_CommandReceived(object sender, Piksel.Nemesis.CommandReceivedEventArgs e) { e.ResultSource.SetResult("Node A Result"); }
static void Main() { WindowHeight = 16; WindowWidth = 32; var rasgele = new Random(); var skor = 0; int eniyiskor = 0; var hiz = 400; Title = Convert.ToString("Müthiş Yılan Oyunu"); var bas = new Piksel(WindowWidth / 2, WindowHeight / 2, ConsoleColor.Red); var kenarlar = new Piksel(rasgele.Next(1, WindowWidth - 10), rasgele.Next(1, WindowHeight - 10), ConsoleColor.DarkGray); var ortayer = new List <Piksel>(); var ilkHareket = Yon.Sag; var oyunBittiMi = false; if (File.Exists(tempdosyasi)) { TextReader tr = new StreamReader(tempdosyasi); string a1 = tr.ReadLine(); eniyiskor = Convert.ToInt32(a1); tr.Close(); } else { TextWriter tw = new StreamWriter(tempdosyasi); tw.Close(); } if (eniyiskor <= 25) { hiz = 350; } else if (eniyiskor <= 50) { hiz = 300; } else if (eniyiskor <= 75) { hiz = 250; } else if (eniyiskor <= 100) { hiz = 200; } else if (eniyiskor <= 200) { hiz = 100; } SetCursorPosition(WindowWidth / 5 - 3, WindowHeight / 2 - 2); Write("Kendini hazır hissediyorsan"); SetCursorPosition(WindowWidth / 5 + 3, WindowHeight / 2 + 1); WriteLine("Bir tuşa bas"); ReadKey(); while (true) { Clear(); oyunBittiMi |= (bas.XPoz == WindowWidth - 1 || bas.XPoz == 0 || bas.YPoz == WindowHeight - 1 || bas.YPoz == 0); DuvarCiz(); if (kenarlar.XPoz == bas.XPoz && kenarlar.YPoz == bas.YPoz) { skor++; Title = Convert.ToString($"Skor: {skor}"); kenarlar = new Piksel(rasgele.Next(1, WindowWidth - 10), rasgele.Next(1, WindowHeight - 10), ConsoleColor.DarkGray); } for (int i = 0; i < ortayer.Count; i++) { PikselCiz(ortayer[i]); oyunBittiMi |= (ortayer[i].XPoz == bas.XPoz && ortayer[i].YPoz == bas.YPoz); } if (oyunBittiMi) { break; } PikselCiz(bas); PikselCiz(kenarlar); var sw = Stopwatch.StartNew(); while (sw.ElapsedMilliseconds <= hiz) { ilkHareket = HareketOku(ilkHareket); } ortayer.Add(new Piksel(bas.XPoz, bas.YPoz, ConsoleColor.Green)); switch (ilkHareket) { case Yon.Yukari: bas.YPoz--; break; case Yon.Asagi: bas.YPoz++; break; case Yon.Sol: bas.XPoz--; break; case Yon.Sag: bas.XPoz++; break; } if (ortayer.Count > skor) { ortayer.RemoveAt(0); } } if (skor > eniyiskor) { eniyiskor = skor; TextWriter tw = new StreamWriter(tempdosyasi); tw.WriteLine(eniyiskor); tw.Close(); } Clear(); DuvarCiz(); SetCursorPosition(WindowWidth / 5 + 1, WindowHeight / 2 - 2); WriteLine($"Oyun bitti, skor: {skor}"); SetCursorPosition(WindowWidth / 5 + 2, WindowHeight / 2); WriteLine($"En yüksek skor: {eniyiskor}"); ReadKey(); }