TMemoryStream与BMP的问题
首先将bmp图片SaveToStream(stream);//stream:=TMemoryStream.create;
然后p:=stream.memory; //p:Pointer;
我有一个DLL动态链接库,将p作为参数传入
那么,我的问题是,在dll里边,要处理这幅图片,然而,我不知道函数里边新的
bitmap: TBitmap
怎么把这个p赋值给bitmap??
stream1.memory为只读,不能用~
function transform(p: Pointer): Boolean;
var
bitmap: TBitmap;
Stream: TMemoryStream;
p1: PByteArray;
w: Integer;
i, j: Integer;
iamge1: TImage;
begin
bitmap:=TBitmap.Create;
bitmap.PixelFormat:= pf24bit;
stream:=Tmemorystream.Create;
@stream:=p;
for i := 0 to bitmap.height - 1 do
begin
p1 := Bitmap.scanline[i];
j := 0;
while j < (bitmap.width-1)*3+2 do
begin
w :=(p1[j] * 28 + p1[j+1] * 151 + p1[j+2]*77);
w := w shr 8;
p1[j] := byte(w);
p1[j+1] := p1[j];
p1[j+2] := p1[j];
inc(j, 3);
end;
end;
bitmap.PixelFormat:=pf8bit;
bitmap.SaveToStream(stream);
result:=true;
end;
exports
transform;
end.