|
|
Home » Community » Newbie corner » image drawing
image drawing [message #26351] |
Tue, 27 April 2010 08:02  |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
Hello,
I'm writing a raytracer , what is the best way to display the final image? Also i would like to be able to drag the image arround.
Thanks,
Raxvan
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
|
Re: image drawing [message #26353 is a reply to message #26351] |
Tue, 27 April 2010 10:34   |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
Just a bitmap display but i want to be able to rotate, move , and stretch the image in realtime with the mouse. The Raytracer camera/frame will be updated only when the mouse click is released acording to that movement.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
|
Re: image drawing [message #26356 is a reply to message #26351] |
Tue, 27 April 2010 13:32   |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
ok thanks , what i want to do involves both simple and `hard` transformations:
1. zoom in/out ; mouse wheel will just zoom in/out on the image
2. Drag and drop:
Suppose that A (rectangle)is my Picture Ctr,and B is my image.
Normally B is exactly the size of A and the size of the image.
When i click and drag the image in the Picture Ctrl the image will follow my mouse , so when i move right the image will move right. The backgound will be white or black
Hard:
3. Rotate the image in the 2D space.
When i click the corner of the image for example, the picture will rotate around the center.
4. Rotate in 3D space. But i'm not sure if i want to do this.
Imagine you are looking to a plane in space from (0,0,0). The image is at (1,0,0) with the normal (-1,0,0) facing you.
You should be able to rotate the image about Y and Z only around the origin.
Thanks,
Raxvan.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
|
|
|
|
Re: image drawing [message #26362 is a reply to message #26351] |
Tue, 27 April 2010 17:50   |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
no, nothing like that koldo,
Moving the image in the same control. This is not the real problem, i can handle draging.The problem that i have is the 3D rotation;
grub the image by a corner and rotate the image in the same Ctrl,
mrjt thanks for the tip , ill test the app on windows later,
I use custom Image class because i use more that 3 components/pixel
and image filtering.
The only problem is that i don't know any OpenGl, and i think i can get a software renderer done faster.
thanks
Edit.
Can i use safely multiple windows at the same time? (using threads)
How can i fire an event from a thread to another to update the window?
92b48bf94855483bb4cec8bcc8c0c933
[Updated on: Tue, 27 April 2010 17:52] Report message to a moderator
|
|
|
Re: image drawing [message #26363 is a reply to message #26362] |
Tue, 27 April 2010 18:01   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
You could also convert your image format to Image (using ImageBuffer) and then use the functions in CtrLib/ImageOp.cpp like:
Image RotateClockwise(const Image& img)
Afterall, to draw the image you must have to convert it to RGB as some stage.
[Updated on: Tue, 27 April 2010 18:02] Report message to a moderator
|
|
|
Re: image drawing [message #26365 is a reply to message #26362] |
Tue, 27 April 2010 19:19  |
|
raxvan wrote on Tue, 27 April 2010 17:50 | Can i use safely multiple windows at the same time? (using threads)
How can i fire an event from a thread to another to update the window?
|
Yes, it is possible, actually even without threads. See GUI tutorial, paragraph 6 for description how. Usual approach to keep the GUI responsive is to have one thread handling GUI and a separate one for computations.
For updating the GUI from computation thread, there exist more possible ways. I usually use the dirty but simple one - I store a pointer to the part of GUI I need to update. Following example worked well for me when I needed to report the progress of computation to the user in a LineEdit: thread__ LineEdit* ReportEditPtr;
void Report(String str,bool stamp,bool nl) {
GuiLock __;
(*ReportEditPtr)<<=(~(*ReportEditPtr)).ToString()+
(stamp?FormatTime(GetSysTime(),"hh:mm:ss "):"")+str+(nl?"\n":"");
(*ReportEditPtr).SetCursor((~(*ReportEditPtr)).ToString().GetLength()-1);
(*ReportEditPtr).Refresh(); (*ReportEditPtr).Sync();
}
And in the window constructor: ReportEditPtr=&ReportLineEdit;
Hopefully someone will recommend you some cleaner way 
Honza
|
|
|
Goto Forum:
Current Time: Mon Apr 28 19:15:59 CEST 2025
Total time taken to generate the page: 0.00955 seconds
|
|
|