Quote Originally Posted by LP View Post
Thanks for documenting this, but this is really how COM works when you use multi-threading(Main Thread Load Images, not found this error), it doesn't look like something that can be done on PXL's side.
Now,add "CoInitialize" and fixed "ECannotCreateWICImagingFactory". but, If use multi-threading, occasionally report new error "floating point divide by zero at 0x6be7464e". this error break to "FMX.Canvas.D2D.pas":

Code:
class function TBitmapCodecWIC.IsValid(const AStream: TStream): Boolean;
var
  Decoder: IWICBitmapDecoder;
  Frame: IWICBitmapFrameDecode;
  W, H: UINT;
  CopyStream: TMemoryStream;
  Stream: IWICStream;
  SavePosition: Int64;
begin
  W := 0;
  H := 0;
  SavePosition := AStream.Position;
  try
    CopyStream := TMemoryStream.Create;
    try
      CopyStream.CopyFrom(AStream, AStream.Size);


      ImagingFactory.CreateStream(Stream);
      Stream.InitializeFromMemory(CopyStream.Memory, CopyStream.Size);


      ImagingFactory.CreateDecoderFromStream(stream, GUID_NULL, WICDecodeMetadataCacheOnDemand, Decoder);
      if Decoder <> nil then
      begin
        Decoder.GetFrame(0, Frame);
        if Frame <> nil then
          Frame.GetSize(W, H);
      end;
      Result := W * H <> 0;
    finally
      CopyStream.Free;
    end;
  finally
    AStream.Position := SavePosition;
  end;
end;
Stack sequence:
:6be7464e ; C:\Windows\SysWOW64\WindowsCodecs.dll
:6bee8413 ; C:\Windows\SysWOW64\WindowsCodecs.dll
:6bee747f ; C:\Windows\SysWOW64\WindowsCodecs.dll
:6be1a070 ; C:\Windows\SysWOW64\WindowsCodecs.dll
:6be1944e ; C:\Windows\SysWOW64\WindowsCodecs.dll
:6be13f1a ; C:\Windows\SysWOW64\WindowsCodecs.dll
FMX.Canvas.D2D.TBitmapCodecWIC.IsValid($26DB33
FMX.Graphics.TBitmapCodecManager.LoadFromStream(,$C3DB6C0,0)
PXL.FMBridge.TFMBridge.LoadFromStream(nil,'.png',$ 26DB338,$A857720,DontCare)
PXL.ImageFormats.TImageFormatManager.LoadFromStrea m('.png',$26DB338,$A857720,DontCare)
PXL.Images.TAtlasImage.LoadFromStream('.png',$26DB 338,DontCare)
PXL.Images.TAtlasImages.AddFromStream('.png',$26DB 338,'item_e10050',True,DontCare,Unknown)
PXL.Images.TAtlasImages.AddFromFile('.\artres\item _e10050.png','item_e10050',True,DontCare,Unknown)
fol.client.archive.TFOLArchiveManager.loadImages(' .\artres')
fol.client.archive.onLoadGameData