通过DLL函数取得图像数据放置Pchar中,如果放到bitmap中的byte中?
var
aDisplay :Pchar;
aCapture1 :Array [0..1234567] Of Byte ;
begin
GetMem(aDisplay,640*480*3+1024*5);
CYUSBCAM_ReadDisplayWindowData(0,0,640,480,aDisplay); // 获得图象数据放置在aDisplay Fwidth :=640;
FHeight :=480;
BitMap :=TBitMap.Create;
BitMap.PixelFormat :=pf24bit;
BitMap.Height :=FHeight;
BitMap.Width :=FWidth; try
for y:=0 to FHeight-1 do
begin
pRGB := BitMap.ScanLine[Y];
for x:=0 to Fwidth-1 do
begin
pRGB^.rgbtRed :=;//R;{如何将Pchar类型的aDisplay往Byte中赋值}
pRGB^.rgbtGreen:=;//G;{如何将Pchar类型的aDisplay往Byte中赋值}
pRGB^.rgbtBlue :=;//B;{如何将Pchar类型的aDisplay往Byte中赋值}
inc(pRGB); {如果aCapture1是Array [0..1234567] Of Byte 如下赋值}
pRGB^.rgbtRed :=aCapture1[(FHeight-1-y)*Fwidth*3+3*x+2];//R;
pRGB^.rgbtGreen:=aCapture1[(FHeight-1-y)*Fwidth*3+3*x+1];//G;
pRGB^.rgbtBlue :=aCapture1[(FHeight-1-y)*Fwidth*3+3*x+0];//B;
inc(pRGB);
end;
end;
canvas.draw(0,0,BitMap);
finally
BitMap.free;
end;
end;
var
aDisplay :Pchar;
aCapture1 :Array [0..1234567] Of Byte ;
begin
GetMem(aDisplay,640*480*3+1024*5);
CYUSBCAM_ReadDisplayWindowData(0,0,640,480,aDisplay); // 获得图象数据放置在aDisplay Fwidth :=640;
FHeight :=480;
BitMap :=TBitMap.Create;
BitMap.PixelFormat :=pf24bit;
BitMap.Height :=FHeight;
BitMap.Width :=FWidth; try
for y:=0 to FHeight-1 do
begin
pRGB := BitMap.ScanLine[Y];
for x:=0 to Fwidth-1 do
begin
pRGB^.rgbtRed :=;//R;{如何将Pchar类型的aDisplay往Byte中赋值}
pRGB^.rgbtGreen:=;//G;{如何将Pchar类型的aDisplay往Byte中赋值}
pRGB^.rgbtBlue :=;//B;{如何将Pchar类型的aDisplay往Byte中赋值}
inc(pRGB); {如果aCapture1是Array [0..1234567] Of Byte 如下赋值}
pRGB^.rgbtRed :=aCapture1[(FHeight-1-y)*Fwidth*3+3*x+2];//R;
pRGB^.rgbtGreen:=aCapture1[(FHeight-1-y)*Fwidth*3+3*x+1];//G;
pRGB^.rgbtBlue :=aCapture1[(FHeight-1-y)*Fwidth*3+3*x+0];//B;
inc(pRGB);
end;
end;
canvas.draw(0,0,BitMap);
finally
BitMap.free;
end;
end;
b:pchar;
a,c:byte;
begin
a:=64;
b:=pchar(a);
c:=byte(b);
showmessage(inttostr(c));
end;
CopyMemory(aCapture1,aCapture,640*480*3+1024*5)就搞定了
ss : PChar;
aa : array of byte;
i : integer;
begin
ss := 'abcd';
i := length(ss); SetLength(aa,4); aa[0] := byte(ss[0]);;
showmessage(VarToStr(aa[0]));end;