Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
AllocateImage Property
See Also  Example
Leadtools.Codecs Namespace > CodecsLoadOptions Class : AllocateImage Property



Enables or disables the allocation of memory for the storage of the image data.

Syntax

Visual Basic (Declaration) 
Public Property AllocateImage As Boolean
Visual Basic (Usage)Copy Code
Dim instance As CodecsLoadOptions
Dim value As Boolean
 
instance.AllocateImage = value
 
value = instance.AllocateImage
C# 
public bool AllocateImage {get; set;}
C++/CLI 
public:
property bool AllocateImage {
   bool get();
   void set (bool value);
}

Return Value

true to have Leadtools do the necessary allocation, false to disable it.

Example

Visual BasicCopy Code
Public Sub AllocateImageExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()

   'Setting the loading options.
   'allow LEADTOOLS to allocate the image data
   codecs.Options.Load.AllocateImage = True
   'keeping the loaded image data compressed in memory.
   codecs.Options.Load.Compressed = True
   codecs.Options.Load.DiskMemory = False
   'force a palletized image to be dithered to the LEAD fixed palette.
   codecs.Options.Load.FixedPalette = True
   'we know the format of the file
   codecs.Options.Load.Format = RasterImageFormat.Cmp
   'disable loading metadata markers if present in the file, false to ignore them.
   codecs.Options.Load.Markers = False
   codecs.Options.Load.NoDiskMemory = True
   codecs.Options.Load.NoInterlace = False
   codecs.Options.Load.NoTiledMemory = True
   codecs.Options.Load.Passes = 0
   'ignore the view perspective stored in the file.
   codecs.Options.Load.Rotated = False
   'set negative pixel values to 0.
   codecs.Options.Load.Signed = False
   codecs.Options.Load.InitAlpha = True
   codecs.Options.Load.StoreDataInImage = True
   'load super-compressed in memory
   codecs.Options.Load.SuperCompressed = True
   codecs.Options.Load.TiledMemory = False
   codecs.Options.Load.XResolution = 350
   codecs.Options.Load.YResolution = 350

   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp")

   'Meta file's comments will be saved.
   codecs.Options.Save.Comments = True
   codecs.Options.Save.FixedPalette = True
   codecs.Options.Save.GeoKeys = False
   'Tiff file output will be gray.
   codecs.Options.Save.GrayOutput = True
   'Meta file's markers will be saved.
   codecs.Options.Save.Markers = True
   codecs.Options.Save.MotorolaOrder = False
   codecs.Options.Save.OptimizedPalette = True
   codecs.Options.Save.Password = "LEADTOOLS"

   Dim resolutions As System.Drawing.Size() = New Size(0) {}
   resolutions(0).Width = 350
   resolutions(0).Height = 350

   codecs.Options.Save.SetResolutions(resolutions)
   'Meta file's tags will be saved.
   codecs.Options.Save.Tags = True
   codecs.Options.Save.UseImageDitheringMethod = True

   codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "allocate_image.tif", RasterImageFormat.Tif, 8, 1, image.PageCount, 1, CodecsSavePageMode.Overwrite)

   ' Clean up
   image.Dispose()
   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void AllocateImageExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   //Setting the loading options. 
   //allow LEADTOOLS to allocate the image data 
   codecs.Options.Load.AllocateImage = true; 
   //keeping the loaded image data compressed in memory. 
   codecs.Options.Load.Compressed = true; 
   codecs.Options.Load.DiskMemory = false; 
   //force a palletized image to be dithered to the LEAD fixed palette. 
   codecs.Options.Load.FixedPalette = true; 
   //we know the format of the file 
   codecs.Options.Load.Format = RasterImageFormat.Cmp; 
   //disable loading metadata markers if present in the file, false to ignore them. 
   codecs.Options.Load.Markers = false; 
   codecs.Options.Load.NoDiskMemory = true; 
   codecs.Options.Load.NoInterlace = false; 
   codecs.Options.Load.NoTiledMemory = true; 
   codecs.Options.Load.Passes = 0; 
   //ignore the view perspective stored in the file. 
   codecs.Options.Load.Rotated = false; 
   //set negative pixel values to 0. 
   codecs.Options.Load.Signed = false; 
   codecs.Options.Load.InitAlpha = true; 
   codecs.Options.Load.StoreDataInImage = true; 
   //load super-compressed in memory 
   codecs.Options.Load.SuperCompressed = true; 
   codecs.Options.Load.TiledMemory = false; 
   codecs.Options.Load.XResolution = 350; 
   codecs.Options.Load.YResolution = 350; 
 
   RasterImage image = codecs.Load( LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"); 
 
   //Meta file's comments will be saved. 
   codecs.Options.Save.Comments = true; 
   codecs.Options.Save.FixedPalette = true; 
   codecs.Options.Save.GeoKeys = false; 
   //Tiff file output will be gray. 
   codecs.Options.Save.GrayOutput = true; 
   //Meta file's markers will be saved. 
   codecs.Options.Save.Markers = true; 
   codecs.Options.Save.MotorolaOrder = false; 
   codecs.Options.Save.OptimizedPalette = true; 
   codecs.Options.Save.Password = "LEADTOOLS"; 
 
   System.Drawing.Size[] resolutions = new Size[1]; 
   resolutions[0].Width = 350; 
   resolutions[0].Height = 350; 
 
   codecs.Options.Save.SetResolutions(resolutions); 
   //Meta file's tags will be saved. 
   codecs.Options.Save.Tags = true; 
   codecs.Options.Save.UseImageDitheringMethod = true; 
 
   codecs.Save(image,  LeadtoolsExamples.Common.ImagesPath.Path + "allocate_image.tif", RasterImageFormat.Tif, 8, 1, image.PageCount, 1, CodecsSavePageMode.Overwrite); 
 
   // Clean up 
   image.Dispose(); 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

If you do not allow Leadtools to allocate the memory for the storage of the image data, then you should process the data manually using the RasterCodecs.LoadImage event.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also