C#是如何处理图片的大小的。

hongxin125 2004-09-25 07:23:51
我想把一个128*128大小的gif或jpg图片改成150*100的大小。图片要求变型但不能截断改变图片的完整性,改变后另存为一个同类性的文件,gif改变后还市动画。谁有实现方法,最好有过程,我不太会C#。一定给分。
...全文
264 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
nnfzj 2004-09-26
  • 打赏
  • 举报
回复

这个问题挺难,你得对GIF文件的格式非常清楚才行!
hongxin125 2004-09-25
  • 打赏
  • 举报
回复
是可以了,我做的gif不是动画了。谁有法。不知道 windinwing(潇笑) ( ) 信誉:72 2004-09-25 19:38:00 得分: 0

可不可以的。我不太明白。请给讲一下好吗?
hongxin125 2004-09-25
  • 打赏
  • 举报
回复
Bitmap map=new Bitmap(Server.MapPath("./upimg/102935.gif"));
Bitmap map1=(Bitmap) map.GetThumbnailImage(100,150,null,IntPtr.Zero);
try
{
map1.Save("c:\\0.gif",System.Drawing.Imaging.ImageFormat.Gif);
}
catch(Exception ex)
{
error1.InnerHtml=ex.Message;
}
BearRui 2004-09-25
  • 打赏
  • 举报
回复
try:

Image img=Image.FromFile(@"g:\图片\ffx203.jpg");
Bitmap bmp=new Bitmap(img,150,150);
bmp.Save(@"c:\123.jpg")
windinwing 2004-09-25
  • 打赏
  • 举报
回复
System.IO.FileStream newFile= new System.IO.FileStream(_SavePath + sFilename, System.IO.FileMode.Create);
newFile.Write(myData,0, myData.Length);
newFile.Close();
this.m_BigImgName=sFilename;

if(!flag)
{
m_Err=1;
return;
}
string SmallImgPath=_SavePath+"small\\";
if(!System.IO.Directory.Exists(SmallImgPath))
System.IO.Directory.CreateDirectory(SmallImgPath);
System.Drawing.Image.GetThumbnailImageAbort myCallBack =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap myBitmap;
try
{
myBitmap = new Bitmap(_SavePath+ sFilename);


file_append = 0;
string sThumbFile = System.IO.Path.GetFileNameWithoutExtension(m_UpFile.FileName)
+ sThumbExtension + ".gif";
while (System.IO.File.Exists(SmallImgPath + sThumbFile))
{
file_append++;
sThumbFile = System.IO.Path.GetFileNameWithoutExtension(m_UpFile.FileName) +
file_append.ToString() + sThumbExtension + ".gif";
}

// 保存小图片
System.Drawing.Image myThumbnail= myBitmap.GetThumbnailImage(ThumbWidth,
ThumbHeight, myCallBack, IntPtr.Zero);
myThumbnail.Save(SmallImgPath + sThumbFile);

this.m_SmallImgName=sThumbFile;

myThumbnail.Dispose();
myBitmap.Dispose();
}
catch //(ArgumentException errArgument)
{

m_Err=-3;
System.IO.File.Delete(_SavePath + sFilename);
}

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧