2

グラフィックライブラリC#を使用して別の画像の上に画像を描画しようとすると、小さい画像が拡大縮小され、最初の画像が覆われます。

  public Form1()
    {   
        //InitializeComponent();
        read_file();
        InitializeComponent1();
        SetStyle(ControlStyles.Opaque, true);
        // theImage = new Bitmap("F:/4th year/1st Term/sensor network/proj/reconstructscene/reconstructscene/images/tryImage.jpg");
        theImage2 = new Bitmap("F:/4th year/1st Term/sensor network/proj/reconstructscene/reconstructscene/images/1.jpg");
        // theImage = new Bitmap(newImage);
        theImage = new Bitmap("F:/4th year/1st Term/sensor network/proj/reconstructscene/reconstructscene/images/tryImage.jpg");
    }
    protected override void OnPaint(PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
        //e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
        //e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; 
          g.DrawImage(theImage, ClientRectangle);
        // Create pen.
        g.FillRectangle(new SolidBrush(Color.Red), 50, 50, 50, 50);
        RectangleF recto = new System.Drawing.RectangleF(50, 50, 50, 50);
        Pen blackPen = new Pen(Color.Black,1);

        g.DrawRectangle(blackPen, 50, 50, 50, 50);
        g.DrawImage(theImage2, ClientRectangle); //this will cover the 1st one
    }
4

2 に答える 2

5

代わりにこれを持ってください:

g.DrawImage(theImage2, 0, 0, theImage2.Width, theImage2.Height);

これにより、画像を引き伸ばさずに「適切な」場所に描画する必要があります。

于 2010-12-29T12:32:30.457 に答える
-1

画像の描画を見てください

DrawStringを使用する必要があります

于 2010-12-29T12:37:50.163 に答える