Xojo Conferences
MBSOct2019CologneDE

« MBS Xojo Plugins, ver… | Home | MBS Xojo Plugins, ver… »

CGImageSourceMBS CreateThumbnailMT method for Xojo


Today a client had questions on how to get a lot of thumbnails calculated quickly in Xojo. We do have CGImageSourceMBS class to read various image files and use Apple's image decoders with hardware acceleration, but doing one after the other in Xojo for thousands of image files would still take a long time.

To speed things up, we made a few plugin functions to use preemptive threads to create the thumbnails. You run several Xojo threads and in each process image files and call one of the following methods:

CreateThumbnailMT(file as FolderItem, ImageIndex as integer = 0, Options as dictionary = nil) as CGImageMBS
CreateThumbnailMT(data as String, ImageIndex as integer = 0, Options as dictionary = nil) as CGImageMBS
CreateThumbnailMT(data as MemoryBlock, ImageIndex as integer = 0, Options as dictionary = nil) as CGImageMBS

The main work is done on a preemptive thread, so you can get a lot of CPU cores busy if needed. The returned CGImageMBS objects can be converted to Xojo pictures (Picture method), or you get png or jpeg image data with PNGData or JPEGData methods.

You can pass various options via dictionary to select the thumbnail size or decide whether you like to use thumbnails embedded in images.

Coming soon for next 19.1 prerelease. If you like to try earlier, please email us.

PS: We also add GMConvertMBS class to do the similar things cross platform. You can use it to scale down images for thumbnails with preemptive threads.
08 02 19 - 16:09
two comments

How does the performance compare to using helper apps? What are the advantages / disadvantages? Can you make this more generally useable, eg use preemptive threads for data processing?
Markus - 08 02 19 - 22:29

Well, this runs within your app, so some overhead with launching helper is avoided.
But if it crashes, the whole app crashes.
Christian Schmitz (URL) - 08 02 19 - 22:32


  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.