Discussion:
GDI and multiple layers?
(too old to reply)
Todor Atanasov
2013-11-17 19:11:29 UTC
Permalink
Hi everyone,
I searched the group but didn't find anything.
I have 1000 polygons drawn on OnPaint() and some other stuff. Is there a way to speed up the drawing, by not drawing the polygons every time (but still see them of course) and only "refresh" the other stuff?

I also use double buffering to overcome the flickering.
R.Wieser
2013-11-18 12:44:15 UTC
Permalink
Hello Todor,
Post by Todor Atanasov
Is there a way to speed up the drawing, by not drawing
the polygons every time
Draw those static polygons onto a bitmap once and display that bitmap in the
target window ?

Regards,
Rudy Wieser
Post by Todor Atanasov
Hi everyone,
I searched the group but didn't find anything.
I have 1000 polygons drawn on OnPaint() and some other stuff. Is there a
way to speed up the drawing, by not drawing the polygons every time (but
still see them of course) and only "refresh" the other stuff?
Post by Todor Atanasov
I also use double buffering to overcome the flickering.
Todor Atanasov
2013-11-20 13:48:12 UTC
Permalink
Post by R.Wieser
Hello Todor,
Post by Todor Atanasov
Is there a way to speed up the drawing, by not drawing
the polygons every time
Draw those static polygons onto a bitmap once and display that bitmap in the
target window ?
Regards,
Rudy Wieser
Post by Todor Atanasov
Hi everyone,
I searched the group but didn't find anything.
I have 1000 polygons drawn on OnPaint() and some other stuff. Is there a
way to speed up the drawing, by not drawing the polygons every time (but
still see them of course) and only "refresh" the other stuff?
Post by Todor Atanasov
I also use double buffering to overcome the flickering.
How can I do that? How can I combine this bitmap and the "refresh data"?
R.Wieser
2013-11-20 15:45:32 UTC
Permalink
Hello Todor,
Post by Todor Atanasov
How can I do that? How can I combine this bitmap and the "refresh data"?
I'm not sure how exactly its done in VC, but in another lanuage I've been
using the BitBlt command myself, which is a function in GDI32.DLL.

In the draw event you first draw the bitmap and than the remaining polygons
over it. If you also need polygons drawn *under* you would need to create a
bitmap with transparency and use a 'draw polygons under, draw bitmap, draw
polygons over' sequence.

Hope that helps,
Rudy Wieser
Post by Todor Atanasov
Post by R.Wieser
Hello Todor,
Post by Todor Atanasov
Is there a way to speed up the drawing, by not drawing
the polygons every time
Draw those static polygons onto a bitmap once and display that bitmap in the
target window ?
Regards,
Rudy Wieser
[snip]
Post by Todor Atanasov
How can I do that? How can I combine this bitmap and the "refresh data"?
Todor Atanasov
2013-11-20 18:35:42 UTC
Permalink
Post by R.Wieser
Hello Todor,
Post by Todor Atanasov
How can I do that? How can I combine this bitmap and the "refresh data"?
I'm not sure how exactly its done in VC, but in another lanuage I've been
using the BitBlt command myself, which is a function in GDI32.DLL.
In the draw event you first draw the bitmap and than the remaining polygons
over it. If you also need polygons drawn *under* you would need to create a
bitmap with transparency and use a 'draw polygons under, draw bitmap, draw
polygons over' sequence.
Hope that helps,
Rudy Wieser
Post by Todor Atanasov
Post by R.Wieser
Hello Todor,
Post by Todor Atanasov
Is there a way to speed up the drawing, by not drawing
the polygons every time
Draw those static polygons onto a bitmap once and display that bitmap in
the
Post by Todor Atanasov
Post by R.Wieser
target window ?
Regards,
Rudy Wieser
[snip]
Post by Todor Atanasov
How can I do that? How can I combine this bitmap and the "refresh data"?
I also use BitBlt
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );

where the memDC is a CDC. So I have to simply select the polygon bitmap first with selectobject and then the memDC, which contains the refreshed things?
R.Wieser
2013-11-20 20:41:24 UTC
Permalink
Hello Todor,
Post by Todor Atanasov
So I have to simply select the polygon bitmap first with selectobject
and then the memDC, which contains the refreshed things?
That could work, provided that last bitmap is transparent where no polygons
have been drawn (otherwise it would fully obscure the first drawn one)..

But why not just draw the (static) polygon bitmap onto the target and than
draw the refreshed things (the dynamic polygons) directly ontop (instead of
first drawing them to yet another memory DC) ?

Hope that helps,
Rudy Wieser
Post by Todor Atanasov
Post by R.Wieser
Hello Todor,
I'm not sure how exactly its done in VC, but in another lanuage I've
been using the BitBlt command myself, which is a function in
GDI32.DLL.
In the draw event you first draw the bitmap and than the remaining
polygons over it. If you also need polygons drawn *under* you
would need to create a bitmap with transparency and use a 'draw
polygons under, draw bitmap, draw polygons over' sequence.
Hope that helps,
Rudy Wieser
I also use BitBlt
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
where the memDC is a CDC. So I have to simply select the polygon
bitmap first with selectobject and then the memDC, which contains
the refreshed things?
Todor Atanasov
2013-11-20 20:49:03 UTC
Permalink
Post by R.Wieser
Hello Todor,
Post by Todor Atanasov
So I have to simply select the polygon bitmap first with selectobject
and then the memDC, which contains the refreshed things?
That could work, provided that last bitmap is transparent where no polygons
have been drawn (otherwise it would fully obscure the first drawn one)..
But why not just draw the (static) polygon bitmap onto the target and than
draw the refreshed things (the dynamic polygons) directly ontop (instead of
first drawing them to yet another memory DC) ?
Hope that helps,
Rudy Wieser
Post by Todor Atanasov
Post by R.Wieser
Hello Todor,
I'm not sure how exactly its done in VC, but in another lanuage I've
been using the BitBlt command myself, which is a function in
GDI32.DLL.
In the draw event you first draw the bitmap and than the remaining
polygons over it. If you also need polygons drawn *under* you
would need to create a bitmap with transparency and use a 'draw
polygons under, draw bitmap, draw polygons over' sequence.
Hope that helps,
Rudy Wieser
I also use BitBlt
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
where the memDC is a CDC. So I have to simply select the polygon
bitmap first with selectobject and then the memDC, which contains
the refreshed things?
Hi Rudy,
So like this?

memDC.SelectObject(bitmap_polygons);
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
everything else now
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
R.Wieser
2013-11-21 08:33:29 UTC
Permalink
Hello Todor,
So like this? [snip]
Well, you seem to be drawing the MemoryDC (containing the static polygons)
twice: once before and once after "everything else", and that is not needed.

Just draw the MemoryDC to the current DC (which I take it is the one you
actually displaying) once at the begin, than draw "everything else".

Hope that helps,
Rudy Wieser
Hi Rudy,
So like this?
memDC.SelectObject(bitmap_polygons);
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
everything else now
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
Todor Atanasov
2013-11-21 11:31:50 UTC
Permalink
Post by R.Wieser
Hello Todor,
So like this? [snip]
Well, you seem to be drawing the MemoryDC (containing the static polygons)
twice: once before and once after "everything else", and that is not needed.
Just draw the MemoryDC to the current DC (which I take it is the one you
actually displaying) once at the begin, than draw "everything else".
Hope that helps,
Rudy Wieser
Hi Rudy,
So like this?
memDC.SelectObject(bitmap_polygons);
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
everything else now
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );
Thanks Ruby,
Will try it and will report back. I know this can be a stupid questions for some, but I am not that deep in GDI.

Todor
Todor Atanasov
2013-11-20 18:34:53 UTC
Permalink
Post by Todor Atanasov
Hi everyone,
I searched the group but didn't find anything.
I have 1000 polygons drawn on OnPaint() and some other stuff. Is there a way to speed up the drawing, by not drawing the polygons every time (but still see them of course) and only "refresh" the other stuff?
I also use double buffering to overcome the flickering.
I also use BitBlt
dc.BitBlt( rc.left, rc.top,
rc.right - rc.left,
rc.bottom - rc.top,
&memDC,
0, 0,
SRCCOPY );

where the memDC is a CDC. So I have to simply select the polygon bitmap first with selectobject and then the memDC, which contains the refreshed things?
Todor Atanasov
2013-11-30 09:51:11 UTC
Permalink
Post by Todor Atanasov
Hi everyone,
I searched the group but didn't find anything.
I have 1000 polygons drawn on OnPaint() and some other stuff. Is there a way to speed up the drawing, by not drawing the polygons every time (but still see them of course) and only "refresh" the other stuff?
I also use double buffering to overcome the flickering.
Ruby,
I funally got the time to test it and it worked like a charm :D Thanks again for the great help and advice.

Todor
R.Wieser
2013-11-30 17:16:32 UTC
Permalink
Hello Todor,
Post by Todor Atanasov
I funally got the time to test it and it worked like a charm :D
Thanks again for the great help and advice.
Nice to hear it did, and you're welcome.

And don't worry about the questions you asked, we all had to learn it at
some point. :-)

Regards,
Rudy Wieser


-- Origional message
Post by Todor Atanasov
Ruby,
I funally got the time to test it and it worked like a charm :D
Thanks again for the great help and advice.
Todor
Loading...