LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating thumbnails / resampling image for DisplayImageFile?

Solved!
Go to solution

Hello All,

 

I was trying to build a panel to show multiple photos (50) for verification (double click to view whole image in separate window) prior to upload for final storage.

 

I need to resample / thumbnail to approximately fit the control so that the memory usage does not go through the roof. These images will be from several cameras and as such the image type may change  - but starting with jpg would go along way.

 

This may be as simple as a missed setting on the uir but I was not able to figure it out. I am not opposed to creating temp thumbnails on the hard drive and clean them away later.

 

Prefer CVI or SDK to ActiveX etc.

 

Thanks in advance,

Greg

0 Kudos
Message 1 of 6
(4,160 Views)
Solution
Accepted by topic author blakney

One possibility you have, which does not make use of any external piece of software, is to actually use a native picture control to resize your images. The trick is to set the picture control to Size image to control, load the picture and call GetCtrlDisplayBitmap to get the fitted bitmap.

I made up a small exmple that let you choose an image and loads it 48 times into small picture controls: it takes less than 4 seconds to load a 300x300 pixels bitmap andmore or less 9 with a 900x1300 pixels png image.

You do not need to actually save thumbnails to disk, but the sample lets you choose  to create files so that you can compare execution time, see the resulting thumbnails on disk and decide what to do in you application.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 6
(4,151 Views)

Very Clever.

 

 I will give it a try and report back.

 

Thanks for the prompt reply.

 

Greg

0 Kudos
Message 3 of 6
(4,146 Views)

Worked like a dream. Thanks again.

 

Greg

0 Kudos
Message 4 of 6
(4,143 Views)

Just another case of ultimate support from Roberto 😉

 

Probably SetCtrlBitmap function was there just to show an alternative.

I commented it without destroying the program requirements.

 

You can also put GetCtrlDisplayBitmap and DiscardBitmap functions inside "if (save)" block.

This may make things quicker if saving is not required.

S. Eren BALCI
IMESTEK
0 Kudos
Message 5 of 6
(4,131 Views)

ebalci wrote: 

Probably SetCtrlBitmap function was there just to show an alternative.

I commented it without destroying the program requirements.


You can also put GetCtrlDisplayBitmap and DiscardBitmap functions inside "if (save)" block.

This may make things quicker if saving is not required.


Well, actually not. SetCtrlBitmap helps reducing memory occupation in the process: on a limited-memory machine, loading several big images can ultimately lead to a Out-of-memory error in DisplayImageFile and in not displaying the image on the panel. Reloading a smaller bitmap in the controls reduces this effect. As an example, on a 1Gb memory machine progressive loading of a 900x650 pixels bmp image generates such error after more or less 40 images loaded. The bigger the image, the fastest this effect will show. Trapping that non-fatal error permits the function to conclude but the images are not loaded to screen.

In that scenario, adding DiscardBitmap has no effect at all, as memory for the image is allocated inside the picture control.

 

...it seems your development machine is much bigger than mine Smiley Wink

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 6
(4,117 Views)