 |
|
 |
Hi,I am very new to C++.I am loading two bitmaps one on the other.I want to rotate the second bmp file with out effecting to the first bmp file.
Can any one give some sample code in C++(with out using MFC)
Hope will give reply.
Regards, swetha.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
This problem is more for the people sending in comments than for the author:
Why the hello do you need a tutorial to use SetWorldTransform()? Learn how to program people!!!! Read the Microsoft documentation, you'll get a lot further!
Ben Glancy Software Developer Articad Ltd
|
| Sign In·View Thread·PermaLink | 1.00/5 (3 votes) |
|
|
|
 |
|
 |
int widthERT =120; int heightERT =80;
void CRotateDrawDlg::OnPaint() { ... else { // // draw the client based on user selection // UpdateData(TRUE); // get current dialog item's value
CPaintDC dc(this); // device context for painting HDC hDc = dc.GetSafeHdc();
// create a black brush for frame border drawing HBRUSH blackBrush; blackBrush = CreateSolidBrush(RGB(0, 0, 0));
CRect rect; m_ctlDrawArea.GetClientRect(&rect);
// make a frame which start at the (7, 7) rect.top += 7; rect.left += 7;
// draw the frame: FrameRect(hDc, &rect, blackBrush);
POINT centerPt; centerPt.x = (rect.right - rect.left)/2 ; centerPt.y = (rect.bottom - rect.top)/2 ;
// draw the coordinate system dc.MoveTo(centerPt.x, rect.top + 7); dc.LineTo(centerPt.x, rect.bottom - 7);
dc.MoveTo(rect.left + 7, centerPt.y); dc.LineTo(rect.right - 7, centerPt.y);
// // rotate the DC // int nGraphicsMode = SetGraphicsMode(hDc, GM_ADVANCED); XFORM xform; XFORM xfform; XFORM xffform; if ( m_iAngle != 0 ) { double fangle = (double)m_iAngle / 180. * 3.1415926; xform.eM11 = (float)cos(fangle); xform.eM12 = (float)sin(fangle); xform.eM21 = (float)-sin(fangle); xform.eM22 = (float)cos(fangle); xform.eDx = 0; xform.eDy = 0;
xfform.eM11 = 1; xfform.eM12 = 0; xfform.eM21 = 0; xfform.eM22 = 1; xfform.eDx = widthERT; xfform.eDy = 0;
CombineTransform(&xffform,&xform,&xfform);
SetWorldTransform(hDc, &xffform); }
// draw a rectangle or ellipse if ( m_iShapeType == 0 ) { Rectangle(hDc, 0, 0, heightERT, widthERT ); Rectangle(hDc, heightERT-10, widthERT-10, heightERT, widthERT ); } else { }
// draw the rotated coordinate dc.MoveTo(centerPt.x, rect.top + 7); dc.LineTo(centerPt.x, rect.bottom - 7);
dc.MoveTo(rect.left + 7, centerPt.y); dc.LineTo(rect.right - 7, centerPt.y);
CDialog::OnPaint();
// restore the DC if ( m_iAngle != 0 ) { xform.eM11 = (float)1.0; xform.eM12 = (float)0; xform.eM21 = (float)0; xform.eM22 = (float)1.0; xform.eDx = (float)0; xform.eDy = (float)0; SetWorldTransform(hDc, &xform); } SetGraphicsMode(hDc, nGraphicsMode); // clean up resources DeleteObject(blackBrush); } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi, Can any body tell me the logic behinf the api RoundRect(hDC, rc.left, rc.top, rc.right, rc.bottom, rrParms->nRadiusHoriz, rrParms->nRadiusVert); in vc++; Actually same code i have write in postscript to draw rounded rectangle with the paramewter (x1,y1,x2,y2,Rx,Ry).
Please help me. Thanks Prabhash
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi Lucy,
If you need to combine this rotation with the scaling, how to do it? Says that I need to combine with the following scaling code:
dc.SetMapMode(MM_ANISOTROPIC); dc.SetWindowExt(1000,1000); dc.SetViewportExt(140, 290);
I tried with your code and it doesn't do the correct rotation.
Any idea? And thanks for any help in advance...
Cheers
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Once going into advanced mode, you are in advanced...
Create your own scale matrix...
Ben Glancy Software Developer Articad Ltd
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Awesome! the Code works very well in VC project but i am currently looking for achieving the same on embedded VC++, which does not support SetWorldTransform(). Can anybody guide me for achieving an equivalent functionality in WinCE!
Meenu
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
 |
I try using SetWorldTransform() on a printer dc to draw an ActiveX control rotated by 90° but i have a strange problem: If I rotate to the right the output is horizontally stretched and if I rotate to the left it is also stretched and I have strange vertical black lines in the output. Can you give me a hint why this happens?
Here's my code:
CPrintDialog PrtDlg(FALSE); if(PrtDlg.DoModal() == IDOK) { CDC PrtDC; PrtDC.Attach(PrtDlg.GetPrinterDC());
CPrintInfo PrtInfo; PrtInfo.m_rectDraw.SetRect(0, 0, PrtDC.GetDeviceCaps(VERTRES), PrtDC.GetDeviceCaps(HORZRES));
DOCINFO DocInfo; ::ZeroMemory (&DocInfo, sizeof (DOCINFO)); DocInfo.cbSize = sizeof (DOCINFO); DocInfo.lpszDocName = "TEST";
XFORM XForm; XForm.eM11 = 0.0; XForm.eM12 = -1.0; XForm.eM21 = 1.0; XForm.eM22 = 0.0; XForm.eDx = 0.0; XForm.eDy = PrtDC.GetDeviceCaps(VERTRES);
SetGraphicsMode(PrtDC.m_hDC, GM_ADVANCED); if(SetWorldTransform(PrtDC.m_hDC, &XForm)==TRUE) { PrtDC.StartDoc(&DocInfo); Draw((long)&PrtDC, (long)&PrtInfo.m_rectDraw); PrtDC.EndDoc(); } }
Thanks in advance. Tobias Hartmann
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there, i'd like to ask for ideas on creating a series of circles/ellipses and distributing them according to certain radians.It's actually like the round clock in our hse.First draw a big outer circle(like the clock's shape);then distributing,for eg, 12 smaller circles along the outer circle(concept almost like the numbers on the clock).Can anyone pls help me? 10Q. p/s i'm using WinME
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
SetWorldTransform() is unsupported by windows95/98/Me, how can I rotate the shapes on these system? Somebody help me!
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Nope. SetWorldTransform() doesn't work for rotation under Win9x/ME. If you want easy rotation abilities, you might want to use GDI+ instead of GDI.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
One of my requirements is to rotate the whole client area by 180 degree for print only. Any idea how to accomplish it? Your solution would save my time in implementing this in my project.
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
 |
Was needed long back. They have papers in rolls and the requirement was to rotate a particular paper. eg. if they select a page 3 to be printed upside down, then it should print all the papers in normal way except the third page. Which needs to be printed upside down. Thanks for the help.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Thank you very much for the project on rotation of shapes. Can you guide me on how to perform resizing of images, as in Word Art, along with zooming of images.
|
| Sign In·View Thread·PermaLink | 1.25/5 (3 votes) |
|
|
|
 |
|
 |
Off the top of my head, draw your lines, and scale using SetWorldTransform(), as in...
Create your own matrix...
Once you are using SetWorldTransform, you are in the powerful world of Matrix Mathematics.
To give you a run down:
To rotate one object by it's own origin:
1. Translate the object's desired pivot point to origin 2. Rotate. (The object will rotate around the world origin, that is (0,0)) 3. Translate back to origin position
Matrix Multiply the above together to get a single matrix that performs the business.
If you cant understand this concept, I suggest learning Math before you start using the advanced mode of the gdi. And I'd abandon WIndows 95 and use GDI+ instead of GDI anyway... take my word for it.
Ben Glancy Software Developer Articad Ltd
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
It is quite nice example, very clean!
But you can show everybody what you can do with this, eg adding a bitmap, and make it rotate with the rectangle! 
I've tested it, works fine...
=================== Lars [Large] Werner lars@werner.no ===================
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
So *thats* how to get rotated ellipses; i never knew that was possible with windows.
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |