drawing to a bitmap from a thread 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.
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: drawing to a bitmap from a thread

Post by catalin »

If you don't share the resources between threads it should be safe.
There have been some years, wouldn't it have been faster to try already?
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: drawing to a bitmap from a thread

Post by mael15 »

catalin wrote:If you don't share the resources between threads it should be safe.
There have been some years, wouldn't it have been faster to try already?
:lol: :lol: :lol:
I already use the other suggestion to draw on a wxBitmap with a wxMemoryDC inside the thread, convert it to wxImage, send it with an wxThreadEvent to the main thread, convert it back to wxBitmap and paint it to the screen. I just found your suggestion interesting when i reread the topic here and wanted to learn if some other way would be possible. Do you have a link to an article where I can read about shared resources and threads?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: drawing to a bitmap from a thread

Post by catalin »

No, sorry. But any article on the subject will be good enough, there is nothing wx-specific about it. Just consider native resources (which are almost always used by graphic APIs) as not thread safe. Apart from that, Google or any decent library are very good friends.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: drawing to a bitmap from a thread

Post by PB »

Just for the reference, this topic has been discussed on wx-dev recently:
https://groups.google.com/d/topic/wx-us ... discussion

If I understood it correctly, GDI objects can be used in worker threads as long as it is ensured they are accessed always only from the thread they were created in.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: drawing to a bitmap from a thread

Post by mael15 »

PB wrote:Just for the reference, this topic has been discussed on wx-dev recently:
https://groups.google.com/d/topic/wx-us ... discussion

If I understood it correctly, GDI objects can be used in worker threads as long as it is ensured they are accessed always only from the thread they were created in.
Good read, I understand now, thank you everyone!
Post Reply