Page 4 of 5

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 2:45 pm
by wilbert
Keya wrote:confirmed encoder + decoder both working fine in my Windows XP 32, Windows 7 64, Linux Mint 32, Linux Mint 64, and OSX El Capitan 64. Has anyone been able to test on Windows 10? my W10 VM needs a makeover so i cant test atm
Thanks for reporting Keya :D
Nice to know it is working on all those OS versions.
Windows 10 is the Windows version I have so I can confirm it is working fine on Windows 10 as well. :wink:

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 4:28 pm
by VB6_to_PBx

Code: Select all

; Save as jpeg with quality 70
  SaveImage(1, "test_jpg.jpg", #SystemImagePlugin, #SystemImagePlugin_JPEG | 20)
the JPEG Quality setting does not seem to change the actual Quality of the Saved Image or the file size

setting anywhere between 10 to 100 makes no difference ??

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 4:54 pm
by netmaestro
My tests confirm no filesize change between jpeg quality setting 10 vs 100 on Windows 7 x64 with PB 5.5 x86.

May I ask what is the purpose of this approach to SaveImage for the jpeg encoder: [..], #SystemImagePlugin_JPEG | <quality> when the PureBasic SaveImage command has a parameter following imageplugin for flags, which is where PB currently handles its own jpeg quality?

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 6:00 pm
by wilbert
VB6_to_PBx wrote:the JPEG Quality setting does not seem to change the actual Quality of the Saved Image or the file size
I find it difficult sometimes how to convert a C structure to PureBasic, when to use #PB_Structure_AlignC or not.
I made some changes to the structure definitions on Windows. Please test it and let me know if it works now.
netmaestro wrote:May I ask what is the purpose of this approach to SaveImage for the jpeg encoder: [..], #SystemImagePlugin_JPEG | <quality> when the PureBasic SaveImage command has a parameter following imageplugin for flags, which is where PB currently handles its own jpeg quality?
For every encoder plugin you register, you need two functions Encode24 and Encode32 (if you want to support 32 bit as well).
Encoding is almost the same for every image type so instead of registering an individual plugin for every image type, I chose to use one named #SystemImagePlugin .
You put this where you normally specify the plugin like #PB_ImagePlugin_PNG . This leaves only one argument left for the procedure that can be used (Flags) and for JPEG you need to specify both the format and the quality so I had to combine those into one value.

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 6:10 pm
by netmaestro
Ok, thanks for the explanation, I don't see any real downside to doing it that way, the alternative being multiple Use[..] commands. This is clean, compact and quite usable. I like it.
Please test it and let me know if it works now.
On a more somber note: still no difference in jpeg filesize between quality 20 and quality 100.

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 6:19 pm
by wilbert
netmaestro wrote:On a more somber note: still no difference in jpeg filesize between quality 20 and quality 100.
That's strange :?
I tested both x86 and x64 version on Windows 10 and tried 5 different quality settings and all gave a different filesize.
Are you sure you tried the updated code ?

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 7:25 pm
by walbus
A short test v1.52 on Linux Mint x64 and Win10 x64 looking absolutely OK with jpg quality settings

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 8:17 pm
by netmaestro
False alarm here, my test was faulty. A proper test with a suitable image shows significant filesize changes with different qualities. Sorry for the inconvenience.

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Fri Sep 09, 2016 9:13 pm
by wilbert
Thanks for testing.
Good to hear it is working now. :)

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Mon Aug 31, 2020 9:56 am
by PeDe
I used the ImagePlugin from wilbert for a longer time without any problems.
But now I have a problem that I do not understand. When I load an image from a file or from memory that is not in BMP format, the format is not recognized and scaling the image is very slow. With a BMP format I do not have this problem.
When I use the PureBasic decoders everything works normally.

I have provided here an example with test images (200 kB):
https://peter.dreisiebner.at/purebasic/ ... ginPng.zip

I have tested with Windows 7 x64 and PureBasic x86 and x64. I use a slow PC, scaling takes ~ 0.3 seconds.
Does anyone know what the problem could be?

Peter

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Mon Aug 31, 2020 10:42 am
by Saki
On Win 10 I see no negative effect

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Mon Aug 31, 2020 3:19 pm
by PeDe
Saki wrote:On Win 10 I see no negative effect
When you scale the window, you don't have any jerking, you don't see any difference between BMP and PNG/JPG?
Probably your PC is so fast.

Peter

Re: ImagePlugin Modul (Cross-Plattform Multi-Format de-/enco

Posted: Mon Aug 31, 2020 10:05 pm
by Saki
Hi,
i use 4K Resolution.
On Full Desktop-size image all OK.
But on a modern very fast Machine.

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Tue Sep 01, 2020 6:29 am
by wilbert
PeDe wrote:I used the ImagePlugin from wilbert for a longer time without any problems.
But now I have a problem that I do not understand. When I load an image from a file or from memory that is not in BMP format, the format is not recognized and scaling the image is very slow. With a BMP format I do not have this problem.
When I use the PureBasic decoders everything works normally.
Unfortunately I don't have Windows 7 to test with.
The only difference I can think of once the image has been decoded is that the PureBasic JPG and PNG decoders decode to 24 bit and the ImagePlugin module always decodes to 32 bit internally.
What you could try is create a 24 bit image and draw the loaded image to that so you got a 24 bit copy of it but on most computers 32 bit shouldn't be a problem.

If you have a very old PC, the live resize may cause a delay.
When you resize the image the resize event occurs a lot of times. All those events are placed in a queue.
When the drawing procedure can't keep up, it will result in a delay since it still processes all the resize events places in the queue.

Re: ImagePlugin Module (Cross platform multi format de-/enco

Posted: Tue Sep 01, 2020 8:54 am
by PeDe
Thanks wilbert,
your idea with the conversion to 24 bit works. Scaling is again as fast as with the internal decoders.
My graphics card is set to 32 bit, is an integrated Intel HD in a Celeron J1900.

Peter