下面的代码放在主程序中没问题的。 Bitmap2 := TBitmap.Create;
Bitmap2.PixelFormat := Bitmap1.PixelFormat;
Bitmap2.Assign(Bitmap1);但如果放在 dll中,调试时,提示"can not assign a TBitmap to a TBitmap",这是为什么呢?
Bitmap2.PixelFormat := Bitmap1.PixelFormat;
Bitmap2.Assign(Bitmap1);但如果放在 dll中,调试时,提示"can not assign a TBitmap to a TBitmap",这是为什么呢?
uses graphics
找到个例子
这是我写的dll中的代码,完全OK啊。你可以拿去试试。library Project1;
uses
SysUtils,graphics,
Classes; procedure x();stdcall;
var
Bitmap1:Tbitmap;
Bitmap2:Tbitmap;
begin
BitMap1 := TBitMap.Create;
BitMap1.LoadFromFile('c:\1.bmp');
Bitmap2 := TBitmap.Create;
Bitmap2.PixelFormat := Bitmap1.PixelFormat;
Bitmap2.Assign(Bitmap1);
end;
exports x;
{$R *.RES}begin
end.
楼主你应该发代码的,看来的确应该是楼上说的,你的BITmap1和Bitmap2应该是分别在主程序和DLL中。
Classes,
Dialogs,windows,
math,Graphics,Variants; function Sharp(var MyBmp:TBitmap;Threshold:integer):integer;stdcall;
var
x,y:integer;
xx,yy,i:integer;
itemp:integer; newBmp: TBitmap;
p: array[-4..4] of PByteArray;
new_p: PByteArray;
begin
newBmp := TBitmap.Create;
newBmp.PixelFormat := MyBmp.PixelFormat;
newBmp.Assign(MyBmp);以上是我dll的代码,执行到最后一句出错的。
function Sharp(var MyBmp,newBmp:TBitmap;Threshold:integer):integer;stdcall;
先在主程序里把newBmp.Assign(MyBmp);就可以了。
你说的“DLL类型穿透问题”,还不理解。