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 » Image Ctrl How To Add It??? (How to add an Image To My Project In Layer Design? Is It Possible?)
Image Ctrl How To Add It??? [message #52024] Sun, 07 July 2019 11:08 Go to next message
fasasoftware is currently offline  fasasoftware
Messages: 15
Registered: July 2019
Location: Italy
Promising Member
Dear Friends,

I have problems using Image Ctrl....In other words I can't find it in the layer design...After i have added to my project the Controls4U and i have found the StaticImage control...but in the panel layer, i don't know where i should include the image file to display in my form...

Can Sombody Help Me Please?? I'm Newbie...sorry....Best Regards, Lestroso. Embarassed
Re: Image Ctrl How To Add It??? [message #52025 is a reply to message #52024] Sun, 07 July 2019 16:48 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hi Lestroso

With StaticImage, you can use function Set(), in two versions:
- bool StaticImage::Set(String fileName): // You open a bitmap filename
- bool StaticImage::Set(Image image); // You open an Image

You have to do that in the code, for example, in a callback function after pushing a button.


Best regards
Iñaki
Re: Image Ctrl How To Add It??? [message #52026 is a reply to message #52025] Sun, 07 July 2019 18:04 Go to previous messageGo to next message
fasasoftware is currently offline  fasasoftware
Messages: 15
Registered: July 2019
Location: Italy
Promising Member
Dear Koldo,

in other words.... I can't put an image with the layer editor??? i can only place the area of image...

Could you please give me a simple example to replicate it??

I think i'm starting loving this ide!!! It's very Powerful!! I'm using Mac os x 10.13.6 High sierra......

I thank you a lot in advance....Best regards, Lestroso Embarassed

Re: Image Ctrl How To Add It??? [message #52029 is a reply to message #52026] Mon, 08 July 2019 08:58 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hi Lestroso

Here I enclose you a folder with the "Hello World" application changed to load an user selected image. All necessary files are included. The image can be loaded from a file, or embedded inside the executable. Please tell me if you need the last case.
This is the .cpp file:
#include <CtrlLib/CtrlLib.h>
#include <Controls4U/Controls4U.h>

using namespace Upp;

#define LAYOUTFILE <HelloWorldImage/hello.lay>
#include <CtrlCore/lay.h>

class HelloWorld : public WithMainHello<TopWindow> {
	MenuBar menu;
	StatusBar status;

	void FileMenu(Bar& bar);
	void MainMenu(Bar& bar);

public:
	typedef HelloWorld CLASSNAME;

	HelloWorld();
};

void HelloWorld::FileMenu(Bar& bar) {
	bar.Add("Open image", [&] {
		FileSel fs;
		
		String file = SelectFileOpen("Image files\t*.bmp *.png *.jpg *.gif\nAll files\t*.*");
		if (!file.IsEmpty())
			image.Set(file);
	});
	bar.Add("About..", [&] {
		PromptOK("{{1@5 [@9= This is the]::@2 [A5@0 Ultimate`+`+ Hello world sample}}");
	});
		
	bar.Separator();
	bar.Add("Exit", THISBACK(Close));
}

void HelloWorld::MainMenu(Bar& bar) {
	menu.Add("File", THISBACK(FileMenu));
}

HelloWorld::HelloWorld() {
	CtrlLayout(*this, "Hello World");
	Sizeable().Zoomable();
	
	AddFrame(menu);
	AddFrame(status);
	menu.Set(THISBACK(MainMenu));
	status = "Welcome to Hello World !";
}

GUI_APP_MAIN {
	SetLanguage(LNG_ENGLISH);
	HelloWorld().Run();
}


Best regards
Iñaki
Re: Image Ctrl How To Add It??? [message #52031 is a reply to message #52024] Mon, 08 July 2019 15:48 Go to previous messageGo to next message
fasasoftware is currently offline  fasasoftware
Messages: 15
Registered: July 2019
Location: Italy
Promising Member
Dear Koldo!!! THANK you SO MUCH!!! THOUSAND THANKS!! You are a friend!...I'll try to understand from your code!! Best regards,lestroso Laughing
Re: Image Ctrl How To Add It??? [message #52032 is a reply to message #52024] Mon, 08 July 2019 19:03 Go to previous messageGo to next message
fasasoftware is currently offline  fasasoftware
Messages: 15
Registered: July 2019
Location: Italy
Promising Member
DEAR KOLDO,

I have had success with your code...thanks a lot...but could you please if you can....show me how i can insert in my program an image of mine fixed?and include it in the exe??why i can't with layer gui??(in my case in a app??)...

Ultimate++ is very good!! It's True Crossplatform.....i have tried crossing from apple and windows and that's ok!!...In truth i saw ultimate++ many years ago...but it was only for windows...but now there is also for mac....Best Regards,

Lestroso Very Happy
Re: Image Ctrl How To Add It??? [message #52035 is a reply to message #52032] Tue, 09 July 2019 08:23 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hi Lestroso

In Reference/Iml there is a simple example of IMAGEFILE to handle images embedded inside the .exe.
In addition, the Image Tutorial explains a bit about the image designer included in TheIDE. You can edit images or include your own.

After that, you can include this at the beginning:

#define IMAGECLASS MyImages
#define IMAGEFILE  <HelloWorldImage/ImageFile.iml> // ImageFile is the name of your .iml file filled with images
#include <Draw/iml.h>

You can handle the embedded images as any Image type.

Please try this demo, read the help, and try to include this in HelloWorldImage.
If it does not work, I will include it for you, but please try it first on your own.


Best regards
Iñaki
Previous Topic: [SOLVED] Invalid memory access on ImageDraw::Init (X11)
Next Topic: How i can play a sound?? wav,mp3,ogg,aiff????
Goto Forum:
  


Current Time: Thu Mar 28 23:26:29 CET 2024

Total time taken to generate the page: 0.01666 seconds