Loading a bitmap in FMX in Berlin: you'd think it's easy... you'd be wrong.
Loading a bitmap in FMX in Berlin: you'd think it's easy... you'd be wrong.
This is my code:
procedure TForm1.Button1Click(Sender: TObject);
var Stream : TMemoryStream;
begin
Stream := TMemoryStream.Create;
IdHTTP1.Get( 'https://commons.wikimedia.org/wiki/Category:Clickable_images#/media/File:Crux_and_neighboring_stars.jpeg',Stream);
Stream.Position := 0;
Stream.SaveToFile( 'test.jpeg' );
ImageViewer1.Bitmap.LoadFromFile( 'test.jpeg' );
end;
It says the bitmap can't be loaded.
Anybody knows what I am missing?
These are my included units:
interface section:
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects, IdCoder, IdCoder3to4,
IdCoderMIME, IdHTTP, FMX.Layouts, FMX.ExtCtrls, System.ImageList, FMX.ImgList;
implementation:
uses IdGlobal, FMX.Canvas.D2D, FMX.Platform, FMX.MediaLibrary, System.Messaging;
What am I missing?
Thanks!
A
This is my code:
procedure TForm1.Button1Click(Sender: TObject);
var Stream : TMemoryStream;
begin
Stream := TMemoryStream.Create;
IdHTTP1.Get( 'https://commons.wikimedia.org/wiki/Category:Clickable_images#/media/File:Crux_and_neighboring_stars.jpeg',Stream);
Stream.Position := 0;
Stream.SaveToFile( 'test.jpeg' );
ImageViewer1.Bitmap.LoadFromFile( 'test.jpeg' );
end;
It says the bitmap can't be loaded.
Anybody knows what I am missing?
These are my included units:
interface section:
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects, IdCoder, IdCoder3to4,
IdCoderMIME, IdHTTP, FMX.Layouts, FMX.ExtCtrls, System.ImageList, FMX.ImgList;
implementation:
uses IdGlobal, FMX.Canvas.D2D, FMX.Platform, FMX.MediaLibrary, System.Messaging;
What am I missing?
Thanks!
A
look at the test.jpeg file, it is HTML :)
ReplyDeletethe JPEG URL is upload.wikimedia.org
Good grief. Thanks.
ReplyDeleteDoes FMX include declaration for JPG format or you need to add jpg unit just like as in VCL?
ReplyDeleteHeinz Toskano not even that. It uses the WIC codec on Windows and specific classes for Android/iOS. There'a a codec manager which identifies everything based off the header of the image file.
ReplyDelete