PCS Lecture - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

PCS Lecture

Description:

The screen co-ordinate system is Pixels ... of pixels per logical inch along the screen height. BITSPIXEL Number of adjacent color bits for each pixel. ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 26
Provided by: compu354
Category:
Tags: pcs | lecture | pixels

less

Transcript and Presenter's Notes

Title: PCS Lecture


1
LECTURE 7
  • Mapping Modes
  • System Metrics
  • Other Topics

2
MAPPING MODES
  • What are mapping Modes?
  • We have seen that the device context holds the
    current GDI information and effects how we draw
    onto a device.

3
But the Screen is not the WORLD
  • The screen co-ordinate system is Pixels
  • The world may use Inchs, Centimeters or any other
    specific dimension

4
Windows Dimensions and View
  • Windows Origin
  • Viewport Origin
  • Windows Extent
  • Viewport Extent
  • From these three criteria sets of information
    we can derive a Mapping Mode.

5
Logical Units
  • Textout (hdc,x,y,Buffer,length)
  • The X and Y are positions for the start of the
    text. - these positions are Logical Units
  • Windows has to translate Logical Units to Device
    Units
  • This translation is governed by the selected
    mapping mode in the device context.

6
Map Modes
  • Mode Logical Unit X axis Y axis
  • MM_TEXT Pixel Right Down
  • MM_LOMETRIC 0.1 mm Right Up
  • MM_HIMETRIC 0.01 mm Right Up
  • MM_LOENGLISH 0.01 inch Right Up
  • MM_HIENGLISH 0.001 inch Right Up
  • MM_TWIPS 1/1440 inch Right Up
  • MM_ISOTROPIC Arb x y Select Select
  • MM_ANISOTROPIC Arb x ! y Select Select

7
MAP MODE SET UP
  • You can set map Mode simple by SetMapMode(hdc,
    mode)
  • Regardless of the map mode selected X and y must
    be short integers i.e. -32767 to 32768.
  • This is true even in 32 but Windows !

8
Device Coordinates and Logical Coordinates
  • You must not get confused by map modes,
  • If you set MM_LOENGLISH you will not get WM_SIZE
    messages with the screen rectangle quoted in
    hundredths of an inch!

9
Device Coordinate System
  • Windows maps the logical coordinates in GDI
    functions to device coordinates via the Map Mode
    defined.
  • In a video system the device coordinates are
    always in Pixels.

10
Device Definitions
Screen 0,0

Window 0,0
Client 0,0
11
Client to Screen etc.
  • Various APIs exist to convert and get
    Coordinates
  • ClientToScreen
  • ScreenToClient
  • GetWindowRect
  • GetClientRect

12
Viewport and the Window
  • Using the mapping mode we are defining how the
    logical coordinates are mapped to the device
    coordinates..
  • In most cases in windows the viewport is the same
    as the client area of the window itself, however
    in some cases it can be related to the window
    coordinates themselves.

13
MM_TEXT (Default)
  • SetViewportOrg (hdc, cxClient / 2, cyClient /2)

14
A Little Strange !
  • As another option we could move the origin as
  • SetViewportOrg (hdc,cxClient /2 , cyClient /2)
  • SetWindowOrg (hdc, -cxClient /2, -cyClient /2)

15
Basic Dimension of Mapping
  • The default for LO and HI English and LO and HI
    Metric are
  • Window Origin (0,0) - Can be changed
  • Viewport Origin (0,0) - Can Be Changed
  • Window extent (?,?) - Cannot be changed
  • Viewport extent (?,?) - Cannot be changed

16
MAKE YOUR OWN MAP MODE
  • MM_ISOTROPIC
  • MM_ANISOTROPIC
  • allow you to change the viewport and windows
    extent meaning that we have an ability to change
    scaling.
  • ISOTROPIC means same in both directions i.e. x
    y
  • ANISOTROPIC different in both directions i.e. x
    ! y.

17
ISOTROPIC
  • ISOTROPIC
  • define arbitrary axes
  • preserving equal logical units
  • rectangles with equal sides squares
  • ellipses with equal major and minor axis
    circles.

18
(No Transcript)
19
GetTextMetrics
  • struct _TEXTMETRIC
  • Some standard calculations ...
  • Character Width normal tmAveCharWidth
  • Capital Character Width (tmPitchAndFamily 1)
    ? 3 2))Character Width normal
  • Character Height tmHeight tmExternalLeading

20
SCROLL TECHNIQUES
  • Normally any window which displays text will have
    scroll bars.
  • Need to calculate the range of the scroll and the
    scroll position etc.
  • We will only look at Vertical scroll control,
  • Similar argument can be applied to Horizontal
    scroll and the same technique can be employed.

21
STANDARD Macro's
  • define min(a,b) (((a) lt (b)) ? (a) (b))
  • define max(a,b) (((a) gt (b)) ? (a) (b))
  • SCROLL APIs
  • SetScrollRange (.....)
  • SetScrollPosition(....)

22
TYPICAL WM_CREATE
  • hdc GetDC (hwnd) // can't do TextMetrics
    etc. without a Device Context.
  • GetTextMetrics (hdc, tm)
  • cxChar tm.tmAveCharWidth
  • cxCaps (tm.tmPitchAndFamily 1 ? 3 2)
    cxChar/2
  • cyChar tm.tmHeight tm.tmExternalLeading
  • ReleaseDC (hwnd, hdc)
  • nMaxWidth 40 cxChar 22 cxCaps // Thats
    a
  • // typical setting for max width on a line

23
TYPICAL in WM_SIZE
  • cxClient LOWORD (lParam) // can extract the
    client size
  • // from the parameters.
  • cyClient HIWORD (lParam)
  • nVscrollMax max (0, NUMLINES 2 - cyClient /
    cyChar)
  • // NUMLINES is how many display lines
  • nVscrollPos min (nVscrollPos, nVscrollMax)
  • SetScrollRange (hwnd, SB_VERT, 0, nVscrollMax,
    FALSE)
  • SetScrollPos (hwnd, SB_VERT, nVscrollPos, TRUE)
  • nHscrollMax max (0, 2 (nMaxWidth - cxClient)
    / cxChar)
  • nHscrollPos min (nHscrollPos, nHscrollMax)
  • SetScrollRange (hwnd, SB_HORZ, 0, nHscrollMax,
    FALSE)
  • SetScrollPos (hwnd, SB_HORZ, nHscrollPos, TRUE)

24
Device Caps
  • This allows you to determine Physical
    capabilities of the device.
  • GetDeviceCaps(...)
  • Typical Devices (hdc)
  • DT_PLOTTER Vector plotter
  • DT_RASDISPLAY Raster display
  • DT_RASPRINTER Raster printer
  • DT_RASCAMERA Raster camera
  • DT_CHARSTREAM Character stream
  • DT_METAFILE Metafile
  • DT_DISPFILE Display file

25
Characteristics
  • Typical values
  • HORZSIZE Width, in millimeters, of the physical
    screen.
  • VERTSIZE Height, in millimeters, of the physical
    screen.
  • HORZRES Width, in pixels, of the screen.
  • VERTRES Height, in raster lines, of the screen.
  • LOGPIXELSX Number of pixels per logical inch
    along the screen width.
  • LOGPIXELSYNumber of pixels per logical inch along
    the screen height.
  • BITSPIXEL Number of adjacent color bits for each
    pixel.
Write a Comment
User Comments (0)
About PowerShow.com