AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

JPG zu Bitmap

Ein Thema von qb-tim · begonnen am 9. Jun 2006 · letzter Beitrag vom 11. Jun 2006
Antwort Antwort
Benutzerbild von qb-tim
qb-tim

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

JPG zu Bitmap

  Alt 9. Jun 2006, 15:32
Hi,

in meinem Programm will ich einen JPG in eine TImage laden:

Delphi-Quellcode:
function DownloadJPGToImage(AURL: String; AImage: TImage): Boolean;
var lGiveback : Boolean;
    lHTTP : TIdHTTP;
    lDstStream: TStream;
    lGraphic : TJPEGImage;
begin
  lHTTP := TIdHTTP.Create(nil);
  lDstStream := TMemoryStream.Create;
  lGraphic := TJPEGImage.Create;
  try
    lHTTP.Get(AURL, lDstStream);
    lDstStream.Position := 0;
    lGraphic.LoadFromStream(lDstStream);
    AImage.Picture.Graphic := lGraphic;
    lGiveback := True;
  except
    lGiveback := False;
  end;
  lGraphic.Free;
  lDstStream.Free;
  lHTTP.Free;
  result := lGiveback;
end;
(Danke an SirThornberry)

Nun will ich die Größe des Bildes verkleiner (NIE vergrößern):

Delphi-Quellcode:
procedure ResizeImage(newWidth, newHeight: integer; Image: TImage);
begin
  Image.Canvas.StretchDraw(Rect(0,0,newWidth,newHeight), Image.Picture.Graphic);
  Image.Picture.Graphic.Width := newWidth;
  Image.Picture.Graphic.Height := newHeight;
end;
Nun sagt Delphi, dass es nur eine Image mit Bitmap ändern kann...

Wie ändere ich jetzt die JPG (schon im Image) in eine "brauchbare" weiße für die ResizeImage-Prozedur?
  Mit Zitat antworten Zitat
Benutzerbild von qb-tim
qb-tim

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

Re: JPG zu Bitmap

  Alt 9. Jun 2006, 17:31
Tut mir leid...

Es hat sich erledigt.

TIPP: Suche nach "JPG Bitmap"
  Mit Zitat antworten Zitat
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
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:31 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz