Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: HOW TO: Combine image "tiles" into one image using minimal memory
Started by GregR at 12-21-2006 15:35. Topic has 5 replies.

Print Search « Previous Thread Next Thread »
  12-21-2006, 15:35
GregR is not online. Last active: 9/30/2008 12:26:32 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,607
HOW TO: Combine image "tiles" into one image using minimal memory

Attachment: API - v15 - Combine Tiles by Strips.zip
Reply Quote
This sample application shows how to use the LEADTOOLS v15 API to treat and combine four images as "tiles" into a larger image.  In other words, you have four images: 1, 2, 3, 4 which are part of a larger image that should look like this: 12 34 If you can't picture it exactly, take a look at 1.tif, 2.tif, 3.tif, 4.tif, and combined.tif from the attached project to see what your input and output (combined.tif) actually look like.

In the case that these images are very large, such as 5000x5000, the resulting image of 10,000x10,000 would take up a VERY large chunk of memory, around 300MB.  This demo can combine these four images and only use about 5.5 MB of memory because it will load and save the file row by row.

In summary, this will show you how to:
1. Use L_SaveFile with a FILESAVECALLBACK function.
2. Use L_LoadFileTile to create a partial bitmap in memory from a file.  This is what allows you to use minimal memory when loading the files 1, 2, 3, and 4.
3. Use L_GetBitmapRow to copy only a single row of a bitmap into a buffer. 4. Combine and/or create very large images using hardly any memory.

There are some limitations of this sample:
1. It only works with 24bpp images.  If you want this to work on images of a different bpp, then you will need to make sure that they have the combined image you are saving has the same palette as the images you are loading.
2. It only works with four images named 1, 2, 3, and 4, which will get combined as mentioned before.  They must be the same size and file format.  To combine them in a different order or use more images, you will have to change the logic around in the FILESAVECALLBACK.
3. Depending on the file format, it could still take a long time to execute because of how much compression/decompression is needed.  For 5000x5000 Uncompresseed RGB tifs, it took about 45 seconds.  The same images saved as Lossless JPEGs took about 15 minutes.
Greg Ross
LEADTOOLS Technical Support
   Report 
  01-23-2008, 16:24
Sunitha is not online. Last active: 1/23/2008 9:23:10 PM Sunitha

Not Ranked
Joined on 01-23-2008
Posts 1
Re: HOW TO: Combine image "tiles" into one image using minimal memory
Reply Quote
Can this be done fo Jpeg images as well?
   Report 
  01-24-2008, 8:58
GregR is not online. Last active: 9/30/2008 12:26:32 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,607
Re: HOW TO: Combine image "tiles" into one image using minimal memory
Reply Quote
Yes.
Greg Ross
LEADTOOLS Technical Support
   Report 
  07-14-2008, 11:13
jonny is not online. Last active: 7/14/2008 4:02:30 PM jonny

Not Ranked
Joined on 07-14-2008
Posts 5
Re: HOW TO: Combine image "tiles" into one image using minimal memory
Reply Quote
:p,

Is this available in v15 C# APIs?
If it is, it will be a huge help to our application.

-Jonny
   Report 
  07-14-2008, 14:31
GregR is not online. Last active: 9/30/2008 12:26:32 PM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,607
Re: HOW TO: Combine image "tiles" into one image using minimal memory

Attachment: NET - v15 - Combine Tiles by Strips.zip
Reply Quote
Here's a C# version.  This is also hard coded for the four simple TIF images, so you'll need to add some bullet proofing if you intend on using other formats, bpp, image sizes, etc.

In the .NET libraries, you use: RasterCodecs.Save, RasterCodecs.SaveImage event, RasterImage.GetRow, and RasterImage.Load (one of the overloads which takes a Rectangle).

Greg Ross
LEADTOOLS Technical Support
   Report 
  07-14-2008, 14:39
jonny is not online. Last active: 7/14/2008 4:02:30 PM jonny

Not Ranked
Joined on 07-14-2008
Posts 5
Re: HOW TO: Combine image "tiles" into one image using minimal memory
Reply Quote
Wow, that's great!
and thanks for making up the sample in such a short time Greg!

If this could work, we will definitely going to upgrade to V15!



   Report 
Post
LEAD Support Fo... » General » Example Request... » Re: HOW TO: Combine image "tiles" into one image using minimal memory

Powered by Community Server, by Telligent Systems