Einzelnen Beitrag anzeigen

Rollo62
Online

Registriert seit: 15. Mär 2007
4.116 Beiträge
 
Delphi 12 Athens
 
#6

AW: Datein zur Laufzeit laden

  Alt 25. Aug 2016, 11:44
Versuchs mal damit:

Delphi-Quellcode:
function Bmp_LoadFromStream( const aStrm : TStream;
                              var bmp : TBitmap;
                              const sExt : String) : Int64;
var
  aBCM: TBitmapCodecManager;
  aBMS: TBitmapSurface;

begin
    Result := 0;

    if not Assigned(aStrm) or not Assigned(bmp) then
      Exit;

    aBCM := TBitmapCodecManager.Create;
    aBMS := TBitmapSurface.Create;

    try

      begin

          if aBCM.LoadFromStream( aStrm, aBMS ) then // This is no more reches
          begin
            Result := aStrm.Size; // the Operation was OK so far
          end else
          begin
            Result := 0; // the Operation was NOT OK
          end;

      end;

      if Result > 0 then
      begin // Copy was OK, so do Assign
        bmp.Assign( aBMS );
      end;

    finally
      aBMS.Free;
      aBCM.Free;
    end;

end;
  Mit Zitat antworten Zitat