Click here to Skip to main content
13,256,260 members (49,923 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 17 Nov 2002

EMF record rotation for EMR_POLYGON16

, 17 Nov 2002
Rate this:
Please Sign up or sign in to vote.
EMF record rotation for EMR_POLYGON16

Sample Image - MROT.jpg


When I decided to build a PowerPoint-like visual editor, first thing I had to do was pasting clipboard contents to my view. But it's all around MSDN, CodeGuru etc. Like DrawCli, JTDraw, etc..

But the second part, when I had to rotate clipboard image, it was different. I could not find any hints at all.

Maybe it's because of my poor ability to search things.. :( Anyway, I decided to rotate EMF.

The API function SetWorldTransform() is not supported on Win98. Actually I'm working on Win2K, but I wanted to rotate EMF without any GDI transformation functions.

I think the steps to rotate EMF image is as follows.

  1. Draw COleClientItem inherited object to CMetaFileDC(A_DC).
  2. Get EMF from A_DC.
  3. Draw acquired EMF bits as rotated on another CMetaFileDC(B_DC).
  4. Get EMF from B_DC.
  5. Draw rotated EMF file to output DC

Enumerating EMF (or WMF) requires CALLBACK function. Global scope can be used, but I've put it into my CItem class as static member function. No-static member function cannot be used as CALLBACK function in EnumEnhMetaFile.

Included source files were built as following sequence.

  1. Create new MFC (EXE) project with Ole Container options selected.
  2. CblahblahCntrItem class is the COleClientItem inherited class. So, if you want some properties in your item, put your things into C~~CntrItem class.
  3. Add ID_EDIT_PASTE event handler
  4. Customize draw function

That's all.

Download project & build. Run MROT and get some vector image on your system's clipboard, and paste into MROT.

Then you can see the clipart on MROT's view. Then push RIGHT or LEFT cursor key. Then the image will rotate by 5 in degrees.

MROT handles only EMR_POLYGON16 record. So, If your clipart contains other polygonal records or rectangular records.. MROT cannot display & rotate it well.

MSDN\TECHART\1619\EMFDCODE.EXE on you MSDN CD can help you inspect your source clipart.

Now I think, building PowerPoint-like visual editor is not difficult (I say editor..:)) but will take long time if you approach as what I did. I'll move to GDI+, because I don't have to convert any polygon points at all.

P.S. You may wonder what ConvertEMF member function is for. Some cliparts have their own mapping aspects. Mapmode as MM_ANISOTROPIC, and Window/Viewport Extents inversed.. so, same rotation command will act differently on those kind of cliparts... ConvertEMF converts WindowExt inversed cliparts to non-inversed one.

Is there anyone to handle all of EMF records to rotate? :)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Korea (Republic of) Korea (Republic of)
Lazy Programmer since 1998.

You may also be interested in...

Comments and Discussions

GeneralEasy way to rotate - using GDI+ Pin
Devin20-Nov-02 16:40
memberDevin20-Nov-02 16:40 
GeneralRe: Easy way to rotate - using GDI+ Pin
Sunil TG4-Nov-07 22:30
memberSunil TG4-Nov-07 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 18 Nov 2002
Article Copyright 2002 by Devin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid