←Select platform

Passes Property

Summary
Gets or sets the number of passes (scans through the image) when loading a progressive image (JPEG mainly).
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int Passes { get; set; } 
@property (nonatomic, assign) NSInteger passes; 
public int getPasses() 
public void setPasses(int value) 
public: 
property int Passes { 
   int get(); 
   void set (    int ); 
} 
Passes # get and set (CodecsLoadOptions) 

Property Value

The number of passes (scans through the image) when loading a progressive image.

Value Description
Any positive number Load a progressive file showing at most the specified number of passes.
0 Load the file in one pass. The default value is 0
-1 Load a progressive file showing only significant scans.
-2 Load a progressive file showing all the scans.
Remarks

This value is also used when loading JBIG files to determine the number of resolutions to load to create a progressive load effect.

This property controls the number of times the RasterCodecs.LoadImage event can be called for a particular row. If you do not use the RasterCodecs.LoadImage event, this value is ignored.The RasterCodecs.LoadImage event can be used to implement a paint while load feature. For progressive files, the event is called several times for the same image row. The quality of the row is improved with every call. The improvements in some passes do not have visual improvements, so it is recommended you show only the significant scans (-1).

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.ImageProcessing.Core; 
 
 
RasterImage image; 
private void Codecs_LoadImage(object sender, CodecsLoadImageEventArgs e) 
{ 
   //copy each row of data into our manually allocated RasterImage 
   image.SetRow(e.Row, e.Buffer.Data, image.BytesPerLine * e.Lines); 
} 
 
public void AllocateImageExample() 
{ 
   string fileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp"); 
   RasterCodecs codecs = new RasterCodecs(); 
   CodecsImageInfo info = codecs.GetInformation(fileName, false); 
   int size = info.Width * info.Height * info.BitsPerPixel; 
   IntPtr data = Marshal.AllocHGlobal(size); 
 
   image = new RasterImage(RasterMemoryFlags.User, info.Width, info.Height, info.BitsPerPixel, RasterByteOrder.Bgr, info.ViewPerspective, null, data, size); 
   image.Access(); 
   //Setting the loading options. 
   //Do NOT allow LEADTOOLS to allocate the image data 
   codecs.Options.Load.AllocateImage = false; // CodecsOptions & CodecsLoadOptions reference 
   codecs.Options.Load.StoreDataInImage = false; 
   //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; 
   //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; 
   //allow loading corrupted images 
   codecs.Options.Load.LoadCorrupted = true; 
 
   codecs.LoadImage += Codecs_LoadImage; 
   codecs.Load(fileName); 
   codecs.LoadImage -= Codecs_LoadImage; 
   image.Release(); 
 
   //Meta file's comments will be saved. 
   //CodecsSaveOptions reference 
   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"; 
 
   LeadSize[] resolutions = new LeadSize[1]; 
   resolutions[0].Width = 350; 
   resolutions[0].Height = 350; 
 
   codecs.Options.Save.GetResolutions(); 
   codecs.Options.Save.SetResolutions(resolutions); 
   codecs.Options.Save.Reset(); 
 
   //Meta file's tags will be saved. 
   codecs.Options.Save.Tags = true; 
   codecs.Options.Save.UseImageDitheringMethod = true; 
 
 
 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "allocate_image.tif"), RasterImageFormat.Tif, 8, 1, image.PageCount, 1, CodecsSavePageMode.Overwrite); 
 
   // Finalize cannot be called directly, it is invoked automatically. 
   // To clean up before exiting, use Dispose 
   image.Dispose(); 
   Marshal.FreeHGlobal(data); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.