Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » How to rotate an image
How to rotate an image [message #21744] Wed, 03 June 2009 14:21 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

this is the QtfDrawing reference package:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

GUI_APP_MAIN
{
	DrawingDraw dw(100, 100);
	dw.DrawRect(0, 0, 100, 100, White);
	dw.DrawEllipse(10, 10, 80, 80, Red, 5, Blue);
	dw.DrawRect(50, 50, 50, 50, Yellow);
	QtfRichObject pict(CreateDrawingObject(dw.GetResult(), Size(500, 500), Size(500, 500)));
	String qtf;
	qtf << "[A6 This is some drawing in QTF: " << pict << "&";
	qtf << "[C3*@B And now in the table: {{1:1 " << pict << ":: Another cell " << pict << "}}";
	PromptOK(qtf);
}


I want to show the created picture rotated of 180 degree (2 right angle). I can't find a straight way to operate on dw or pict. Any suggestion? Maybe I must exchange the pixel one by one?

Thanks,
Luigi
Re: How to rotate an image [message #21745 is a reply to message #21744] Wed, 03 June 2009 14:55 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
In Draw/ImageOp.h there are:
Image RotateClockwise(const Image& img);
Image RotateAntiClockwise(const Image& img);
Image MirrorHorz(const Image& img);
Image MirrorVert(const Image& img);
Image Rotate(const Image& m, int angle);


But I can't find any documentation about it anywhere, I just use it in my own code (the RotateClockwise one) and it works, maybe it will help you too.

I can't see anything else in draw about rotating of full image or drawdraw, which doesn't make sense a little bit, when we speak about vector components like DrawingDraw, maybe some global transform matrix would be nice touch there.
But if I recall it correctly, Mirek prefer's Draw in stateless way, so setting up "view matrix" would not work, maybe some convert function: DrawingDraw TransformDrawingDraw( const DrawingDraw & w, const [transformmatrixtype] & tm ); ??
But for example Clipping operation does set state of Draw, sooo ... well. I didn't work with these things for long time, so I'm not sure what to think about it and what would be a proper way to go.

[Updated on: Wed, 03 June 2009 14:57]

Report message to a moderator

Re: How to rotate an image [message #21751 is a reply to message #21745] Wed, 03 June 2009 19:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
You might want to check Painter.

E.g. examples/PainterExamples.

Mirek
Re: How to rotate an image [message #21772 is a reply to message #21745] Thu, 04 June 2009 18:08 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
mr_ped wrote on Wed, 03 June 2009 14:55

In Draw/ImageOp.h there are:
Image RotateClockwise(const Image& img);
Image RotateAntiClockwise(const Image& img);
Image MirrorHorz(const Image& img);
Image MirrorVert(const Image& img);
Image Rotate(const Image& m, int angle);





Thanks. To use them I moved on ImageDraw. Painter seems to complicated because I need to include the rotated image and its original in a qtf document.
Please let me ask one more question:

In
ImageDraw iw(1200, 1000);
if iw is printed on the screen the numbers are pixel?
If I create a qtf object with

QtfRichObject pict( CreateImageObject(iw, 1200, 1000) ) ;
String qtf;
qtf << "[A6 This is some drawing in QTF: " << pict << "&";
PromptOK(qtf);

I see a smaller size. How the image is scaled in the qtf units?


Thanks a lot,
Luigi

[Updated on: Thu, 04 June 2009 18:36]

Report message to a moderator

Re: How to rotate an image [message #21778 is a reply to message #21772] Thu, 04 June 2009 21:42 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Thu, 04 June 2009 12:08

mr_ped wrote on Wed, 03 June 2009 14:55

In Draw/ImageOp.h there are:
Image RotateClockwise(const Image& img);
Image RotateAntiClockwise(const Image& img);
Image MirrorHorz(const Image& img);
Image MirrorVert(const Image& img);
Image Rotate(const Image& m, int angle);





Thanks. To use them I moved on ImageDraw. Painter seems to complicated because I need to include the rotated image and its original in a qtf document.
Please let me ask one more question:

In
ImageDraw iw(1200, 1000);
if iw is printed on the screen the numbers are pixel?
If I create a qtf object with

QtfRichObject pict( CreateImageObject(iw, 1200, 1000) ) ;
String qtf;
qtf << "[A6 This is some drawing in QTF: " << pict << "&";
PromptOK(qtf);

I see a smaller size. How the image is scaled in the qtf units?



Well, generally, scaling factor varies Smile

In the case of Prompt, scaling is defined by

Zoom GetRichTextStdScreenZoom()
{
	return Zoom(Ctrl::HorzLayoutZoom(96), 600);
}


Mirek
Previous Topic: Draw package and console app error
Next Topic: Code error for svn1432
Goto Forum:
  


Current Time: Fri Mar 29 00:32:55 CET 2024

Total time taken to generate the page: 0.01409 seconds