Understanding GDI mapping modes and other functions

This tool was contributed by Hans Wedemeyer.

MapMode.exe is an interactive tool that can help a programmer better understand various graphics functions and their interactions.

It demonstrates the interactions of

SetMapMode()    // all eight modes
SetWindowExt ()
SetViewportExt ()
SetViewportOrg ()
CreateCompatibleBitmap()
BitBlt( )

Have you ever wondered what a printed page will look like in a particular map mode, here's thre answer and you don't have to write code to find out !

Ever wondered what all those arguments to BitBlt() do ! now you can find out!

Open eight windows and compare all eight map modes at the same time !

When you run the program, there appears a "control panel", on it are various buttons to adjust the parameters for each function. as you adjust the screen is repainted and the change takes place immediately.

Consider these to be in the program's OnDraw()

void MapMode::OnDraw(CDC* pDC )
{
    CRect rect;
    GetClientRect(&rect);

    if ( pDC->IsPrinting())
    {
        rect.left = 0;
        rect.top = 0;
        rect.right = pDC->GetDeviceCaps(HORZRES);
        rect.bottom = pDC->GetDeviceCaps(VERTRES);
    }

    pDC->SetMapMode ( m_nMapMode );

    pDC->SetWindowExt ( X, Y )

    pDC->SetViewportExt ( X , Y );

    pDC->SetViewportOrg ( X, Y );

    bmp.CreateCompatibleBitmap( pDC, X, Y );

   pDC->BitBlt( X1, Y1, X2, Y2, pBmpDC, X3, Y3, SRCCOPY );
}

You may draw a line to better understand or locate various x,y coordinates.

Additions made since the original tool.

Annotated origins for easy indentifaction.

Another new feature is "Find Origin" which help pin point in which direction the origin could be, useful if you loose the origin off screen.

Download file



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds