根据一个大图片自动生成相应小图片的代码

我的一个项目中用的

None.gif using  System;
None.gif
using  System.IO;
None.gif
using  System.Drawing;
None.gif
None.gif
namespace  Compoment
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// ImageLib 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class ImageLib
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private string _OrgFileName;
InBlock.gif        
public string OrgFileName
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return(_OrgFileName);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                _OrgFileName
=value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private string _OutFileName;
InBlock.gif        
public string OutFileName
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return(_OutFileName);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                _OutFileName
=value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
public ImageLib()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// TODO: 在此处添加构造函数逻辑
InBlock.gif            
//
ExpandedSubBlockEnd.gif
        }

InBlock.gif
InBlock.gif        
public ImageLib(string InFileName,string OutputFileName)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.OrgFileName=InFileName;
InBlock.gif            
this.OutFileName=OutputFileName;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public void GetSmallPicture(string InFileName,string OutputFileName,int Width)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.OrgFileName=InFileName;
InBlock.gif            
this.OutFileName=OutputFileName;
InBlock.gif            
if(File.Exists(this.OrgFileName))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Image MyImage
=Image.FromFile(this.OrgFileName);
InBlock.gif                Double Diff;
InBlock.gif                Diff
=Convert.ToDouble(Decimal.Divide(MyImage.Height,MyImage.Width));
InBlock.gif                Bitmap ImageOutput
=new Bitmap(MyImage,Width,Convert.ToInt32(Math.Ceiling(Width*Diff)));
InBlock.gif                MyImage.Dispose();
InBlock.gif                ImageOutput.Save(
this.OutFileName,System.Drawing.Imaging.ImageFormat.Jpeg);
InBlock.gif                ImageOutput.Dispose();
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public string GetSmallPicture(int Width)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return("");
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
~ImageLib()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif
ExpandedSubBlockEnd.gif        }
        
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

转载于:https://www.cnblogs.com/Heroman/archive/2004/12/07/74000.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值