Leo Priori
Leo Priori

Reputation: 3

c++builder firemonkey Load a image url get 'Loading bitmap failed' error

I found this example and tried to load an image from my localhost:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TMemoryStream *strm = new TMemoryStream;
    IdHTTP1->Get(L"http://192.168.15.10/server/ima.png", strm);
    strm->Position = 0;
    Image1->Bitmap->LoadFromStream(strm);
}

But I´m getting this error:

Project Project1.exe raised exception class EBitmapLoadingFailed with message 'Loading bitmap failed.'

The image (ima.png) is in the correct place, and it opens perfectly when I load it manually in a TImage in the MultiResBitmap options. And it opens perfectly when using Image1->Bitmap->LoadFromFile("c:\\server\\ima.png");

I tried to get other images from the Internet, but get the same error. In fact, I need to load PNG and JPG files from my webserver (online) at runtime using Firemonkey on Android and iOS.

I'm using C++Builder 10.2.1 Tokyo, and would like a C++Builder example. No Delphi please!

Upvotes: 0

Views: 971

Answers (1)

Abu Bany
Abu Bany

Reputation: 1

Add this :

#include <FMX.Platform.hpp>
#include <FMX.MediaLibrary.hpp>
#include <System.Messaging.hpp>

Upvotes: 0

Related Questions