主な機能:
1指定された画像のサムネイルを生成します
特定のディレクトリ内のすべての画像サムネイルの2つのバルク生成
3は5つのサムネイルサイズの定義モードを提供します
4現在、.jpg形式のみをサポートしています
ベータ版のダウンロード:http://bjfile.focus.cn/file/15483/728_mjpg.rar
コアコード:
// JPEGのサムネイルを保存します
手順savepic(sourcefilename、descfilename:string);
const
maxwidth = 200;
maxhigth = 200;
var
JPG:tjpegimage;
BMP:tbitmap;
sourcejpg:tjpegimage;
幅、高さ、tmpint:整数;
始める
試す
bmp:= tbitmap.create;
sourcejpg:= tjpegimage.create;
jpg:= tjpegimage.create;
//ソースファイルを読み取ります
sourcejpg.loadfromfile(sourcefilename);
//削減比を計算します
sourcejpg.width> = sourcejpg.heightの場合
tmpint:= round(sourcejpg.width div maxwidth)
それ以外
tmpint:= round(sourcejpg.height div maxhigth);
width:= sourcejpg.width div tmpint;
高さ:= sourcejpg.height div tmpint;
//縮む
bmp.width:= width;
bmp.height:= height;
bmp.pixelformat:= pf24bit;
bmp.canvas.stretchdraw(rect(0,0、width、height)、sourcejpg);
//保存
jpg.Assign(BMP);
jpg.savetofile(descfilename);
ついに
bmp.free;
jpg.free;
sourcejpg.free;
終わり;
終わり;