This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, February 18, 2008 4:35:26 AM(UTC)
Groups: Registered
Posts: 3
I have been using the LeadTools RasterImage SDK for a couple of years now. All of the images in my system are stored in multipage TIFFs using LZW compression. Recently our clients have started using larger and larger images. For example, one of our clients managed to create a 137 page 8 bit color 300 DPI full page size image document. When compressed to LZW it takes up about 30 MB of disk space. However, it takes up an exponentially larger amount of RAM when loaded as a RasterImage. Here is a quick sample of the code I use to load the image.
Dim
ms As System.IO.MemoryStream = Nothing
Dim imgRaster As Leadtools.IRasterImage = Nothing
'I retrieve the bytes from the database and load the memory stream with in the method call below
ms = GetMemStreamFromBytes(bytes)
Dim
cod As New Leadtools.Codecs.RasterCodecs
imgRaster = cod.Load(ms,
0, ms.Length)
That's pretty much it. I then use the RasterImage in various ways. When the cod.Load method is called, the memory usage shoots up from about 80Mb to roughly 1.3Gb (quite an increase). Aparently it must be decompressing the image and loading each page as a full bitmap and keeping it in memory. I have read a little bit about using tileing to use disk space instead of memory, but I am not sure how to do this properly. I am looking for a way to either have LeadTools load the page from the given bytes on demand when I say imgRaster.Page = 2, etc. OR to setup the RasterImage to store itself on disk temporarily until I need it. Can you help me decipher the correct LeadTools objects and methods to do this? I am using RasterImage version 14 for dot net.
Thanks,
Ryan
#2
Posted
:
Monday, February 18, 2008 12:31:31 PM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Hello,
You can try setting cod.Options.Load.Compressed = True. That should keep the image compressed in memory. Let me know how that works out.
Thanks.
#3
Posted
:
Tuesday, February 19, 2008 3:10:13 AM(UTC)
Groups: Registered
Posts: 3
I will give compressed a try. However, I am worried about quality degradation. However, according to the LeadTools help file "Compressed images: 1-bit only, using a proprietary RLE compression.", it sounds like compression only works with 1 bit images. I am using both 1-bit images, as well as other images that may be up to 24 bit. It is the higher bitrate images that I am really concerned with. Those are the ones that take up exponentially larger amounts of memory. Ideally I would like to use Tiled Images because according to the documentation "Tiled images: the image is broken into separate tiles. Tiles can be disk or conventional memory." So really if I can get tiled disk memory that will only load one tile at a time into memory as needed, that would solve my problem. The documentation does not really the cover the implementation of this. Can you show me how to do that?
#4
Posted
:
Wednesday, February 20, 2008 9:09:52 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Yes, I can show you that. You just have to set 2 flags for cod.Load.Options. Currently there is a bug with it though. Even if you set it to use Tiled and/or Disk memory, it will still do Conventional memory. You can try it out to confirm it. Use the code below, and check the IsTiled and IsDiskMemory flags of the RasterImage object.
cod.Options.Load.DiskMemory = true;
cod.Options.Load.TiledMemory = true;
Let me know what it says on your system and I can report this to our engineers.
Thanks.
#5
Posted
:
Wednesday, July 28, 2010 5:22:17 PM(UTC)
Groups: Registered
Posts: 3
Hi,
In my case, when I set the following options to true. I receive a System.ArgumentException. both as following:
cod.Options.Load.DiskMemory = true;
cod.Options.Load.TiledMemory = true;
System.ArgumentException: Image is not GDI+ compatible
at Leadtools.Kernel.DisplayMethods.L_ChangeToGdiPlusImage(BitmapHandle pBitmap)
at Leadtools.Kernel.DisplayMethods.L_CreateGdiPlusGraphics(BitmapHandle pBitmap, Int32& nRet)
at Leadtools.RasterImage.CreateGdiPlusGraphics()
How can i resolve this error ?
Thanks!!!
#6
Posted
:
Wednesday, July 28, 2010 9:44:13 PM(UTC)
Groups: Registered
Posts: 3
How can we change the image with DiskMemory = true to a GDI+ compatible image.
#7
Posted
:
Thursday, July 29, 2010 6:44:33 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
The help topic for the TestGdiPlusCompatible Method states that:
For a RasterImage to be compatible with a GDI+ image it needs the following:
- IsConventionalMemory to be true (Tiled, compressed and disk-based images are not supported)
- ... < some other conditions >
The topic is available here:
http://www.leadtools.com/help/leadtools/v17/dh/l/Leadtools~Leadtools.RasterImage~TestGdiPlusCompatible.html
If you set the codecs.Options.Load.NoTiledMemory property to True before loading the
Images, do you get the same exception?
If you don't want to keep the TiledMemory property set to true, try the MakeGdiPlusCompatible method to force your image to become GDI+ compatible.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.