/// <summary> /// Transformation en fleur (Bonus (Index = 9)) /// </summary> public void Fleur() { //Validation taille; ImagePaireValidation(); //Création d'une nouvelle image temporaire Bitmap nouvelleBtm = new Bitmap(this.Largeur, this.Hauteur, System.Drawing.Imaging.PixelFormat.Format24bppRgb); BitmapMatricielle imgTn = new BitmapMatricielle(nouvelleBtm); //Parcour chaque pixel de l'image for (int i = 0; i < this.Hauteur / 2; i++) { for (int j = 0; j < this.Largeur / 2; j++) { //Déplacement des pixels pour réussir la transformation (multiplication des images) imgTn[i, j] = this[i * 2, j * 2]; imgTn[i, this.Largeur - 1 - j] = this[i * 2, j * 2 + 1]; imgTn[this.Hauteur - i - 1, j] = this[i * 2 + 1, j * 2]; imgTn[this.Hauteur - i - 1, this.Largeur - j - 1] = this[i * 2 + 1, j * 2 + 1]; } } //Affecte la nouvelle image pour pouvoir être affichée this.ImageBitmap = nouvelleBtm; }
/// <summary> /// Transformation boulanger (Index = 7) /// </summary> public void Boulanger() { //Validation taille; ImagePaireValidation(); //Création d'une nouvelle image temporaire Bitmap nouvelleImage = new Bitmap(this.Largeur * 2, this.Hauteur / 2, System.Drawing.Imaging.PixelFormat.Format24bppRgb); BitmapMatricielle imgTransfo = new BitmapMatricielle(nouvelleImage); //Parcour chaque pixel de l'image for (int j = 0; j < imgTransfo.Largeur; j += 2) { for (int i = 0; i < imgTransfo.Hauteur; i++) { //Déplacement des pixels pour réussir la premiere transformation (élargissement) imgTransfo[i, j] = this[i * 2, j / 2]; imgTransfo[i, j + 1] = this[2 * i + 1, j / 2]; } } //Parcour chaque pixel de l'image for (int i = 0; i < imgTransfo.Hauteur; i++) { for (int j = 0; j < imgTransfo.Largeur / 2; j++) { //Déplacement des pixels pour réussir la deuxieme étape : Déplacement dans la nouvelle image this[i, j] = imgTransfo[i, j]; } } //Parcour chaque pixel de l'image for (int i = imgTransfo.Hauteur - 1; i >= 0; i--) { for (int j = 0; j < imgTransfo.Largeur / 2; j++) { //Déplacement des pixels pour le découpage et l'effet miroir vertical this[(imgTransfo.Hauteur * 2) - (i + 1), j] = imgTransfo[i, (imgTransfo.Largeur - 1) - j]; } } }