Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » WebImage example not working (Examples)
WebImage example not working [message #56033] Sat, 16 January 2021 23:44 Go to next message
dschoni is currently offline  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 Go to previous messageGo to next message
Xemuth is currently offline  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 #56068 is a reply to message #56043] Tue, 19 January 2021 20:59 Go to previous messageGo to next message
dschoni is currently offline  dschoni
Messages: 15
Registered: January 2021
Location: Switzerland
Promising Member
Hello Xemuth

You gave me something to study ...

First I had to add the Core/SSL package to the Core Package.
Then I had to include the Libs
#include <Core/Core.h>
#include <Core/SSL/SSL.h>

Now with
img = StreamRaster::LoadStringAny(HttpRequest("https://www.ultimatepp.org/0i.png").Execute());
everything works fine.

Thank you very much.
Best Regards

Quote:
The first steps are the hardest ...
Re: WebImage example not working [message #56070 is a reply to message #56033] Tue, 19 January 2021 23:22 Go to previous messageGo to next message
Xemuth is currently offline  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 :
https://i.imgur.com/WajbiaH.png

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"
https://i.imgur.com/xn6NzbZ.png
I'm able to add Core/SSL to my project :
https://i.imgur.com/QWoOUbz.png

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

Re: WebImage example not working [message #56071 is a reply to message #56033] Wed, 20 January 2021 23:53 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
dschoni wrote on Sat, 16 January 2021 23:44
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 ...


Sorry, that example was broken. Now fixed.
Previous Topic: Cross Compiling?
Next Topic: CallbackN<> storing pointer to member function
Goto Forum:
  


Current Time: Wed Apr 24 16:52:34 CEST 2024

Total time taken to generate the page: 0.02483 seconds