public static Kep KitomoritMatrix(string tomoritettKep) { Kep kitomoritettMatrix = new Kep(); string[] sorok = tomoritettKep.Trim().Split('\n'); foreach (string sor in sorok) { kitomoritettMatrix.Add(KitomoritSor(sor)); } return(kitomoritettMatrix); }
private void mentesMaskentToolStripMenuItem_Click(object sender, EventArgs e) { if (bitmap != null) { DialogResult result = fajlMento.ShowDialog(); if (result == DialogResult.OK) { string fajlNev = fajlMento.FileName; string kiterjesztes = fajlNev.Split('.').Last(); string tartalom = ""; if (kiterjesztes == "kep") { for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { Color szin = bitmap.GetPixel(x, y); tartalom += szin.R + ":" + szin.G + ":" + szin.B + " "; } tartalom += "\n"; } } else if (kiterjesztes == "tkep") { kep = new Kep(); for (int y = 0; y < bitmap.Height; y++) { kep.Add(new KepSor()); for (int x = 0; x < bitmap.Width; x++) { Color szin = bitmap.GetPixel(x, y); kep[y].Add(Pixel.FromString(szin.R + ":" + szin.G + ":" + szin.B)); } } tartalom = Tomorito.TomoritMatrix(kep); } FajlbaKiir(fajlNev, tartalom); } } }
private void megnyitasToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = fajlMegnyito.ShowDialog(); if (result == DialogResult.OK) { string kepFajl = fajlMegnyito.FileName; string kiterjesztes = kepFajl.Split('.').Last(); StreamReader file = new StreamReader(kepFajl); Kep kep = new Kep(); if (kiterjesztes == "kep") { while (!file.EndOfStream) { KepSor pixelSor = new KepSor(); string sor = file.ReadLine(); string[] pixelek = sor.Trim().Split(' '); foreach (string pixel in pixelek) { pixelSor.Add(Pixel.FromString(pixel)); } kep.Add(pixelSor); } } else if (kiterjesztes == "tkep") { string tomoritett = file.ReadToEnd(); kep = Tomorito.KitomoritMatrix(tomoritett); } file.Close(); kepHelye.Image = KepBetolt(kep); } }