请问高手如何将尺寸大于800x600的图像调整为800x600的图像显示?(100分)

  • 主题发起人 主题发起人 急人
  • 开始时间 开始时间

急人

Unregistered / Unconfirmed
GUEST, unregistred user!
谢了wql!我想直接显示有如何?既将尺寸大于800x600的图像调整为800x600的图像并显示?
就像Photoshop中进入"图象"中的"图象大小"将大尺寸调整为800x600一样。
 
唉!看来不要200分都不行!

var
_dc:hdc;
_bmp:tbitmap;

procedure tform1.button1click(sender:tobject);
begin
button1.visible:=false;

image1.streach:=true;
image1.left:=0;
image1.top:=0;
image1.height:=600;
image1.width:=800;
form1.left:=0;
form1.top:=0;
form1.height:=600;
form1.width:=800;
image1.picture.loadfromfile('pic>800*600文件名');

_dc:=getwindc(0);
_bmp:=tbitmap.create;
_bmp.width:=800;
_bmp.height:=600;

try
bitblt(_bmp.canvas.handle,0,0,_bmp.width,_bmp.height,_dc,0,0,SRCCOPY);
_bmp.savetofile('c:/pic800_600.bmp');
finally
release(0,_dc);
_bmp.free;
end;
button1.visible:=true;
end;


后面来的人晚了一步!呵呵!
 
有钱吗?
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1575813
看看我以前的回贴,你只要把比例重新调整一下就行了。
把算法改一下,虽然有点烦,但不会失真。
 
有好多软件都支持图片的大小调节呀!象最常用的PHOTOSHOP就是一种!你用用看看吧!
 
canvas.stretchDraw呀!
 
用如下的过程试试, 应该没有问题。 除此之外, 它还可随窗口大小自动缩放图片并且保持
图片比例不变。
procedure TViewForm.FormResize(Sender: TObject);
var i, m, n: integer;
var WinRact, ImageRact : Single;
begin
// ViewSize := ViewSize;
m:= 0; n:= 0;
for i := Low(ViewFactor) to High(Viewfactor) do
begin
if ViewFactor < (Self.ClientWidth / OrgImageWidth) then m := m + 1;
if ViewFactor < (Self.ClientHeight/ orgimageHeight) then n := n + 1;
end;
if m < n then FViewSize := m else FViewSize := n;
if ImageMain.Width > ClientWidth then ImageMain.Width := ClientWidth;
WinRact := (ClientHeight - StatusHeight) / ClientWidth;
ImageRact := OrgImageHeight / OrgImageWidth;
if WinRact <= ImageRact then begin
ImageMain.Height := ClientHeight - StatusHeight;
ImageMain.Width := Round((ClientHeight-StatusHeight) / ImageRact);
ImageMain.Top := 0;
ImageMain.Left := Round((ClientWidth - ImageMain.Width) div 2);
StatusBar1.Panels[2].Text := Format('%d%%',[Round(ImageMain.Height / OrgImageHeight * 100)]);
end;
if WinRact > ImageRact then begin
ImageMain.Width := ClientWidth;
ImageMain.Height := Round(ClientWidth * ImageRact);
ImageMain.Left := 0;
ImageMain.Top := Round((ClientHeight - ImageMain.Height - StatusHeight) div 2);
StatusBar1.Panels[2].Text := Format('%d%%',[Round(ImageMain.Width / OrgImageWidth * 100)]);
end;
if (Width < MIN_FORM_WIDTH) then Width := MIN_FORM_WIDTH;
if (Height < MIN_FORM_HEIGHT) then Height := MIN_FORM_HEIGHT;
if (Width > Screen.DesktopWidth) then Width := Screen.DesktopWidth;
if (Height > Screen.DesktopHeight) then Height := Screen.DesktopWidth;
end;

 
后退
顶部