当位图缩放时,它像这样

时间:2018-10-26 07:00:56

标签: c# image-processing bitmap

我在图片框中绘制了一个图像,我需要使用跟踪栏对其进行缩放。但是,只要我按比例放大就会发生这种情况,如果我继续按比例放大,它将变得更加模糊。

enter image description here

我的代码:

图像绘制

public LayerClass ImageDrawing(LayerClass.Type img, Bitmap bm, Rectangle imgRect, String filepath, int angle, PaintEventArgs e)
    {
        bm = ImageClass.GrayscaleImage(bm);
        bm = MakeTransparentImage(bm);

        e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
        bm = RotateImage(bm, angle);
        imgRect = new Rectangle((int)(Shape.center.X - (bm.Width / 2)), (int)(Shape.center.Y - (bm.Height / 2)), (int)bm.Width, (int)bm.Height);
        e.Graphics.DrawRectangle(new Pen(Color.Red, 1), imgRect);
        e.Graphics.DrawImage(bm, imgRect);

        this.imageBitmap = bm;
        this.filePath = filePath;
        this.rotationAngle = angle;
        this.location = location;
        this.imageRect = imgRect;
        return new LayerClass(LayerClass.Type.Image, this, filePath, imgRect);
    }

缩放

    private void trackBar_ScaleImg_Scroll(object sender, EventArgs e)
        {
            //Width Scaling
            if(rb_WidthImage.Checked)
            {
                imgRect.Width = trackBar_ScaleImg.Value;
                imgRect.X = (int)(Shape.center.X - (imgRect.Width / 2));
                lbl_imgWidth.Text = Math.Round((trackBar_ScaleImg.Value * 25.4) / 96).ToString();
                toolTip_Scroll.SetToolTip(trackBar_ScaleImg, lbl_imgWidth.Text);

                ImageBitmap = new Bitmap(ImageBitmap, new Size(imgRect.Width, imgRect.Height));
            }
}

0 个答案:

没有答案