主要功能:
1生成指定圖片的縮略圖
2批量生成某一目錄內(nèi)所有圖片縮略圖
3提供5中縮略圖尺寸定義模式
4目前只支持.jpg格式
測(cè)試版下載: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);
//計(jì)算縮小比例
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;
聯(lián)系客服