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 » [SOLVED]How I can put an image in a form like a splash screen?? ([SOLVED]How I can put an image in a form like a splash screen??)
Re: How I can put an image in a form like a splash screen?? [message #52686 is a reply to message #52685] Sun, 10 November 2019 23:16 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello Lestroso,

Welcome to the U++ forums.

There are several ways, but the simplest and IMO most robust way to display static images is using the StreamRaster interface.
U++ is using a "plugin" system to decode registered raster files. By default it can decode and display png and bmp files but
by adding plugin packages (in plugin/ folser) to your application can decode other formats such as jpg too:

Here is an example. An image viewer (png, bmp, jpg)

#include <CtrlLib/CtrlLib.h>

#include <plugin/jpg/jpg.h> // <- Also add plugin/jpg to your package if you want jpg support.

using namespace Upp;

struct ImageViewer : TopWindow {
	Image img;
	void Paint(Draw& w) override
	{
		if(!IsNull(img)) w.DrawImage(0, 0, img);
	}

	ImageViewer()
	{
		Title(t_("Image viewer (Press CTRL + O to open an image file)"));
		Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 640, 200);
	}
	
	bool Key(dword key, int count) override
	{
		if(key == K_CTRL_O) {
			img = StreamRaster::LoadFileAny(SelectFileOpen("*.jpg *.png *.bmp"));
			if(!IsNull(img))
				SetRect(Rect(GetRect().TopLeft(), img.GetSize()));
		}
		return true;
	}
};

GUI_APP_MAIN
{
	ImageViewer().Run();
}




Best regards,
Oblivion


[Updated on: Sun, 10 November 2019 23:17]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to include files .h or .cpp as external library?
Next Topic: How I can load inside Utimate++ RayLib For MacOs And Win?
Goto Forum:
  


Current Time: Sat May 11 07:26:29 CEST 2024

Total time taken to generate the page: 0.01651 seconds