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 » Community » Newbie corner » image drawing
icon5.gif  image drawing [message #26351] Tue, 27 April 2010 08:02 Go to next message
raxvan is currently offline  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 #26352 is a reply to message #26351] Tue, 27 April 2010 10:05 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
raxvan wrote on Tue, 27 April 2010 08:02

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


Hello Raxvan

The display has to be OpenGL or just a bitmap display?


Best regards
Iñaki
Re: image drawing [message #26353 is a reply to message #26351] Tue, 27 April 2010 10:34 Go to previous messageGo to next message
raxvan is currently offline  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 #26354 is a reply to message #26353] Tue, 27 April 2010 11:32 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
raxvan wrote on Tue, 27 April 2010 10:34

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.

Hello raxvan

You can begin with a Picture Ctrl. Try to explain what is the mouse behavior you want and we could help you to handle the mouse rotate, move and stretch.


Best regards
Iñaki
Re: image drawing [message #26356 is a reply to message #26351] Tue, 27 April 2010 13:32 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
ok thanks Smile, 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 #26357 is a reply to message #26356] Tue, 27 April 2010 15:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Quote:

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


Hello Raxvan

A question. Do you want to drag your image from a Ctrl to another Ctrl and meanwhile changing the mouse pointer image to the image dragged?


Best regards
Iñaki
Re: image drawing [message #26358 is a reply to message #26351] Tue, 27 April 2010 15:59 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
nope,
just move the image around in the same Ctrl.


92b48bf94855483bb4cec8bcc8c0c933
Re: image drawing [message #26359 is a reply to message #26358] Tue, 27 April 2010 16:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Raxvan

I meant this:

index.php?t=getfile&id=2502&private=0
  • Attachment: Dib.PNG
    (Size: 22.75KB, Downloaded 456 times)


Best regards
Iñaki
Re: image drawing [message #26360 is a reply to message #26359] Tue, 27 April 2010 16:17 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Use OpenGL, it'll be a both easier and faster than any other method.

The only problem that occurs to me is image format. How are you storing the image? Are you using Upp image format or just an array of RGB(A)? The reason I ask is that if you're using Upp format on windows you'll need to swap the B & R components.
Re: image drawing [message #26362 is a reply to message #26351] Tue, 27 April 2010 17:50 Go to previous messageGo to next message
raxvan is currently offline  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 Go to previous messageGo to next message
mrjt is currently offline  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 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Smile

Honza
Previous Topic: Upp .dll
Next Topic: Void pointer to NTL Array and VectorMap
Goto Forum:
  


Current Time: Fri Mar 29 06:00:21 CET 2024

Total time taken to generate the page: 0.01139 seconds