我做了个程序是将图片上传到数据库里存放的,现在已经实现了这个功能!但由于有些图片太大,我想将图片缩小后再上传到数据库!(例如将图片缩小到原图的1/8)但我不知道如何将图片缩小!以下是上传图片的代码var
F:TFileStream
beginF:=TFileStream.Create('C:\1.jpg',fmOpenRead);
query.Insert;
TBlobField(queryt1).loadfromstream(F);
query.Post; end;如何将图片缩小到原图的1/8后再上传呢?麻烦各位帮忙看看,小弟万分感谢
F:TFileStream
beginF:=TFileStream.Create('C:\1.jpg',fmOpenRead);
query.Insert;
TBlobField(queryt1).loadfromstream(F);
query.Post; end;如何将图片缩小到原图的1/8后再上传呢?麻烦各位帮忙看看,小弟万分感谢
bmp,backbmp:TBitmap;
begin
backbmp:=TBitmap.Create;
backbmp.Assign(Image1.Picture.Bitmap);
try
bmp:=TBitmap.Create;
bmp.PixelFormat:=pf24bit;
Image1.AutoSize:=True;
bmp.Width:=trunc(0.9*Image1.Width);
bmp.Height:=trunc(0.9*Image1.Height);
//保持最大限度不失真
SetStretchBltMode(bmp.Canvas.Handle,HALFTONE);
StretchBlt(bmp.Canvas.Handle,0,0,bmp.Width,bmp.Height,
backbmp.Canvas.Handle,0,0,backbmp.Width,backbmp.Height,SRCCOPY);
Image1.Picture.Bitmap.Assign(bmp);
Image1.Top:=Self.Height div 2-Image1.Height div 2;
Image1.Left:=Self.Width div 2-Image1.Width div 2;
bmp.PixelFormat:=pf24bit;
Self.Caption:='图象尺寸为:'+IntToStr(Image1.Width)+'*'+IntToStr(Image1.Height);
bmp.Free;
except
end;
backbmp.Free;
backbmp:=nil;
http://www.cnblogs.com/del/archive/2008/07/02/1234229.html