我将我的一个缩放例子给你,你自己看看,改一下即可。要缩小就传Rates小于1,变大就大
于1。
procedure Zoom(Img: TImage;const Rates:single);
var
Bmp :TBitmap;
begin
try
iScaleRate:=Round(Rates*PERCENT);
CboScale.Text:=IntToStr(iScaleRate);
Bmp :=TBitmap.Create;
Bmp.Width :=Round(TifPic.Width*Rates);
Bmp.Height :=Round(TifPic.Height*Rates);
Img.Picture:=nil;
Img.Picture.Bitmap.Assign(TifPic);
StretchBlt(Bmp.Canvas.Handle,0,0,Bmp.Width,Bmp.Height,
Img.Picture.Bitmap.Canvas.Handle,0,0,Img.Picture.Bitmap.Width,Img.Picture.Bitmap.Height,SRCCOPY);
Img.AutoSize :=True;
Img.Picture:=nil;
Img.Picture.Bitmap.Assign(Bmp);
BufferPic.Graphic:=nil;
BufferPic.Bitmap.Assign(Bmp);
Position := Point(0,0);
except
ShowMessage('You scale the picture to large! Out of memory!!');
CboScale.Text:='100';
iScaleRate:=100;
Zoom(Image1,iScaleRate/PERCENT);
end;
Bmp.Free;
end;
转BMP为JPEG就照楼上的来。最好自己动手,不然你直接贴代码记忆不会深刻。要转回来就
反过来写。