分享

delphi实现批量缩略图生成工具开发代码

 quasiceo 2012-12-29

delphi实现批量缩略图生成工具开发代码

作者:5unGUUB8  来源:中国宽带  发布时间:2009-2-6 12:40:08

关键字/核心提示:[标签:副标题]
  主要功能:  1生成指定图片的缩略图  2批量生成某一目录内所有图片缩略图  3提供5中缩略图尺寸定义模式  4目前只支持.jpg格式    测试版下载:http://bjfile.focus.cn/file/15483/728_MJpg.rar    核心代码:    //保存JPEG的缩略图...

  主要功能:

  1生成指定图片的缩略图
  2批量生成某一目录内所有图片缩略图
  3提供5中缩略图尺寸定义模式
  4目前只支持.jpg格式
  
  测试版下载:http://bjfile.focus.cn/file/15483/728_MJpg.rar
  
  核心代码:
  
  //保存JPEG的缩略图
  procedureSavePic(SourceFileName,DescFileName:String);
  const
  MaxWidth=200;
  MaxHigth=200;
  var
  jpg:TJPEGImage;
  bmp:TBitmap;
  SourceJpg:TJPEGImage;
  Width,Height,tmpInt:Integer;
  begin
  try
  bmp:=TBitmap.Create;
  SourceJpg:=TJPEGImage.Create;
  Jpg:=TJPEGImage.Create;
  //读取源文件
  SourceJpg.LoadFromFile(SourceFileName);
  //计算缩小比例
  ifSourceJpg.Width>=SourceJpg.Heightthen
  tmpInt:=Round(SourceJpg.WidthdivMaxWidth)
  else
  tmpInt:=Round(SourceJpg.HeightdivMaxHigth);
  Width:=SourceJpg.WidthdivtmpInt;
  Height:=SourceJpg.HeightdivtmpInt;
  //缩小
  bmp.Width:=Width;
  bmp.Height:=Height;
  bmp.PixelFormat:=pf24bit;
  bmp.Canvas.StretchDraw(Rect(0,0,Width,Height),SourceJpg);
  //保存
  jpg.Assign(bmp);
  jpg.SaveToFile(DescFileName);
  finally
  bmp.Free;
  jpg.Free;
  SourceJpg.Free;
  end;
  end;

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多