ImageGear for .NET
AspectDenominatorY Property
See Also  Example Send Feedback
ImageGear21.Art Assembly > ImageGear.ART Namespace > ImGearARTRuler Class : AspectDenominatorY Property




Glossary Item Box

Gets or sets the Mark's Y aspect denominator value.

Syntax

 
Visual Basic
C#
Managed Extensions for C++
C++/CLI
 
 

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 measurement units, like meters or inches.

The default value is 1.

Example

C#Copy Code
// 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);
Visual BasicCopy Code
' 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

©2013. Accusoft Corporation. All Rights Reserved.