Picture can not be loaded from raw stream (unknown format)
Original Reporter info from Mantis: JoshyFun @joshyfun
-
Reporter name: José Mejuto
Original Reporter info from Mantis: JoshyFun @joshyfun
- Reporter name: José Mejuto
Description:
There is no way to load a stream (usually TBlobStream) because the stream does not have a name to extract the extension and known the file format to create the reader.
Steps to reproduce:
Link a TDBImage with an TBlobField like in: http://bugs.freepascal.org/view.php?id=12030
If this patch is applied that bug seems trivial to be fixed.
Additional information:
The attached patch create a new TPicture.LoadFromStream(Stream) which uses FPImageHandlers to scan the known formats (skiping some as no proper support in fpc by now) and try to detect the right one.
The patch also add a new:
TPicture.FindGraphicClassWithStreamData(const Stream: TStream; ExceptionOnNotFound: boolean): TGraphicClass;
which mimics the FindGraphicClassWithFileExt but using the binary data in stream instead the "FileExt".
Patch tested only in Win32 but it should work in any platform as the code is not platform specific nor endian specific.
Mantis conversion info:
- Mantis ID: 14698
- OS: Windows
- OS Build: XP SP2
- Build: r21578 FPC 2.3.1
- Platform: i386
- Version: 0.9.29 (SVN)
- Fixed in version: 0.9.29 (SVN)
- Target version: 1.0.0
- LazTarget: 1.0