Load TGLImage or TGLTexture from stream

237 Views Asked by At

I am using GLScene SVN Snapshot 6432 with Delphi XE2 and it does not seem to be possible load a texture image from a stream.

I have scanned through the documentation and searched the internet but all I can find is the declaration LoadFromFile, no LoadFromStream is present anywhere.

I have looked through the sourcecode as well but I can not find or understand the code which handles the file-loading process either.

Is it possible to somehow load an image-file from a TMemoryStream to a TGLTexture or TGLImage?

EDIT:

I did some more research:

There are indeed LoadFromStream declarations available and they seem to point to the file ApplicationFileIO.pas located in the GLScene Source Directory.

When calling LoadFromStream from TGLImage, for instance, I get the error message "Import for TGLImage to TMemoryStream not available. (C:\GLSeneLibraryPath\Source\ApplicationFileIO.pas, line 348)".

I have tried the following code when getting the message mentioned above:

procedure TtestForm.Button1Click(Sender: TObject);
  var ms: tmemorystream;
      img: tglimage;
begin
  ms:=TMemoryStream.Create;
  img:=TGLImage.Create;

  opd.Execute(Self.Handle);

  ms.LoadFromFile(opd.FileName);
  img.LoadFromStream(ms);

  ms.Free;
  img.Free;
end;

Could it possibly be so that I need to somehow use the ApplicationFileIO.pas unit to get this working?

I have tried including that file in the uses clause everywhere but it does not make a difference.

0

There are 0 best solutions below