调整图像大小的最佳方法是什么? [英] What is the best way to resize an image?

查看:77
本文介绍了调整图像大小的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!


我一直在尝试使用图像。我从这里的精美

人那里学到了很多东西。所以,我还了解到缩略图从一个数码相机看起来很可怕。我知道他们为什么看起来很糟糕那么什么是

调整图像大小的最佳方法。我不太关心尺寸,但我想我想在上传时压缩它。


有什么想法吗?


谢谢!


Rudy

Hello all!

I been trying to get a handle with Images. I have learned alot from the fine
people here. So, I also learned that thumbnail images look terrible taken
from a digital cam. I know why they look bad. So what is the best way to
resize an image. I''m not too concerned about size, but I guess I would like
to compress it on the upload.

Any thoughts?

Thanks!

Rudy

推荐答案

您可以使用大小来调整图像大小GetThumbnailImage方法。

这里有更多信息:
http://msdn.microsoft.com/library/de...ImageTopic.asp


或许你会发现这些自定义函数对我写的有用:


public Image DisplaySize(Bitmap bmp)

{

Response.Write(bmp.Width.ToString());

Response.Write(bmp.Height.ToString());

}


//按比例缩小图像,使得高度和宽度都不比[NewSize]像素高出



公共系统.Drawing.Image ShrinkImage(System.Drawing.Bitmap bmp,int

NewSize)


{


double NewWidth;


double NewHeight;


double ShrinkPercent;


System.Drawing.Image。 GetThumbnailImageAbort myCallback =


new System.Drawing.Image.GetThumbnailImageAbort(Thumbn ailCallback);


if(bmp.Width> bmp.Height)


{


NewWidth = NewSize;


ShrinkPercent =(NewWidth / bmp.Width) * 100;


NewHeight =(ShrinkPercent / 100)* bmp.Height;


}


$


{


NewHeight = NewSize;


ShrinkPercent =(NewHeight / bmp .Height)* 100;


NewWidth =(ShrinkPercent / 100)* bmp.Width;


}

System.Drawing.Image myShrunkenImage =

bmp.GetThumbnailImage((int)NewWidth,(int)NewHeight,myCallback,IntPtr.Zero);


返回n myShrunkenImage;


}


public bool ThumbnailCallback(){return false;}


-

我希望这会有所帮助,

Steve C. Orr,MCSD,MVP
http://SteveOrr.net

" Rudy" <儒** @ discussions.microsoft.com>在消息中写道

news:5E ********************************** @ microsof t.com ...
You can resize the image using the GetThumbnailImage method.
Here''s more info:
http://msdn.microsoft.com/library/de...ImageTopic.asp

Or maybe you''ll find these custom functions useful that I wrote:

public Image DisplaySize(Bitmap bmp)
{
Response.Write(bmp.Width.ToString());
Response.Write(bmp.Height.ToString());
}

//shrink the image proportionately so that neither height nor width is more
than [NewSize] pixels

public System.Drawing.Image ShrinkImage(System.Drawing.Bitmap bmp, int
NewSize)

{

double NewWidth;

double NewHeight;

double ShrinkPercent;

System.Drawing.Image.GetThumbnailImageAbort myCallback =

new System.Drawing.Image.GetThumbnailImageAbort(Thumbn ailCallback);

if (bmp.Width>bmp.Height)

{

NewWidth=NewSize;

ShrinkPercent=(NewWidth/bmp.Width)*100;

NewHeight=(ShrinkPercent/100)*bmp.Height;

}

else

{

NewHeight=NewSize;

ShrinkPercent=(NewHeight/bmp.Height)*100;

NewWidth=(ShrinkPercent/100)*bmp.Width;

}

System.Drawing.Image myShrunkenImage =
bmp.GetThumbnailImage((int)NewWidth,(int)NewHeight ,myCallback,IntPtr.Zero);

return myShrunkenImage;

}

public bool ThumbnailCallback(){return false;}

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Rudy" <Ru**@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
大家好!

我一直试图搞定图像。我从这里的很好的人那里学到了很多东西。所以,我还了解到缩略图从数码相机看起来很糟糕。我知道他们为什么看起来很糟糕那么什么是
调整图像大小的最佳方法。我不太关心尺寸,但我想我会在上传时压缩它。

有什么想法吗?

谢谢!

Rudy
Hello all!

I been trying to get a handle with Images. I have learned alot from the
fine
people here. So, I also learned that thumbnail images look terrible taken
from a digital cam. I know why they look bad. So what is the best way to
resize an image. I''m not too concerned about size, but I guess I would
like
to compress it on the upload.

Any thoughts?

Thanks!

Rudy



一切都取决于。如果你看看史蒂夫的答案,你会看到一种方法来做它的b $ b。但是,例如,如果您希望在每个缩略图上都有一个缩略图页面和

链接到完整尺寸的图像,那么您可能不想制作

较小的图像,但使用

属性或样式在浏览器中显示较小的图像。实际上,这会预先加载图像,这样当点击

缩略图时,浏览器就会花时间显示已经缓存的图像。


-

HTH,

Kevin Spencer

Microsoft MVP

..Net开发人员

你所寻求的是你得到的东西。


" Rudy" <儒** @ discussions.microsoft.com>在消息中写道

news:5E ********************************** @ microsof t.com ...
It all depends. If you look at Steve''s answer, you will see one way of doing
it. However, if, for example, you want to have a page of thumbnails and
links on each thumbnail to the full-sized image, you may not want to make a
smaller image, but display the image smaller in the browser, using
attributes or style. This, in effect, pre-loads the images, so that when the
thumbnail is clicked on it takes no time for the browser to display the
already-cached image.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Rudy" <Ru**@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
大家好!

我一直试图搞定图像。我从这里的很好的人那里学到了很多东西。所以,我还了解到缩略图从数码相机看起来很糟糕。我知道他们为什么看起来很糟糕那么什么是
调整图像大小的最佳方法。我不太关心尺寸,但我想我会在上传时压缩它。

有什么想法吗?

谢谢!

鲁迪
Hello all!

I been trying to get a handle with Images. I have learned alot from the
fine
people here. So, I also learned that thumbnail images look terrible taken
from a digital cam. I know why they look bad. So what is the best way to
resize an image. I''m not too concerned about size, but I guess I would
like
to compress it on the upload.

Any thoughts?

Thanks!

Rudy



嗨凯文!


你有一个例子吗?我将如何做到这一点?


" Kevin Spencer"写道:
Hi Kevin!

Would you have an example on how I would do that?

"Kevin Spencer" wrote:
这一切都取决于。如果你看看史蒂夫的答案,你会看到一种做法。但是,例如,如果您希望在每个缩略图上都有一个缩略图页面和
链接到完整尺寸的图像,您可能不希望制作一个较小的图像,而是将图像显示得更小在浏览器中,使用
属性或样式。实际上,这会预先加载图像,这样当点击缩略图时,浏览器就会花时间显示已经缓存过的图像。

-
HTH,

Kevin Spencer
微软MVP
..Net开发人员
你所寻求的是什么。

鲁迪 <儒** @ discussions.microsoft.com>在消息中写道
新闻:5E ********************************** @ microsof t.com。 ..
It all depends. If you look at Steve''s answer, you will see one way of doing
it. However, if, for example, you want to have a page of thumbnails and
links on each thumbnail to the full-sized image, you may not want to make a
smaller image, but display the image smaller in the browser, using
attributes or style. This, in effect, pre-loads the images, so that when the
thumbnail is clicked on it takes no time for the browser to display the
already-cached image.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Rudy" <Ru**@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
大家好!

我一直试图搞定图像。我从这里的很好的人那里学到了很多东西。所以,我还了解到缩略图从数码相机看起来很糟糕。我知道他们为什么看起来很糟糕那么什么是
调整图像大小的最佳方法。我不太关心尺寸,但我想我会在上传时压缩它。

有什么想法吗?

谢谢!

鲁迪
Hello all!

I been trying to get a handle with Images. I have learned alot from the
fine
people here. So, I also learned that thumbnail images look terrible taken
from a digital cam. I know why they look bad. So what is the best way to
resize an image. I''m not too concerned about size, but I guess I would
like
to compress it on the upload.

Any thoughts?

Thanks!

Rudy




这篇关于调整图像大小的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆