Exemple #1
0
        public static KepSor KitomoritSor(string tomoritettSor)
        {
            KepSor kitomoritettSor = new KepSor();

            string[] darabok = tomoritettSor.Trim().Split(' ');
            foreach (string darab in darabok)
            {
                if (darab.Contains("#"))
                {
                    string[] reszek = darab.Split('#');

                    int   db   = Convert.ToInt32(reszek[0]);
                    Pixel elem = Pixel.FromString(reszek[1]);

                    for (int i = 0; i < db; i++)
                    {
                        kitomoritettSor.Add(elem);
                    }
                }
                else
                {
                    kitomoritettSor.Add(Pixel.FromString(darab));
                }
            }

            return(kitomoritettSor);
        }
Exemple #2
0
        // Segédfüggvények
        private static Bitmap KepBetolt(Kep kep)
        {
            int szelesseg = kep.First().Count;
            int magassag  = kep.Count;

            Bitmap vaszon = new Bitmap(szelesseg, magassag);

            for (int y = 0; y < magassag; y++)
            {
                KepSor sor = kep[y];
                for (int x = 0; x < szelesseg; x++)
                {
                    Pixel pixel = kep[y][x];
                    vaszon.SetPixel(x, y, pixel.ToColor());
                }
            }

            return(vaszon);
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        public static string TomoritSor(KepSor sor)
        {
            string tomoritettSor = "";
            int    db            = 0;

            Pixel elozo = new Pixel();

            foreach (Pixel aktualis in sor)
            {
                if (aktualis == elozo)
                {
                    db++;
                }
                else
                {
                    tomoritettSor += TomoritDarab(elozo, db);
                    db             = 1;
                    elozo          = aktualis;
                }
            }
            tomoritettSor += TomoritDarab(elozo, db);

            return(tomoritettSor);
        }