解决图片缩放问题。我这段代码,只能按所选图片的大小截取,虽然图片画布大小改了但是实质上图片并没有进行缩放。怎样让图片的大小改变,不用手工调整图片大小后再截取。
public void SaveScreen(string strPicName)
{
bmp=(Bitmap) this.pbShow.Image; //图片框中所显示的图
bmp1 = new Bitmap(iWidth,iHeight,System.Drawing.Imaging.PixelFormat.Format32bppArgb);
g = Graphics.FromImage(bmp1);
g.DrawImage(bmp,new Rectangle(0,0,iWidth,iHeight),iLeft,iTop,iWidth,iHeight,System.Drawing.GraphicsUnit.Pixel);
bmp1.Save(strSavePath+strPicName,System.Drawing.Imaging.ImageFormat.Jpeg);
}
public void SaveScreen(string strPicName)
{
bmp=(Bitmap) this.pbShow.Image; //图片框中所显示的图
bmp1 = new Bitmap(iWidth,iHeight,System.Drawing.Imaging.PixelFormat.Format32bppArgb);
g = Graphics.FromImage(bmp1);
g.DrawImage(bmp,new Rectangle(0,0,iWidth,iHeight),iLeft,iTop,iWidth,iHeight,System.Drawing.GraphicsUnit.Pixel);
bmp1.Save(strSavePath+strPicName,System.Drawing.Imaging.ImageFormat.Jpeg);
}
function show(chkw)
{
if(chkw>200)
{
chkw=200;
}
else
{
chkw=chkw;
}
return chkw;
}</script>//example <img src="images/teach/opera/01.jpg" onload="this.width=show(this.width)" >