为什么使用Graphics.ScaleTransform(0.5f,0.5f)可以,而使用:float x = 图象.Image.Size.Width;
Graphics.ScaleTransform(x,x);
却不行?这样也不行:
float x = (float)图象.Image.Size.Width;
Graphics.ScaleTransform(x,x);这样更不行,运行中都停下来报错:
float x = (float)(600/图象.Image.Size.Width);
Graphics.ScaleTransform(x,x);分快没了,高手简单说说就行!
Graphics.ScaleTransform(x,x);
却不行?这样也不行:
float x = (float)图象.Image.Size.Width;
Graphics.ScaleTransform(x,x);这样更不行,运行中都停下来报错:
float x = (float)(600/图象.Image.Size.Width);
Graphics.ScaleTransform(x,x);分快没了,高手简单说说就行!
解决方案 »
- 关于virtual,new ,override
- c#皮肤包的问题!
- 一个C#问题
- c#.net 2005 WEB开发用户控件中去控件的id
- 新建asp.net web应用程序时报“http:/1.1 403 Access Forbidden”错误,直接的帮助里说得不甚清楚,有解决过这个问题的,说具体点么?
- C#中能否引用VBScript中的对象呢!
- C#中怎么将字符串转为double类型呢?
- 请教在WINFORM程序中,如何用代码在一个已经存在的EXCEL文件里,新增一个EXCEL表,并指定表名。。。。非常感谢
- 如果数据被绑定到控件之后,修改控件上的数据会同时修改数据库里的数据吗?
- 平面坐标系排序实现
- 如何调用本地文件夹里的数据库?
- wen.config配置问题
表示缩放后的宽是原来的0.5倍,长也是原来的0.5倍float x = (float)图象.Image.Size.Width;
Graphics.ScaleTransform(x,x);
缩放后的长,宽是原来的x倍,这样新得到的图片长宽太大,假设原来x是100,现在就是10000了,在内存中放不下这么大的图片自然就会报错了
{
if (图象.Image.Size.Height > 600 || 图象.Image.Size.Width > 600)
{
float x = (float)(600 / 图象.Image.Size.Width);
float y = (float)(600 / 图象.Image.Size.Height);
Image magnifyimage = new Bitmap(图象.Image.Size.Width, 图象.Image.Size.Height);
using (Graphics g = Graphics.FromImage(magnifyimage))
{
if (图象.Image.Size.Width > 图象.Image.Size.Height)
{
g.ScaleTransform(x, x);
//g.ScaleTransform(0.1f, 0.1f);
}
else
{
g.ScaleTransform(y, y);
//g.ScaleTransform(0.1f, 0.1f);
}
g.DrawImage(图象.Image, 0, 0);
}
图象.Image = magnifyimage;
}老报错,不知道什么原因.