Les Modes d’interpolation: Exemple

Author:

Modifier,le,mode,de,composition,d'une,image
{filelink=16675}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;

public class ModeInterpolation : Form {

    protected override void OnPaint(PaintEventArgs e) {
        Text = "Interpolation et redimension";
        Graphics gImage = e.Graphics;
        Bitmap bmp = new Bitmap("find.jpg");
        gImage.FillRectangle(Brushes.Blue, this.ClientRectangle);

        int largeur = bmp.Width;
        int hauteur = bmp.Height;

        gImage.InterpolationMode = InterpolationMode.HighQualityBicubic;
        gImage.DrawImage(
          bmp,
          new Rectangle(10, 10, largeur + 20, hauteur + 20),
          new Rectangle(0, 0, largeur, hauteur),
          GraphicsUnit.Pixel);

        gImage.InterpolationMode = InterpolationMode.NearestNeighbor;
        gImage.DrawImage(
          bmp,
          new Rectangle(50, 50, largeur + 20, hauteur + 20),
          new Rectangle(20, 20, largeur, hauteur),
          GraphicsUnit.Pixel);
    }
    public static void Main() {
        Application.Run(new ModeInterpolation());
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *