D
dobug
Unregistered / Unconfirmed
GUEST, unregistred user!
用Gdi+的兄弟帮调试下吧,我实在不知道怎么办了,从Stream中创建TGPBitmap对象,如果文件类型是jpg就一点问题没有,但是是png的话马上报错。
下面的代码是写的一个Demo,实际程序要复杂些,不要建议我用Graphicsex,我只要能从一个MemoryStream中创建一个TGpbitmap就可以了。
var
PicStream:TStream;
StreamAdapter:TStreamAdapter;
FBitmap:TGPBitmap;
g:TGPGraphics;
begin
PicStream:=TMemoryStream.Create;
TMemoryStream(PicStream).LoadFromFile('d:/1/1.png');
PicStream.Seek(0,sobeginning);
StreamAdapter:=TStreamAdapter.Create(PicStream,soReference);
FBitmap:=TGPBitmap.Create(StreamAdapter);
g:=TGPGraphics.Create(self.Canvas.Handle);
g.DrawImage(FBitmap,0,0);
g.Free;
PicStream.Free;
FBitmap.Free;
end;
下面的代码是写的一个Demo,实际程序要复杂些,不要建议我用Graphicsex,我只要能从一个MemoryStream中创建一个TGpbitmap就可以了。
var
PicStream:TStream;
StreamAdapter:TStreamAdapter;
FBitmap:TGPBitmap;
g:TGPGraphics;
begin
PicStream:=TMemoryStream.Create;
TMemoryStream(PicStream).LoadFromFile('d:/1/1.png');
PicStream.Seek(0,sobeginning);
StreamAdapter:=TStreamAdapter.Create(PicStream,soReference);
FBitmap:=TGPBitmap.Create(StreamAdapter);
g:=TGPGraphics.Create(self.Canvas.Handle);
g.DrawImage(FBitmap,0,0);
g.Free;
PicStream.Free;
FBitmap.Free;
end;