C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 5th, 2005, 08:11 AM
dado dado is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 dado User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Mirror Text

Hi!

I'm working with Borland C++ Builder 6 and i need to get the mirror of a text; it means that a string has to be flipped. In other words, i don't need only that the characters of a string change order ('mirror' becomes 'rorrim'), but also the single font must be flipped (not using a mirrored font). How can i obtain that? I tried by inverting the order of the pixels of the Canvas in which the text is drawn, but in this way the software get too slow.
Please, give me help!
Thanks a lot

Bye

Reply With Quote
  #2  
Old January 10th, 2005, 03:38 AM
dado dado is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 dado User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi!

I found out the solution of this problem and i post it for people that must solve it! What you've got to do is to transform the way in which the canvas is drawn by a transformation matrix.
You act like that:

Above all define the handle that manage your canvas:

HDC hDC;
hDC = Canvas->Handle;

Then you have to define the transformation matrix, that allow you to act two-dimensional linear transformation between world space and page space for the specified device context:

XFORM xForm;

xForm.eM11 = (FLOAT) -1;
xForm.eM12 = (FLOAT) 0.0;
xForm.eM21 = (FLOAT) 0.0;
xForm.eM22 = (FLOAT) 1;


xForm.eDx = (FLOAT) 0.0;
xForm.eDy = (FLOAT) 0.0;


This xForm cause the flip of the canvas on horizontal axis; that's why each point (x, y), after the transformation, become the new point (x', y') in the following way:

x' = x * eM11 + y * eM21 + eDx,
y' = x * eM12 + y * eM22 + eDy,

where the transformation matrix is represented by the following:
| eM11 eM12 0 |
| eM21 eM22 0 |
| eDx eDy 1 |

be carefull about eDx e eDy, thinking of that the point (0, 0) of the canvas is the top-left angle.
Now you have to set the graphics mode for the specified device context:

SetGraphicsMode( hDC, GM_ADVANCED );

in that way you obtain the behaviour:
Windows NT:
Sets the advanced graphics mode that allows world transformations. This value must be specified if the application will set or modify the world transformation for the specified device context. In this mode all graphics, including text output, fully comforms to the world-to-device transformation specified in the device context.
Windows 95:
The GM_ADVANCED value is not supported. When playing enhanced metafiles, Windows 95 does its best to ensure that enhanced metafiles on Windows 95 look the same as they do on Windows NT. To accomplish this, Windows 95 may simulate GM_ADVANCED mode when playing specific enhanced metafile records.

Then set the two-dimensional linear transformation between world space and page space for the specified device context (hDC):

SetWorldTransform(hDC, &xForm);

from now, each thing that you draw on the canvas is drawn transformed (by the transformation matrix xForm); in my case i'll get my mirrored text:

Canvas->TextOut(-100, 100, "mirror");

to come back and draw normally, you have only to set the inver matrix:

xForm.eM11 = (FLOAT) -1;
xForm.eM12 = (FLOAT) 0.0;
xForm.eM21 = (FLOAT) 0.0;
xForm.eM22 = (FLOAT) 1;


xForm.eDx = (FLOAT) 0.0;
xForm.eDy = (FLOAT) 0.0;


and continue with your code!!!

What a rough thing!!
Have a good work!

Hi

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Mirror Text


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT