get position after rotating using wxGCDC Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
mael15
Super wx Problem Solver
Super wx Problem Solver
Posts: 306
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

get position after rotating using wxGCDC

Post by mael15 » Tue Feb 05, 2019 10:13 am

Hello everyone,
I rotate a wxImage using a wxGCDC. Now I need the position of the left top corner of that rotated wxImage on screen. How can I get that?
I have a hunch it might work using the wxGraphicsMatrix?
Thank you!

Code: Select all

	auto degreeToRadians = [](double degree) {
		return (degree * 3.1415926535897932384626433832795) / 180;
	};
	
	gcdc = static_cast<wxGCDC*>(dc);
	gcdc->SetDeviceOrigin(500, 500);
	gcdc->GetGraphicsContext()->Rotate(degreeToRadians(37));

Manolo
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 664
Joined: Mon Apr 30, 2012 11:07 pm

Re: get position after rotating using wxGCDC

Post by Manolo » Tue Feb 05, 2019 1:41 pm

I suppose you know the coordinates [cx, cy] of that corner before the rotation.
Then the new coordinates after the rotation can be obtained by

Code: Select all

gcdc->GetGraphicsContext()->GetTransform().TransformPoint(&cx, &cy);

Post Reply