本文介绍了c#image使用新位图vs绘制图像调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么区别?



位图newImage =新位图(_ currentBitmap,newWidth,newHeight);

返回newImag;



AND



位图animage =新位图(newWidth,newHeight);

使用(Graphics gr = Graphics.FromImage(animage))

{

gr.SmoothingMode = SmoothingMode.HighQuality;

gr.InterpolationMode = InterpolationMode .HighQualityBicubic;

gr.PixelOffsetMode = PixelOffsetMode.HighQuality;

gr.CompositingQuality = CompositingQuality.HighQuality;

gr.DrawImage(_ currentBitmap,new Rectangle(0,0,newWidth,newHeight));

}

返回animage;

what is the difference?

Bitmap newImage = new Bitmap(_currentBitmap, newWidth, newHeight);
return newImag;

AND

Bitmap animage= new Bitmap( newWidth, newHeight);
using (Graphics gr = Graphics.FromImage(animage))
{
gr.SmoothingMode = SmoothingMode.HighQuality;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
gr.CompositingQuality = CompositingQuality.HighQuality;
gr.DrawImage(_currentBitmap, new Rectangle(0, 0, newWidth, newHeight));
}
return animage;

推荐答案

public Bitmap(Image original, int width, int height) : this(width, height) {
            Graphics g = null;
            try {
                g = Graphics.FromImage(this);
                g.Clear(Color.Transparent);
                g.DrawImage(original, 0, 0, width, height);
            }
            finally {
                if (g != null) {
                    g.Dispose();
                }
            }
        }



这篇关于c#image使用新位图vs绘制图像调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 07:44