When I decided to build a PowerPoint-like visual editor, the first thing I had to do was pasting clipboard contents to my view. But it's all around MSDN, CodeGuru, etc. like
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 for 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 are as follows:
COleClientItem inherited object to
- Get EMF from
- Draw acquired EMF bits as rotated on another
- Get EMF from
- 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
Included source files were built as the following sequence:
- Create new MFC (EXE) project with Ole Container options selected.
CblahblahCntrItem class is the
COleClientItem inherited class. So, if you want some properties in your item, put your things into
ID_EDIT_PASTE event handler.
- Customize draw function.
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.
MM_ANISOTROPIC, and Window/Viewport Extents inversed... so, same rotation command will act differently on those kind of cliparts...
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.