请高手入内! (50分)

  • 主题发起人 主题发起人 ahhlian
  • 开始时间 开始时间
A

ahhlian

Unregistered / Unconfirmed
GUEST, unregistred user!
VB中:
Private Declare Sub out_byte Lib "vbdll.dll" (ByVal port%, ByVal da%) '写一个byte
Private Declare Function in_byte Lib "vbdll.dll" (ByVal port%) As Integer '读一个byte
Function ad2118(channel As Integer) As Integer
Dim h, m, l, da As Integer
out_byte baseadd, channel
delay (100)
out_byte baseadd + 1, 1
delay (500)
h = in_byte(baseadd + 2)
delay (50)
l = Int(in_byte(baseadd + 3) / 16)
da = h * 16 + l
ad2118 = da
End Function

DELPHI中:
procedure out_byte(port,dat:integer);external 'vbdll.dll';
function in_byte(port:integer):integer;external 'vbdll.dll';
Function ad2118(channel:Integer):integer;
var h,l,da:integer;
begin
out_byte(baseadd, channel);
//start
delay(100);
out_byte(baseadd+1, 1);
delay(500);
h:= in_byte(baseadd + 2);
//高位
delay(50);
l:= trunc(in_byte(baseadd+3)/16);
//低位 //end
da:= h*16 +l ;
ad2118:= da ;
end;

这是两段程序,其中BASEADD为常量=H100。该程序在VB中运行正常,但在DELPHI中函数
AD2118无法返回值。我想问题应该在DA:=H*16+L行,但该如何纠正却不知道。奇怪的是,
我屏蔽掉START..END之间的语句即不调用OUT_BYTE和IN_BYTE函数,而直接给H、L赋值,
则运行正常。我想函数声明应该没问题,但问题在哪呢?
 
这样试试:
procedure out_byte(port,dat:integer);external 'vbdll.dll';stdcall;
function in_byte(port:integer):integer;external 'vbdll.dll';stdcall;
 
转图像的:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=696000
http://www.delphibbs.com/delphibbs/dispq.asp?lid=694696
http://www.delphibbs.com/delphibbs/dispq.asp?lid=724648
 
有没有方法将JPEG图象转换成BITMAP图象。
 
uses JPEG;

procedure JPEGtoBMP(FileName:string);
var
jpeg:JPEGImage;
bmp:Bitmap;
begin

jpeg:=JPEGImage.Create;
try
jpeg.LoadFromFile(FileName);
jpeg.CompressionQuality=100;
bmp:=Bitmap.Create;
try
mp.Assign(jpeg);
mp.SaveTofile(ChangeFileExt(FileName,'.bmp'));
finally
mp.free
end;

finally
jpeg.free
end;

end;
 
后退
顶部