public void AgrandirImageHauteur() { Projet_Vincent_Poupet.MyImage imagetest = new Projet_Vincent_Poupet.MyImage("test.bmp"); Projet_Vincent_Poupet.Pixel[,] matriceimageresultat = new Projet_Vincent_Poupet.Pixel[2 * imagetest.Hauteur, imagetest.Largeur]; for (int i = 0; i < imagetest.Hauteur; i++) { for (int j = 0; j < imagetest.Largeur; j++) { int k = 0; while (k < 2) { matriceimageresultat[i * 2 + k, j] = imagetest.MatriceDePixels[i, j]; k++; } } } imagetest.AgrandirImageHauteur(2); for (int i = 0; i < imagetest.Hauteur; i++) { for (int j = 0; j < imagetest.Largeur; j++) { Assert.AreEqual(imagetest.MatriceDePixels[i, j].rouge, matriceimageresultat[i, j].rouge); Assert.AreEqual(imagetest.MatriceDePixels[i, j].bleu, matriceimageresultat[i, j].bleu); Assert.AreEqual(imagetest.MatriceDePixels[i, j].vert, matriceimageresultat[i, j].vert); } } }
public void Rotation() { Projet_Vincent_Poupet.MyImage imagetest = new Projet_Vincent_Poupet.MyImage("coco.bmp"); Projet_Vincent_Poupet.Pixel[,] matricetournée = new Projet_Vincent_Poupet.Pixel[imagetest.Largeur, imagetest.Hauteur]; for (int j = 0; j < imagetest.Largeur; j++) { for (int i = 0; i < imagetest.Hauteur; i++) { matricetournée[j, imagetest.Hauteur - i - 1] = imagetest.MatriceDePixels[i, j]; } } imagetest.RotationSensTrigo(); for (int i = 0; i < imagetest.Hauteur; i++) { for (int j = 0; j < imagetest.Largeur; j++) { Assert.AreEqual(imagetest.MatriceDePixels[i, j].rouge, matricetournée[i, j].rouge); Assert.AreEqual(imagetest.MatriceDePixels[i, j].bleu, matricetournée[i, j].bleu); Assert.AreEqual(imagetest.MatriceDePixels[i, j].vert, matricetournée[i, j].vert); } } }
public void PixelPassageGris() { Projet_Vincent_Poupet.Pixel pixeltest = new Projet_Vincent_Poupet.Pixel(239, 120, 100); Projet_Vincent_Poupet.Pixel pixelresultat = new Projet_Vincent_Poupet.Pixel(153, 153, 153); pixeltest.PassageGris(); Assert.AreEqual(pixeltest.rouge, pixelresultat.rouge); Assert.AreEqual(pixeltest.bleu, pixelresultat.bleu); Assert.AreEqual(pixeltest.vert, pixelresultat.vert); }
public void PixelPassageNoirEtBlanc() { Projet_Vincent_Poupet.Pixel pixeltest = new Projet_Vincent_Poupet.Pixel(239, 120, 100); Projet_Vincent_Poupet.Pixel pixelresultat = new Projet_Vincent_Poupet.Pixel(255, 255, 255); pixeltest.PassageNoirEtBlanc(); Assert.AreEqual(pixeltest.rouge, pixelresultat.rouge); Assert.AreEqual(pixeltest.bleu, pixelresultat.bleu); Assert.AreEqual(pixeltest.vert, pixelresultat.vert); }
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); } } }