Delphi implementation of bulk thumbnail generation tool development code

xiaoxiao2021-03-06  39

The main function:

1 Generate the thumbnail of the specified picture 2 Batch Generate all the images in a directory Thumbnails 3 Provides 5 缩 略 图 Size definition mode 4 Only support .jpg format beta download: http: //bjfile.focus.cn/file/ 15483 / 728_MJpg.rar core code: // save JPEG thumbnails procedure SavePic (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; // read the source file SourceJpg.LoadFromFile (SourceFileName); // calculate the reduction ratio if SourceJpg.Width > = SourceJpg.Height then tmpInt: = Round (SourceJpg.Width div MaxWidth) else tmpInt: = Round (SourceJpg.Height div MaxHigth); Width: = SourceJpg.Width div tmpInt; Height: = SourceJpg.Height div tmpInt; // Reduced bmp.width: = width; bmp.height: = height; bmp.pixelformat: = pf24bit; bmp.canvas.stretchdraw (Rect (0, 10, width, height), sourcejpg); // Save JPG.Assign (BMP ); Jpg.savetofile (descfilename); Finally Bmp.Free; JP G.free; Sourcejpg.Free;

转载请注明原文地址:https://www.9cbs.com/read-78826.html

New Post(0)