示例#1
0
        /// <summary>
        /// Bouton qui permet d'appliquer un effet miroir en fonction d'un axe horizontal
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_EffetMiroirHorizontal(object sender, RoutedEventArgs e)
        {
            string nomfichier = this.CheminOrigine;

            try
            {
                Projet_Vincent_Poupet.MyImage imagemiroirhorizontal = new Projet_Vincent_Poupet.MyImage(nomfichier);
                imagemiroirhorizontal.EffetMiroirParRapportAHorizontale();
                imagemiroirhorizontal.EnregistrerImage(this.CheminEnregistrement);
            }
            catch (Exception)
            {
            }
        }
示例#2
0
        public void EffetMiroirParRapportAHorizontale()
        {
            Projet_Vincent_Poupet.MyImage imagetest     = new Projet_Vincent_Poupet.MyImage("coco.bmp");
            Projet_Vincent_Poupet.MyImage imageresultat = new Projet_Vincent_Poupet.MyImage("coco.bmp");

            int milieu;

            if (imageresultat.Hauteur % 2 == 0)
            {
                milieu = imageresultat.Hauteur / 2;
            }
            else
            {
                milieu = (imageresultat.Hauteur - 1) / 2;
            }


            for (int i = 0; i < imageresultat.Largeur; i++)
            {
                for (int j = 0; j < milieu; j++)
                {
                    Projet_Vincent_Poupet.Pixel Clone = new Projet_Vincent_Poupet.Pixel(imageresultat.MatriceDePixels[j, i].rouge, imageresultat.MatriceDePixels[j, i].vert, imageresultat.MatriceDePixels[j, i].bleu);
                    imageresultat.MatriceDePixels[j, i] = imageresultat.MatriceDePixels[imageresultat.Hauteur - j - 1, i];
                    imageresultat.MatriceDePixels[imageresultat.Hauteur - j - 1, i] = Clone;
                }
            }

            imagetest.EffetMiroirParRapportAHorizontale();

            for (int i = 0; i < imagetest.Hauteur; i++)
            {
                for (int j = 0; j < imagetest.Largeur; j++)
                {
                    Assert.AreEqual(imagetest.MatriceDePixels[i, j].rouge, imageresultat.MatriceDePixels[i, j].rouge);
                    Assert.AreEqual(imagetest.MatriceDePixels[i, j].bleu, imageresultat.MatriceDePixels[i, j].bleu);
                    Assert.AreEqual(imagetest.MatriceDePixels[i, j].vert, imageresultat.MatriceDePixels[i, j].vert);
                }
            }
        }