Click here to Skip to main content
Click here to Skip to main content

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

Introduction

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.. Frown | :( 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..Smile | :) ) 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? Smile | :)

License

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

Share

About the Author

Devin
Web Developer
Korea (Republic Of) Korea (Republic Of)
Lazy Programmer since 1998.

Comments and Discussions

 
GeneralEasy way to rotate - using GDI+ PinmemberDevin20-Nov-02 16:40 
GeneralRe: Easy way to rotate - using GDI+ PinmemberSunil TG4-Nov-07 22:30 
Hi..
 
I ran your app. I could paste an image from the clipboard, (assertion failure ignored)
but I am not getting an idea what the application does.. I could not see an option to rotate! Unsure | :~
 
The text in the menu items did not appear properly.Frown | :(
 
-Sunil
 
Sunil TG
suniltg@msn.com

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 18 Nov 2002
Article Copyright 2002 by Devin
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid