function bmptobmp(SourceBmpFn,DestBmpFn:string;mulw,mulh:real;w_mm,h_mm:integer):String;
{mulw和mulh分别是宽和高的倍数。 w_mm和h_mm是指定到多少毫米。当如果w_mm和h_mm有数字时,mulw和mulh就失效了。这是我自己写的一个函数,你可以改一下,或是自己看了,不知道我说清楚了}
var
Bmp :TBitmap;
image1:Timage;
i:integer;
begin
result:='';
try
Bmp :=TBitmap.Create;
i:=screen.PixelsPerInch;
image1:=TImage.Create(form);
image1.Picture.Bitmap.LoadFromFile(sourcebmpfn);
try
if (w_mm>0) and (h_mm>0) then
begin
bmp.Width:=round(i*w_mm/25.4);
bmp.height:=round(i*h_mm/25.4);
end
else if (mulw>0) and (mulh>0) then
begin
Bmp.Width :=round(image1.Picture.Bitmap.Width*mulw);
Bmp.Height :=round(image1.Picture.Bitmap.Height*mulh);
end
else
begin
Bmp.Width :=image1.Picture.Bitmap.Width;
Bmp.Height :=image1.Picture.Bitmap.Height;
end;
except
exit;
end;
SetStretchBltMode(Bmp.Canvas.Handle,HalfTone);
StretchBlt(Bmp.Canvas.Handle,0,0,Bmp.Width,Bmp.Height,
Image1.Canvas.Handle,0,0,image1.Picture.Bitmap.Width,image1.Picture.Bitmap.Height,SRCCOPY);
Image1.Picture.Bitmap.Assign(Bmp);
if trim(destbmpfn)='' then
begin
destbmpfn:=copy(sourcebmpfn,1,pos('.',sourcebmpfn)-1)+'_new.bmp';
end;
image1.Picture.SaveToFile(destbmpfn);
result:=destbmpfn;
finally
Bmp.Free;
image1.Free;
end;
end;
{mulw和mulh分别是宽和高的倍数。 w_mm和h_mm是指定到多少毫米。当如果w_mm和h_mm有数字时,mulw和mulh就失效了。这是我自己写的一个函数,你可以改一下,或是自己看了,不知道我说清楚了}
var
Bmp :TBitmap;
image1:Timage;
i:integer;
begin
result:='';
try
Bmp :=TBitmap.Create;
i:=screen.PixelsPerInch;
image1:=TImage.Create(form);
image1.Picture.Bitmap.LoadFromFile(sourcebmpfn);
try
if (w_mm>0) and (h_mm>0) then
begin
bmp.Width:=round(i*w_mm/25.4);
bmp.height:=round(i*h_mm/25.4);
end
else if (mulw>0) and (mulh>0) then
begin
Bmp.Width :=round(image1.Picture.Bitmap.Width*mulw);
Bmp.Height :=round(image1.Picture.Bitmap.Height*mulh);
end
else
begin
Bmp.Width :=image1.Picture.Bitmap.Width;
Bmp.Height :=image1.Picture.Bitmap.Height;
end;
except
exit;
end;
SetStretchBltMode(Bmp.Canvas.Handle,HalfTone);
StretchBlt(Bmp.Canvas.Handle,0,0,Bmp.Width,Bmp.Height,
Image1.Canvas.Handle,0,0,image1.Picture.Bitmap.Width,image1.Picture.Bitmap.Height,SRCCOPY);
Image1.Picture.Bitmap.Assign(Bmp);
if trim(destbmpfn)='' then
begin
destbmpfn:=copy(sourcebmpfn,1,pos('.',sourcebmpfn)-1)+'_new.bmp';
end;
image1.Picture.SaveToFile(destbmpfn);
result:=destbmpfn;
finally
Bmp.Free;
image1.Free;
end;
end;
明天我上班去试试,或许行,那一定该满分。即使不太好,我也一定送分,谢谢。