Graphics.GetDpiY method

Applies to: desktop apps only

The Graphics::GetDpiY method gets the vertical resolution, in dots per inch, of the display device associated with this Graphics object.

Syntax

REAL GetDpiY();

Parameters

This method has no parameters.

Return value

Type:

Type: REAL

This method returns the vertical resolution, in dots per inch, of the display device associated with this Graphics object.

Examples

The following example gets the vertical resolution, in dots per inch, of the display device and uses that value to convert pixels to inches. Then the code draws two rectangles that have the same height: one measured in inches and one measured in pixels.


VOID Example_GetDpiY(HDC hdc)
{
   Graphics graphics(hdc);
   
   // Get the vertical resolution, in dots per inch, of the display device.
   REAL dpiY = graphics.GetDpiY();
   
   // Set the unit of measure for graphics to inches.
   graphics.SetPageUnit(UnitInch);
   
   // Use dipY to convert pixels to inches, and draw a 
   // rectangle that has a height of 100 pixels.
   REAL side = 100.0f/dpiY;
   Pen bluePen(Color(255, 0, 0, 255), 0.0f);
   graphics.DrawRectangle(&bluePen, 0.0f, 0.0f, side, side);
   
   // Set the unit of measure for graphics to pixels.
   graphics.SetPageUnit(UnitPixel);
   
   // Draw a 100-pixel square.
   Pen redPen(Color(255, 255, 0, 0), 0.0f);
   graphics.DrawRectangle(&redPen, 120, 0, 100, 100);
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusgraphics.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Graphics
Graphics::GetDpiY
Graphics::GetPageUnit
Graphics::SetPageUnit
Global and Local Transformations
Types of Coordinate Systems

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show: