←Select platform

IsInverted Property

Summary
Gets a value indicating whether the image is inverted.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public bool IsInverted { get; } 
@property (nonatomic, assign, readonly) BOOL isInverted; 
public boolean isInverted(); 
public: 
property bool IsInverted { 
   bool get(); 
} 
IsInverted # get  (InvertedPageCommand) 

Property Value

true if the image is inverted, otherwise; false.

Remarks

The value of the IsInverted property is updated after the command is run on an image. You can specify whether the command will change the image data or just check for inversion using the Flags property. However, the IsInverted property will always be updated whether or not the image data was changed.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
 
public void InvertedPageCommandExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Get an image 
   string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif"); 
   string invertedImageFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_Inverted.tif"); 
   string nonInvertedImageFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_NonInverted.tif"); 
 
   RasterImage image = codecs.Load(tifFileName); 
 
   // The images should be non-inverted at the beginning, check 
   InvertedPageCommand invertedPage = new InvertedPageCommand(InvertedPageCommandFlags.NoProcess); 
   invertedPage.Run(image); 
   Console.WriteLine("Original image, inverted = {0}", invertedPage.IsInverted); 
 
   // Invert the image 
   InvertCommand invert = new InvertCommand(); 
   invert.Run(image); 
 
   codecs.Save(image, invertedImageFileName, image.OriginalFormat, image.BitsPerPixel); 
 
   // Check again 
   invertedPage.Run(image); 
   Console.WriteLine("After running InvertCommand, inverted = {0}", invertedPage.IsInverted); 
 
   // Now run the command to un-invert the image 
   invertedPage.Flags = InvertedPageCommandFlags.Process; 
   invertedPage.Run(image); 
 
   // Now check the image again 
   invertedPage.Flags = InvertedPageCommandFlags.NoProcess; 
   invertedPage.Run(image); 
   Console.WriteLine("After running InvertedPageCommand, inverted = {0}", invertedPage.IsInverted); 
   codecs.Save(image, nonInvertedImageFileName, image.OriginalFormat, image.BitsPerPixel); 
 
   image.Dispose(); 
 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
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.imageprocessing.color.InvertCommand; 
import leadtools.imageprocessing.core.*; 
 
 
public void invertedPageCommandExample() { 
    final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
 
    // Get an image 
    RasterCodecs codecs = new RasterCodecs(); 
    String tifFileName = combine(LEAD_VARS_IMAGES_DIR, "ocr1.tif"); 
    String invertedImageFileName = combine(LEAD_VARS_IMAGES_DIR, "ocr1_Inverted.tif"); 
    String nonInvertedImageFileName = combine(LEAD_VARS_IMAGES_DIR, "ocr1_NonInverted.tif"); 
    RasterImage image = codecs.load(tifFileName); 
 
    // The images should be non=inverted at the beginning, check 
    InvertedPageCommand invertedPage = new InvertedPageCommand(InvertedPageCommandFlags.NO_PROCESS.getValue()); 
    invertedPage.run(image); 
    System.out.println("Original image, inverted = " + invertedPage.isInverted()); 
 
    // Invert the image 
    InvertCommand invert = new InvertCommand(); 
    invert.run(image); 
    codecs.save(image, invertedImageFileName, image.getOriginalFormat(), image.getBitsPerPixel()); 
 
    System.out.println("Command run and image saved to: " + invertedImageFileName); 
    // Check again 
    invertedPage.run(image); 
    System.out.println("After running InvertCommand, inverted = " + invertedPage.isInverted()); 
 
    // Now run the command to un-invert the iamge 
    invertedPage.setFlags(InvertedPageCommandFlags.PROCESS.getValue()); 
    invertedPage.run(image); 
 
    // Now check the image again 
    invertedPage.setFlags(InvertedPageCommandFlags.NO_PROCESS.getValue()); 
    invertedPage.run(image); 
    System.out.println("After running InvertedPageCommand, inverted = " + invertedPage.isInverted()); 
    codecs.save(image, nonInvertedImageFileName, image.getOriginalFormat(), image.getBitsPerPixel()); 
 
    System.out.println("Command run and image saved to: " + nonInvertedImageFileName); 
    assertTrue(new File(nonInvertedImageFileName).exists()); 
 
    image.dispose(); 
    codecs.dispose(); 
 
} 
Requirements

Target Platforms

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

Leadtools.ImageProcessing.Core Assembly

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