Thema: Delphi JPG zu Bitmap

Einzelnen Beitrag anzeigen

Benutzerbild von qb-tim
qb-tim

Registriert seit: 3. Mär 2006
Ort: Deutschland
280 Beiträge
 
Delphi 6 Professional
 
#3

Re: JPG zu Bitmap

  Alt 11. Jun 2006, 14:54
Hier ist die Lösung:

Delphi-Quellcode:
function DownloadJPGToBitmap(const URL : string; ABitmap: TBitmap): Boolean;
var
  idHttp: TIdHTTP;
  ImgStream: TMemoryStream;
  JpgImage: TJPEGImage;
begin
  Result := False;
  ImgStream := TMemoryStream.Create;
  try
    idHttp := TIdHTTP.Create(nil);
    try
      idHttp.Get(URL, ImgStream);
    finally
      idHttp.Free;
    end;
    ImgStream.Position := 0;
    JpgImage := TJPEGImage.Create;
    try
      JpgImage.LoadFromStream(ImgStream);
      ABitmap.Assign(JpgImage);
    finally
      Result := True;
      JpgImage.Free;
    end;
  finally
    ImgStream.Free;
  end;
end;
  Mit Zitat antworten Zitat