|
|
Home » Community » Newbie corner » WebImage example not working (Examples)
WebImage example not working [message #56033] |
Sat, 16 January 2021 23:44 |
dschoni
Messages: 15 Registered: January 2021 Location: Switzerland
|
Promising Member |
|
|
Trying to execute the WebImage example delivers an empty window.
Calling the used URL http: // www.ultimatepp.org / 1i.png delivers nothing in my browser.
Calling http: // www.ultimatepp.org / 0i.png instead delivers a picture, but returns it as https: // www.ultimatepp.org / 0i.png
Using it inside the Webimage example {
img = StreamRaster::LoadStringAny(HttpRequest("https: // www.ultimatepp.org / 0i.png").Execute());
}
delivers nothing as an empty window again.
How can I get a picture?
Most Web-Addresses are https. HTTP seems no longer usable.
Many thanks for help in advance.
Sorry about the empty spaces in the code (links), but I cannot post links ...
|
|
|
Re: WebImage example not working [message #56043 is a reply to message #56033] |
Mon, 18 January 2021 11:27 |
|
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello, to retrieve Image from https website, you must first include "Core/SSL" package to your project, then call the https website
img = StreamRaster::LoadStringAny(HttpRequest("https://www.ultimatepp.org/0i.png").Execute());
The Core/SSL package will allow you to communicate with https website.(you have nothing to do except add the package and use standard HttpRequest)
[Updated on: Mon, 18 January 2021 11:30] Report message to a moderator
|
|
|
|
Re: WebImage example not working [message #56070 is a reply to message #56033] |
Tue, 19 January 2021 23:22 |
|
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Hello Dschoni,
Glad to help ! you don't need to add #include <Core/SSL/SLL.h> . The only thing you need to do is adding the package to your project :
Here is my project without Core/SSL package :
At this point, my following code :
#include <Core/Core.h>
#include <Draw/Draw.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
Image img = StreamRaster::LoadStringAny(HttpRequest("https://www.ultimatepp.org/0i.png").Execute());
}
Will compile and work but my Img wont be loaded because HttpRequest is not performing all SSL requieremet. That's why Core/SSL have been created.
By right clicking to my main package (testimg in my screenshot) and select "Add package to testimg"
I'm able to add Core/SSL to my project :
Since Core/SSL is part of Core (it can be see as kind of plugin) I'm not obligated to include it in my project.
By now, my exemple above will work and download the image.
PS: Also, if you plan on doing more stuff about loading image, or play with several image type, be sure to include all format you need (package plugin/png, plugin/bmp, plugin/gif...) otherwise, the StreamRaster::LoadStringAny(...) wont be able to convert your image data into standard U++ Image
[Updated on: Wed, 20 January 2021 09:20] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat Dec 14 15:01:48 CET 2024
Total time taken to generate the page: 0.03957 seconds
|
|
|