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 Draw into an existing image(buffer) ?
How to Draw into an existing image(buffer) ? [message #10494] Thu, 12 July 2007 16:37 Go to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi everyone,

So, here's my problem:

1) I want to draw multiple vector and raster objects to a single view
2) I want to be able to control the opacity and/or blending method for each layer (perhaps not the vector layers although filled polygons yes)

I have written a function to draw an image to a Rect within another image and apply alpha blending, luminance, bitwise AND/OR etc. and it works fine although am sure someone here could optimise it to draw faster...

I already know that I need to use some sort of background image (have chosen an ImageBuffer) which then gets passed to a painting function for each layer which then does its stuff to the ImageBuffer before letting the next layer up have its go and so on.

My problem is that ImageDraw and DrawingDraw do not draw to already existing images. Its in the documentation and am sure its not impossible to implement as you can convert an Image to an ImageDraw object. However, in the Draw code there is only one-way conversion which means that any kind of complex drawing code is impossible unless I've missed something.

Surely ImageDraw needs to be able to draw to an image and not just create an image which is the case at present.

I can do my multiple raster layers as I have implemented my own function for drawing an image but it seems silly for me to have to re-implement the vector drawing functions as well.

I guess I could draw my vector layers to fresh images and then set an image mask and draw the new image to the main background ImageBuffer but that is a lot of processing for something that should be simple.

Would it be possible to have a DrawImage constructor or an = operator to go from Image or ImageBuffer to DrawImage please?

Cheers,

Nick

p.s. a search for ImageDraw on this site brings up only the documentation. I can't believe am the only person trying to do complex graphics on this platform!









Re: How to Draw into an existing image(buffer) ? [message #10503 is a reply to message #10494] Thu, 12 July 2007 22:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12106
Registered: November 2005
Ultimate Member
You can use Draw::DrawImage to put an existing Image to ImageDraw.

Note that performance difference is negligible, the slowest part is moving pixels to and from GPU which is the same for both ways...

BTW, a tip:

If speed is not that important, you can achieve quite a good results by oversampling: Draw it 2x or 4x bigger, then downsample and you got antialiasing...

Mirek
Re: How to Draw into an existing image(buffer) ? [message #10508 is a reply to message #10503] Fri, 13 July 2007 03:46 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks Mirek,

Works great.

Hmmm so the GPU does the Draw processing eh? Even when am not drawing to the screen? (I do lots of processing before I ever send anything to be drawn to the screen)

Seems like I need to test this code on a lower spec PC to make sure its ok....

Unfortunately speed is important as I allow users to move the map with the mouse. I am sorry to lose the option of having images display the way UPP does it (I had to give this up when I moved to my own blending functions).

Nick



Re: How to Draw into an existing image(buffer) ? [message #10509 is a reply to message #10508] Fri, 13 July 2007 08:55 Go to previous message
mirek is currently offline  mirek
Messages: 12106
Registered: November 2005
Ultimate Member
Well, to say it straight, ImageDraw is sort of cheap solution for cases when you need to use host platform GUI to draw something. OTOH, in straight Win32 or X11, you have exactly the same option (draw bitmaps using GPU).

Full software rendering for U++ is a subject of research. You might try Aris's AGG plugin (see Technology lab).

BTW, speed-wise, it does not have to be so bad. I have just finished project that does a lot of supersampling using ImageDraw and Rescale and with some more tricks (like intense use of Image cache...) things seem to be OK even on 2-3 years old HW.

Mirek

[Updated on: Fri, 13 July 2007 08:57]

Report message to a moderator

Previous Topic: how to paint a LineEdit? how to create a small image?
Next Topic: Correct buffering technique?
Goto Forum:
  


Current Time: Fri Nov 22 21:26:34 CET 2019

Total time taken to generate the page: 0.01180 seconds