←Select platform

FileName Property

Summary
Gets the name of the file being loaded or saved.
Syntax
C#
C++/CLI
Python
public string FileName { get; } 
public: 
property String^ FileName { 
   String^ get(); 
} 
FileName # get  (CodecsPageEventArgs) 

Property Value

The name of the file being loaded or saved. The default value is null.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
private void Codecs_LoadSavePage(object sender, CodecsPageEventArgs e) 
{ 
   if (e.State == CodecsPageEventState.After) 
      Debug.WriteLine("The image has been processed"); 
   else 
      Debug.WriteLine("The image has not processed yet"); 
 
   if (e.Page > 5) 
      e.Command = CodecsPageEventCommand.Stop; 
 
   Debug.WriteLine("File name is: {0}", e.FileName); 
   if (e.Image != null) 
      Debug.WriteLine("The Image width and height is: {0},{1}", e.Image.Width, e.Image.Height); 
   Debug.WriteLine("Page Index is: {0}", e.Page); 
   Debug.WriteLine("Page Count is: {0}", e.PageCount); 
} 
 
public void LoadPageExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   codecs.LoadPage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
   codecs.SavePage += new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")); 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "loadsave.jpg"), RasterImageFormat.Jpeg, image.BitsPerPixel); 
 
   codecs.LoadPage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
   codecs.SavePage -= new EventHandler<CodecsPageEventArgs>(Codecs_LoadSavePage); 
 
   // Clean up 
   codecs.Dispose(); 
   image.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.*; 
import java.net.*; 
import java.nio.file.Paths; 
import java.util.*; 
import java.time.Instant; 
import java.time.Duration; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.codecs.RasterCodecs.FeedCallbackThunk; 
import leadtools.drawing.internal.*; 
import leadtools.imageprocessing.*; 
import leadtools.imageprocessing.color.ChangeIntensityCommand; 
import leadtools.svg.*; 
 
 
CodecsLoadPageListener codecsLoadPage = new CodecsLoadPageListener() { 
 
   @Override 
   public void onLoadPage(CodecsPageEvent e) { 
      if (e.getState() == CodecsPageEventState.AFTER) 
         System.out.println("The image has been processed"); 
      else 
         System.out.println("The image has not processed yet"); 
 
      if (e.getPage() > 5) 
         e.setCommand(CodecsPageEventCommand.STOP); 
 
      System.out.println("File:"); 
      if (e.getImage() != null) 
         System.out.println( 
               "The Image width and height is: " + e.getImage().getWidth() + "," + e.getImage().getHeight()); 
      System.out.println("Page Index is: " + e.getPage()); 
      System.out.println("Page Count is: " + e.getPageCount()); 
   } 
 
}; 
 
CodecsSavePageListener codecsSavePage = new CodecsSavePageListener() { 
 
   @Override 
   public void onSavePage(CodecsPageEvent e) { 
      if (e.getState() == CodecsPageEventState.AFTER) 
         System.out.println("The image has been processed"); 
      else 
         System.out.println("The image has not processed yet"); 
 
      if (e.getPage() > 5) 
         e.setCommand(CodecsPageEventCommand.STOP); 
 
      System.out.println("File: "); 
      if (e.getImage() != null) 
         System.out.println( 
               "The Image width and height is: " + e.getImage().getWidth() + "," + e.getImage().getHeight()); 
      System.out.println("Page Index is: " + e.getPage()); 
      System.out.println("Page Count is: " + e.getPageCount()); 
   } 
 
}; 
 
public void loadPageExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
 
   codecs.addLoadPageListener(codecsLoadPage); 
   codecs.addSavePageListener(codecsSavePage); 
   RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "Image1.cmp")); 
   String dstFilePath = combine(LEAD_VARS_IMAGES_DIR, "loadsave.jpg"); 
   codecs.save(image, dstFilePath, RasterImageFormat.JPEG, image.getBitsPerPixel()); 
 
   codecs.removeLoadPageListener(codecsLoadPage); 
   codecs.removeSavePageListener(codecsSavePage); 
 
   assertTrue("File unsuccessfully saved to " + dstFilePath, (new File(dstFilePath)).exists()); 
 
   // Clean up 
   codecs.dispose(); 
   image.dispose(); 
} 
Requirements

Target Platforms

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

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