这个处理图像二值的dll在vb环境中调用正常,但是编译成exe后提示内存只读错误,急用,请帮帮我 ( 积分: 30 )

  • 主题发起人 主题发起人 lxcy
  • 开始时间 开始时间
L

lxcy

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi的dll中函数如下
function BlackWhite():string;stdcall;
var
p: PByteArray;
Gray, x, y: Integer;
Bmp: TBitmap;
begin
if clipboard.HasFormat(cf_bitmap) then
begin
Bmp := TBitmap.Create;
Bmp.Assign(clipboard);
//设置为24位真彩色
Bmp.PixelFormat := pf24Bit;
randomize;
for y := 0 to Bmp.Height - 1 do
begin
p := Bmp.scanline[y];
for x := 0 to Bmp.Width - 1 do
begin
//一个象素点三个字节
Gray := Round(p[x * 3 + 2] * 0.3 + p[x * 3 + 1] * 0.59 + p[x
* 3] * 0.11);
if gray > 128 then //全局阀值128
begin
p[x * 3] := 255;
p[x * 3 + 1] := 255;
p[x * 3 + 2] := 255;
end
else
begin
p[x * 3] := 0;
p[x * 3 + 1] := 0;
p[x * 3 + 2] := 0;
end;
end;
end;

clipboard.Assign(bmp);
Bmp.Free;
end;
end;


vb中声明和调用

情况一:
Private Declare Function BlackWhite Lib "project1.dll" () As String
private command1_click()
clipboard.setdata picture1.image
blackwhite
end sub

这样调用在vb环境中直接提示内存读错误,要确定或取消
情况一:
Private Declare Function BlackWhite Lib "project1.dll" () As String
private command1_click()
clipboard.setdata picture1.image
blackwhite
end sub

这样调用在vb环境中直接提示内存读错误,要确定或取消
情况一:
Private Declare Function BlackWhite Lib "project1.dll" () As String
private sub command1_click()
clipboard.setdata picture1.image
blackwhite
end sub

这样调用在vb环境中直接提示内存读错误,要确定或取消
情况二:
Private Declare Function BlackWhite Lib "project1.dll" (Optional ByRef another As String) As String
private sub command1_click()
clipboard.setdata picture1.image
blackwhite "aa"
end sub
这样调用可以在vb环境中运行,但是编译成exe后又提示内存错误。请问是dll的问题吗?应该怎么解决?急用。。。。谢谢
 
delphi的dll中函数如下
function BlackWhite():string;stdcall;
var
p: PByteArray;
Gray, x, y: Integer;
Bmp: TBitmap;
begin
if clipboard.HasFormat(cf_bitmap) then
begin
Bmp := TBitmap.Create;
Bmp.Assign(clipboard);
//设置为24位真彩色
Bmp.PixelFormat := pf24Bit;
randomize;
for y := 0 to Bmp.Height - 1 do
begin
p := Bmp.scanline[y];
for x := 0 to Bmp.Width - 1 do
begin
//一个象素点三个字节
Gray := Round(p[x * 3 + 2] * 0.3 + p[x * 3 + 1] * 0.59 + p[x
* 3] * 0.11);
if gray > 128 then //全局阀值128
begin
p[x * 3] := 255;
p[x * 3 + 1] := 255;
p[x * 3 + 2] := 255;
end
else
begin
p[x * 3] := 0;
p[x * 3 + 1] := 0;
p[x * 3 + 2] := 0;
end;
end;
end;

clipboard.Assign(bmp);
Bmp.Free;
end;
end;


vb中声明和调用

情况一:
Private Declare Function BlackWhite Lib "project1.dll" () As String
private command1_click()
clipboard.setdata picture1.image
blackwhite
end sub

这样调用在vb环境中直接提示内存读错误,要确定或取消
情况一:
Private Declare Function BlackWhite Lib "project1.dll" () As String
private command1_click()
clipboard.setdata picture1.image
blackwhite
end sub

这样调用在vb环境中直接提示内存读错误,要确定或取消
情况一:
Private Declare Function BlackWhite Lib "project1.dll" () As String
private sub command1_click()
clipboard.setdata picture1.image
blackwhite
end sub

这样调用在vb环境中直接提示内存读错误,要确定或取消
情况二:
Private Declare Function BlackWhite Lib "project1.dll" (Optional ByRef another As String) As String
private sub command1_click()
clipboard.setdata picture1.image
blackwhite "aa"
end sub
这样调用可以在vb环境中运行,但是编译成exe后又提示内存错误。请问是dll的问题吗?应该怎么解决?急用。。。。谢谢
 
Delphi的string和vb的不一样,改成PChar把
 
那为什么没有参数传递时也会出错啊?
 
后退
顶部