怎么让一个BITMAP流在IMAGE组件里显示? estStream.Position := 0;imgPlate.Refresh; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 destStream.Position := 0;imgPlate.Picture.Bitmap.LoadFromStream(destStream);imgPlate.Refresh; procedure TForm1.loadPlate;var PTemp: p; destStream:TMemoryStream; IntPlateSize :integer; bmp:Tbitmap; pal: PLogPalette; hpal: HPALETTE; i,j: Integer;begin if not FileExists(ExtractFilePath(picsource) + '\plate.bin') then begin imgPlate.Visible := false; labNoPlate.visible := true; exit; end; //new(PTemp); try try //I := 1000; IntPlateSize := 112*21; PTemp := allocmem(2500); PTemp := pointer(integer(PTemp) + 1000) ; destStream := TMemoryStream.Create; destStream.LoadFromFile(ExtractFilePath(application.ExeName)+'\bmp.bin'); destStream.ReadBuffer(PTemp^,1078); UnpackPlate(ExtractFilePath(picsource) + '\plate.bin',PTemp); destStream.WriteBuffer(PTemp^,IntPlateSize); bmp := TBitmap.Create; bmp.LoadFromStream(destStream); //destStream.SaveToFile (ExtractFilePath(application.ExeName)+'\temp.bmp'); labNoPlate.Visible := false; imgPlate.Visible := true; //imgPlate.Picture.LoadFromFile(ExtractFilePath(application.ExeName) + '\temp.bmp'); //imgPlate.Picture.Bitmap.LoadFromStream(destStream); imgPlate.Picture.Assign(bmp); finally freemem(PTemp); deststream.Free; end; except imgPlate.Visible := false; labNoPlate.Visible := true; freemem(PTemp); destStream.free; end;end;看看罢,destStream里面是一个bitmap的流。我先将bmp头装入流,然后再把解压的数据装入流,最后显示的时候用了一个笨办法,先把流存成文件,然后在显示。我现在要改成直接把流显示在Timage中。怎么做?还有跟这个相关的,其实我已经有了图片数据,但是没有头,怎么给它写上一个头,而不是像我这样从文件中导入头?希望给出完整的代码,我试了几种方法都不行。 呵呵,解决了,代码都在下面:procedure TForm1.loadPlate;var PTemp: p; destStream:TMemoryStream; IntPlateSize :integer; bmp:Tbitmap; pal: PLogPalette; hpal: HPALETTE; i,j: Integer;begin if not FileExists(ExtractFilePath(picsource) + '\plate.bin') then begin imgPlate.Visible := false; labNoPlate.visible := true; exit; end; try try IntPlateSize := 112*21; PTemp := allocmem(2500); //PTemp := pointer(integer(PTemp) + 1000) ; destStream := TMemoryStream.Create; destStream.LoadFromFile(ExtractFilePath(application.ExeName)+'\bmp.bin'); //destStream.ReadBuffer(PTemp^,1078); destStream.Position := 1078; UnpackPlate(ExtractFilePath(picsource) + '\plate.bin',PTemp); destStream.WriteBuffer(PTemp^,IntPlateSize); destStream.Position := 0; //bmp := TBitmap.Create; //bmp.LoadFromStream(destStream); //destStream.SaveToFile (ExtractFilePath(application.ExeName)+'\temp.bmp'); labNoPlate.Visible := false; imgPlate.Visible := true; //imgPlate.Picture.LoadFromFile(ExtractFilePath(application.ExeName) + '\temp.bmp'); imgPlate.Picture.Bitmap := nil; imgPlate.Picture.Bitmap.LoadFromStream(destStream); //imgPlate.Picture.Assign(bmp); imgPlate.Refresh; finally freemem(PTemp); deststream.Free; end; except imgPlate.Visible := false; labNoPlate.Visible := true; freemem(PTemp); destStream.free; end;end; 谁知道采集DirectX游戏视频的方法? 如Fraps 请问怎么把鼠标中键禁止掉? 这个消息为什么会有这样的情况? XPManifest 怎么用啊 字串問題 定义一父类对象,怎样访问它子类所继承的属性。 关于怎么动态设置fastreport的小数位的问题! 任务栏弹出菜单的问题? 可以定义TStringGrid中每一格得输入长度吗? 怎么显示这样的窗体? 如何设置自己进程内的热建比如:Ctrl+Alt+C,必须用hook?或者别的? 怎样得到鼠标敲击控件的handle?
var
PTemp: p;
destStream:TMemoryStream;
IntPlateSize :integer;
bmp:Tbitmap; pal: PLogPalette;
hpal: HPALETTE;
i,j: Integer;
begin
if not FileExists(ExtractFilePath(picsource) + '\plate.bin') then
begin
imgPlate.Visible := false;
labNoPlate.visible := true;
exit;
end;
//new(PTemp);
try
try
//I := 1000;
IntPlateSize := 112*21;
PTemp := allocmem(2500);
PTemp := pointer(integer(PTemp) + 1000) ;
destStream := TMemoryStream.Create;
destStream.LoadFromFile(ExtractFilePath(application.ExeName)+'\bmp.bin');
destStream.ReadBuffer(PTemp^,1078);
UnpackPlate(ExtractFilePath(picsource) + '\plate.bin',PTemp);
destStream.WriteBuffer(PTemp^,IntPlateSize);
bmp := TBitmap.Create;
bmp.LoadFromStream(destStream);
//destStream.SaveToFile (ExtractFilePath(application.ExeName)+'\temp.bmp');
labNoPlate.Visible := false;
imgPlate.Visible := true;
//imgPlate.Picture.LoadFromFile(ExtractFilePath(application.ExeName) + '\temp.bmp');
//imgPlate.Picture.Bitmap.LoadFromStream(destStream);
imgPlate.Picture.Assign(bmp);
finally
freemem(PTemp);
deststream.Free;
end;
except
imgPlate.Visible := false;
labNoPlate.Visible := true;
freemem(PTemp);
destStream.free;
end;
end;看看罢,destStream里面是一个bitmap的流。我先将
bmp头装入流,然后再把解压的数据装入流,最后显示
的时候用了一个笨办法,先把流存成文件,然后在显示。
我现在要改成直接把流显示在Timage中。怎么做?还有跟这个相关的,其实我已经有了图片数据,但是没有
头,怎么给它写上一个头,而不是像我这样从文件中导入
头?希望给出完整的代码,我试了几种方法都不行。
procedure TForm1.loadPlate;
var
PTemp: p;
destStream:TMemoryStream;
IntPlateSize :integer;
bmp:Tbitmap; pal: PLogPalette;
hpal: HPALETTE;
i,j: Integer;
begin
if not FileExists(ExtractFilePath(picsource) + '\plate.bin') then
begin
imgPlate.Visible := false;
labNoPlate.visible := true;
exit;
end;
try
try
IntPlateSize := 112*21;
PTemp := allocmem(2500);
//PTemp := pointer(integer(PTemp) + 1000) ;
destStream := TMemoryStream.Create;
destStream.LoadFromFile(ExtractFilePath(application.ExeName)+'\bmp.bin');
//destStream.ReadBuffer(PTemp^,1078);
destStream.Position := 1078;
UnpackPlate(ExtractFilePath(picsource) + '\plate.bin',PTemp);
destStream.WriteBuffer(PTemp^,IntPlateSize);
destStream.Position := 0;
//bmp := TBitmap.Create;
//bmp.LoadFromStream(destStream);
//destStream.SaveToFile (ExtractFilePath(application.ExeName)+'\temp.bmp');
labNoPlate.Visible := false;
imgPlate.Visible := true;
//imgPlate.Picture.LoadFromFile(ExtractFilePath(application.ExeName) + '\temp.bmp');
imgPlate.Picture.Bitmap := nil;
imgPlate.Picture.Bitmap.LoadFromStream(destStream);
//imgPlate.Picture.Assign(bmp);
imgPlate.Refresh;
finally
freemem(PTemp);
deststream.Free;
end;
except
imgPlate.Visible := false;
labNoPlate.Visible := true;
freemem(PTemp);
destStream.free;
end;
end;