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 » some jpgs don't open & slow Stream to Raster
some jpgs don't open & slow Stream to Raster [message #57654] Thu, 11 November 2021 00:31 Go to next message
Mountacir is currently offline  Mountacir
Messages: 45
Registered: November 2021
Member
Hi,

In the process of learning Ultimate++ I'm tying to make a small GUI tool to resize images. I studied the tutorials/examples and search the forum and managed to load the images I want to resize in ColumnList, but I have two problems so far:

1- Some .jpg images don't open even with the ImageView example, but they open fine with the TheIde & the IconDes including its Filesel Preview ( & its WhenIconLazy after i removed the .icon size restriction).

2- The images loading/showing is so slow, I think the bottleneck happens when the Stream is converted back to Image.

The code I come up with:


void imageresizer::openimages(){
	
	if(!fs.ExecuteOpen()) return;

	int fslen = fs.GetCount();

	
	work.Run([=] {

		for(int i =0; i < fslen ; i++) {
			
			String fn = fs[i];

			Image img = StreamRaster::LoadFileAny(fn);			

				GuiLock __;				
				
				if(IsNull(img)) {

					Exclamation(DeQtf(fn) + " not an image.");
					
				}
					
				else {
				
					ClmList.Add(i, img, true);

				}
		}

	});

}



I would appreciate any help or guidance.

Thanks you
Austin2029
Re: some jpgs don't open & slow Stream to Raster [message #57661 is a reply to message #57654] Sun, 14 November 2021 16:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ausin2029 wrote on Thu, 11 November 2021 00:31
Hi,

In the process of learning Ultimate++ I'm tying to make a small GUI tool to resize images. I studied the tutorials/examples and search the forum and managed to load the images I want to resize in ColumnList, but I have two problems so far:

1- Some .jpg images don't open even with the ImageView example, but they open fine with the TheIde & the IconDes including its Filesel Preview ( & its WhenIconLazy after i removed the .icon size restriction).

2- The images loading/showing is so slow, I think the bottleneck happens when the Stream is converted back to Image.

The code I come up with:


void imageresizer::openimages(){
	
	if(!fs.ExecuteOpen()) return;

	int fslen = fs.GetCount();

	
	work.Run([=] {

		for(int i =0; i < fslen ; i++) {
			
			String fn = fs[i];

			Image img = StreamRaster::LoadFileAny(fn);			

				GuiLock __;				
				
				if(IsNull(img)) {

					Exclamation(DeQtf(fn) + " not an image.");
					
				}
					
				else {
				
					ClmList.Add(i, img, true);

				}
		}

	});

}



I would appreciate any help or guidance.

Thanks you
Austin2029


Code seems fine.

Generally, loading especially high resolution .jpgs can be somewhat slow (we are victims of jpg library we are using here). I usually solve the problem with delayed loads / displays (which in general is not trivial to implement).

Can you upload some examples of .jpgs not loading in ImageView?
Re: some jpgs don't open & slow Stream to Raster [message #57662 is a reply to message #57654] Sun, 14 November 2021 20:10 Go to previous messageGo to next message
Mountacir is currently offline  Mountacir
Messages: 45
Registered: November 2021
Member
Hi,

I tried ImageView on (ubuntu-budgie-21.04) and the images I have problem opening on Windows 10 are showing fine (A sample image is attached).

Is it possible to implement some way to take advantage of ThumbCache? I think that would speedup FilesSel icon previews & can be used in applications like what I'm trying to make.

Thank you!
  • Attachment: sample.zip
    (Size: 537.50KB, Downloaded 105 times)
Re: some jpgs don't open & slow Stream to Raster [message #57673 is a reply to message #57654] Tue, 16 November 2021 16:43 Go to previous messageGo to next message
Mountacir is currently offline  Mountacir
Messages: 45
Registered: November 2021
Member
Hi,

I just noticed that those images open With the Code above (Not with ImageView thou) if I put them directly on any drive (C:\sample.jpg) for example. It takes for ever to open just one if it's on any usb drive.

Eidt:

They open if I put them in a drive if I use FileSelNative, they still don't open with FileSel.

[Updated on: Tue, 16 November 2021 16:57]

Report message to a moderator

Re: some jpgs don't open & slow Stream to Raster [message #57674 is a reply to message #57654] Wed, 17 November 2021 03:12 Go to previous messageGo to next message
Mountacir is currently offline  Mountacir
Messages: 45
Registered: November 2021
Member
I just figured out that the problem is the build "CLANG/CLANGx64", I changed it to "MSVS19x64" and now all my images open with my code and ImageView example.
Not sure what's the exact cause, but I'll stick with MSVS19x64 for now.
Re: some jpgs don't open & slow Stream to Raster [message #57676 is a reply to message #57674] Wed, 17 November 2021 10:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ausin2029 wrote on Wed, 17 November 2021 03:12
I just figured out that the problem is the build "CLANG/CLANGx64", I changed it to "MSVS19x64" and now all my images open with my code and ImageView example.
Not sure what's the exact cause, but I'll stick with MSVS19x64 for now.


Thank you.

I have tracked the problem down to the bug in clang64 toolchain (reported here: https://github.com/mstorsjo/llvm-mingw/issues/242)

For now, it is fixed by increasing allocation limit for plugin/jpg. If you do not want to reinstall U++, you can fix that by adding

#define DEFAULT_MAX_MEM 1024*1024*256

at the start of plugin/jpg/lib/jconfig.h
Re: some jpgs don't open & slow Stream to Raster [message #57686 is a reply to message #57676] Thu, 18 November 2021 02:31 Go to previous message
Mountacir is currently offline  Mountacir
Messages: 45
Registered: November 2021
Member
mirek wrote on Wed, 17 November 2021 10:20
Ausin2029 wrote on Wed, 17 November 2021 03:12
I just figured out that the problem is the build "CLANG/CLANGx64", I changed it to "MSVS19x64" and now all my images open with my code and ImageView example.
Not sure what's the exact cause, but I'll stick with MSVS19x64 for now.


Thank you.

I have tracked the problem down to the bug in clang64 toolchain (reported here: https://github.com/mstorsjo/llvm-mingw/issues/242)

For now, it is fixed by increasing allocation limit for plugin/jpg. If you do not want to reinstall U++, you can fix that by adding

#define DEFAULT_MAX_MEM 1024*1024*256

at the start of plugin/jpg/lib/jconfig.h


Thank you very much for the fix, much appreciated!
Previous Topic: How to migrate my old packages to new version U++ in linux
Next Topic: Single tags HTML parser
Goto Forum:
  


Current Time: Tue Apr 16 06:48:06 CEST 2024

Total time taken to generate the page: 0.01937 seconds