• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Loading an image and rendering to specified size

Started by cabbott, 5 October 2009, 13:10:56

Previous topic - Next topic

cabbott

I am running a threaded app that is loading JPG images and then rescaling them to 32x32.

Obviously this is resulting in each image being loaded, rendered to a Bitmap at full size, then resized back to 32x32.  All of which inhales memory like it's going out of fashion because I am running 8 threads!

Is there any way of loading a JPG image and rendering it directly to a specified size, thus avoiding the huge memory overhead rendering a full size Bitmap first?

I am using other image types as well, but lets concentrate on JPG to start with!

PS. Thanks for a very comprehensive imaging library.

Galfar

Sorry for late reply, GMail started to throw notifications from this forum to spam bin for some reason  >:(

When you mention "Bitmap", you don't mean converting to TBitmap right?

There's currently no direct way of doing what you want, you'd have to
modify ImagingJpeg.pas unit:
1) JpegLib used by Imaging to load Jpegs is able to return scaled images (but I think it only scales with retaining the original aspect ratio).
2) Currently JpegLib is set up to send full scanlines one by one to Imaging. You could modify it to drop some scanlines and resize the ones you want to 32 pixels wide.

cabbott

Thanks for responding.

By Bitmap I mean 24-bit decoded image (R8G8B8).

Yes, I started looking at JpegLib with a view to tweaking it.

This will certainly save me a huge memory and time overhead rending from JPEG to R8G8B8, then rescaling back to 32x32 R8G8B8. Why mess about with a 30MB image when a 3KB one will do!

If I get anywhere I will let you know, you could include it in a future build - I can't be the only one that wants to avoid wasted CPU time and memory!

Galfar


Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk