LoadBrush() with progressive JPEG

Discuss any general programming issues here
Post Reply
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

LoadBrush() with progressive JPEG

Post by Flinx »

While experimenting with the image cache of my music player, I noticed that loading a specific image causes problems. When loading from the local drive it is not very noticeable, but with the low-performance SMB server of my AVM router LoadBrush() takes almost five minutes (tested with Windows and Linux). I had a look with ProcessMonitor and there are about 395000 ReadFile attempts far outside the file size.
Maybe something can be improved there.
Here is a test script

Code: Select all

filename$="p2983.jpg"
If IsPicture(filename$)
	Local id=LoadBrush(Nil,filename$)
	DisplayBrush(id, #CENTER, #CENTER)
EndIf
Wait(300)
The image is here and it's from here (it was imported with MP3Tag).

Ralf
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: LoadBrush() with progressive JPEG

Post by airsoftsoftwair »

Can you test the following on Windows?

Code: Select all

Local id = LoadBrush(Nil, filename$, {Loader = "native"})
This will load the brush through the Windows Imaging Component (WIC) instead of Hollywood's internal image loader. Does it make a difference?
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: LoadBrush() with progressive JPEG

Post by Flinx »

It has a similar effect, but only 265000 ReadFile attempts instead of 395000.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: LoadBrush() with progressive JPEG

Post by airsoftsoftwair »

There's probably not much I can do here because that's just how libjpeg works. Have you tried converting the JPEG to a string using FileToString() and then define a virtual file on that string using DefineVirtualFileFromString() and then loading the image from the virtual file?
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: LoadBrush() with progressive JPEG

Post by Flinx »

Thanks, that helps (although I don't like that this libjpeg doesn't stop reading at the first end-of-file message).
I didn't know DefineVirtualFileFromString() yet, and of course it helps with extracting the cover images from the ID3 tags too.
Post Reply