ImageGear .NET - Updated
AspectDenominatorX Property (ImGearARTRuler)
Example 




ImageGear24.Art Assembly > ImageGear.ART Namespace > ImGearARTRuler Class : AspectDenominatorX Property
Gets or sets the mark's X aspect denominator value.
Syntax
'Declaration
 
Public Property AspectDenominatorX As Integer
'Usage
 
Dim instance As ImGearARTRuler
Dim value As Integer
 
instance.AspectDenominatorX = value
 
value = instance.AspectDenominatorX
public int AspectDenominatorX {get; set;}
public: __property int get_AspectDenominatorX();
public: __property void set_AspectDenominatorX( 
   int value
);
public:
property int AspectDenominatorX {
   int get();
   void set (    int value);
}

Property Value

Integer value.
Remarks
ART Ruler object is designed to display the distance between 2 points on the image. Point's coordinates are specified in image pixel units, and the Ruler displays the distance measured in these units.

AspectDenominator/AspectNumerator properties help to change measurement units from image pixels to more convenient measurment units like meters or inches.

The default value is 1.
Example
// Setup start and endpoint for the ruler.
ImGearPoint startPoint = new ImGearPoint(10, 10);
ImGearPoint endPoint = new ImGearPoint(igPage.DIB.Width / 2, igPage.DIB.Height / 2);

// Setup color for the ruler.
ImGearRGBQuad color = new ImGearRGBQuad(0, 255, 0);

// Get and initialize image resolution for the ruler.
ImGearResolution imageResolution = new ImGearResolution(
        igPage.DIB.ImageResolution.XNumerator,
        igPage.DIB.ImageResolution.XDenominator,
        igPage.DIB.ImageResolution.YNumerator,
        igPage.DIB.ImageResolution.YDenominator,
        igPage.DIB.ImageResolution.Units);

// Create ruler, note that the ruler is always created with measurement units set to mm
// and it doesn't depend on ImGearResolution measurement units.
ImGearARTRuler ruler = new ImGearARTRuler(startPoint, endPoint, color, imageResolution);

// Let's change measurement units to inches.
imageResolution.ConvertUnits(ImGearResolutionUnits.INCHES);

// Set number of pixels per 1 inch.
ruler.AspectDenominatorX = 1 * (int)Math.Round((double)imageResolution.XNumerator / (double)imageResolution.XDenominator);
ruler.AspectDenominatorY = 1 * (int)Math.Round((double)imageResolution.YNumerator / (double)imageResolution.YDenominator);

// Set 1 inch scale.
ruler.AspectNumeratorX = 1;
ruler.AspectNumeratorY = 1;

ruler.Label = "%d in";

// Now change the measurement units back to the mm.
imageResolution.ConvertUnits(ImGearResolutionUnits.METERS);

// Set number of pixels per 1 meter.
ruler.AspectDenominatorX = 1 * (int)Math.Round((double)imageResolution.XNumerator / (double)imageResolution.XDenominator);
ruler.AspectDenominatorY = 1 * (int)Math.Round((double)imageResolution.YNumerator / (double)imageResolution.YDenominator);

// Set 1 mm scale.
ruler.AspectNumeratorX = 1000;
ruler.AspectNumeratorY = 1000;

ruler.Label = "%d mm";

igARTPage.AddMark(ruler, ImGearARTCoordinatesType.IMAGE_COORD);
' Setup start and endpoint for the ruler.
Dim startPoint As ImGearPoint = New ImGearPoint(10, 10)
Dim endPoint As ImGearPoint = New ImGearPoint(igPage.DIB.Width / 2, igPage.DIB.Height / 2)

' Setup color for the ruler.
Dim color As ImGearRGBQuad = New ImGearRGBQuad(0, 255, 0)

' Get and initialize image resolution for the ruler.
Dim imageResolution As ImGearResolution = New ImGearResolution( _
  igPage.DIB.ImageResolution.XNumerator, _
  igPage.DIB.ImageResolution.XDenominator, _
  igPage.DIB.ImageResolution.YNumerator, _
  igPage.DIB.ImageResolution.YDenominator, _
  igPage.DIB.ImageResolution.Units)

' Create ruler, note that the ruler is always created with measurement units set to mm
' and it doesn't depend on ImGearResolution measurement units.
Dim ruler As ImGearARTRuler = New ImGearARTRuler(startPoint, endPoint, color, imageResolution)

' Let's change measurement unit to inches.

imageResolution.ConvertUnits(ImGearResolutionUnits.INCHES)

' Set number of pixels per 1 inch.
ruler.AspectDenominatorX = 1 * CInt(Math.Round(CDbl(imageResolution.XNumerator) / CDbl(imageResolution.XDenominator)))
ruler.AspectDenominatorY = 1 * CInt(Math.Round(CDbl(imageResolution.YNumerator) / CDbl(imageResolution.YDenominator)))

' Set 1 inch scale.
ruler.AspectNumeratorX = 1
ruler.AspectNumeratorY = 1

ruler.Label = "%d in"

' Change measurement units back to the mm.

imageResolution.ConvertUnits(ImGearResolutionUnits.METERS)

' Set number of pixels per 1 meter.
ruler.AspectDenominatorX = 1 * CInt(Math.Round(CDbl(imageResolution.XNumerator) / CDbl(imageResolution.XDenominator)))
ruler.AspectDenominatorY = 1 * CInt(Math.Round(CDbl(imageResolution.YNumerator) / CDbl(imageResolution.YDenominator)))

' Set 1 mm scale.
ruler.AspectNumeratorX = 1000
ruler.AspectNumeratorY = 1000

ruler.Label = "%d mm"

igARTPage.AddMark(ruler, ImGearARTCoordinatesType.IMAGE_COORD)
See Also

Reference

ImGearARTRuler Class
ImGearARTRuler Members