BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Rubber-bands: to XOR or Blt?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Shawn Oster
Guest





PostPosted: Fri May 20, 2005 5:43 pm    Post subject: Rubber-bands: to XOR or Blt? Reply with quote



I'm doing the run of the mill rubber-band with handles and I'm curious which
method of handling the rubber-banding would be fastest?

A. XOR

1. MouseDown: change pen to dotted, draw rect
2. MouseMove: XOR rect, calc new rect, draw rect
3. MouseUp: XOR rect, change pen to solid, draw rect

B. BitBlt

I haven't actually done this method before so I may have some steps off but
it seems like it would go something like this:

(Assuming TPaintBox with a BitBlt of Buffer in the OnPaint event)

1. MouseDown: Buffer image, store rect
2. MouseMove: InvalidateRect(rect), calc new rect, draw rect directly to
TPaintBox (NOT on Buffer)
3. MouseUp: Draw new rect to Buffer, InvalidateRect

It's been a few years since I've done the whole rubber-band/handles code and
I'd like something that feels and looks professional
(Illustrator/Corel/Visio/etc)

Thanks,
Shawn


Back to top
Max
Guest





PostPosted: Sat May 21, 2005 1:36 am    Post subject: Re: Rubber-bands: to XOR or Blt? Reply with quote



Can you provide a source example of the B method?


"Shawn Oster" <soster (AT) colorflex (DOT) com> schrieb im Newsbeitrag
news:428e21d5$1 (AT) newsgroups (DOT) borland.com...
Quote:
I'm doing the run of the mill rubber-band with handles and I'm curious
which
method of handling the rubber-banding would be fastest?

A. XOR

1. MouseDown: change pen to dotted, draw rect
2. MouseMove: XOR rect, calc new rect, draw rect
3. MouseUp: XOR rect, change pen to solid, draw rect

B. BitBlt

I haven't actually done this method before so I may have some steps off
but
it seems like it would go something like this:

(Assuming TPaintBox with a BitBlt of Buffer in the OnPaint event)

1. MouseDown: Buffer image, store rect
2. MouseMove: InvalidateRect(rect), calc new rect, draw rect directly to
TPaintBox (NOT on Buffer)
3. MouseUp: Draw new rect to Buffer, InvalidateRect

It's been a few years since I've done the whole rubber-band/handles code
and
I'd like something that feels and looks professional
(Illustrator/Corel/Visio/etc)

Thanks,
Shawn





Back to top
Solerman Kaplon
Guest





PostPosted: Sat May 21, 2005 11:58 am    Post subject: Re: Rubber-bands: to XOR or Blt? Reply with quote



Shawn Oster escreveu:
Quote:
I'm doing the run of the mill rubber-band with handles and I'm curious which
method of handling the rubber-banding would be fastest?
[snip]


XOR will be faster (and easier), but on today's hardware, very unlikely you will
notice difference in speed. The problem is flickering with the second method,
drawing the rubber-band and restoring the buffer may become visible to the end
user. But if you gonna implement more advanced drawing operations, you will end
up needing to implement double buffering anyway so it may not be an issue. And
with double buffering you can just draw the whole image directly instead of
copying the buffer around, and may be faster than the initial approach
considering the different requeriments. I remember that Graphics32 has support
for rubber-band and already implement buffered drawing, maybe it feets what you
need?

Solerman

Back to top
Shawn Oster
Guest





PostPosted: Tue May 24, 2005 10:04 pm    Post subject: Re: Rubber-bands: to XOR or Blt? Reply with quote


I can no problem but it's not very attractive. Just a BitBlt in the area I
just covered up, let me know if you still want it.

"Max" <nospam (AT) nospam (DOT) com> wrote

Quote:
Can you provide a source example of the B method?




Back to top
Shawn Oster
Guest





PostPosted: Tue May 24, 2005 10:06 pm    Post subject: Re: Rubber-bands: to XOR or Blt? Reply with quote


"Solerman Kaplon" <solerman (AT) nospamplease (DOT) wonder.com.br> wrote

Quote:
Shawn Oster escreveu:
I'm doing the run of the mill rubber-band with handles and I'm curious
which method of handling the rubber-banding would be fastest?
[snip]

XOR will be faster (and easier), but on today's hardware, very unlikely
you will notice difference in speed. The problem is flickering with the
second method, drawing the rubber-band and restoring the buffer may become
visible to the end user. But if you gonna implement more advanced drawing
operations, you will end up needing to implement double buffering anyway
so it may not be an issue. And with double buffering you can just draw the
whole image directly instead of copying the buffer around, and may be
faster than the initial approach considering the different requeriments. I
remember that Graphics32 has support for rubber-band and already implement
buffered drawing, maybe it feets what you need?

I've been avoiding the G32 library simply because I'm trying to make
something very light-weight but I may need to look at that library as I
start doing things like rotation and text-wrapping. I went ahead and did
the double-buffered approach because I wasn't a fan of the XOR color.
Thanks for the reply, it reminded me I already had a buffer I could use for
such operations.

Shawn



Back to top
Max
Guest





PostPosted: Tue May 24, 2005 10:40 pm    Post subject: Re: Rubber-bands: to XOR or Blt? Reply with quote

Quote:
just covered up, let me know if you still want it.

Yes, sure! I have currently the same problem. I do not know what solution is
better at this time ...




Back to top
Shawn Oster
Guest





PostPosted: Thu May 26, 2005 6:18 pm    Post subject: Re: Rubber-bands: to XOR or Blt? Reply with quote

Ok, I'll just zip up a basic project and drop it in the attachments group.

"Max" <nospam (AT) nospam (DOT) com> wrote

Quote:
just covered up, let me know if you still want it.

Yes, sure! I have currently the same problem. I do not know what solution
is
better at this time ...



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.