Link to home
Start Free TrialLog in
Avatar of Zoppo
ZoppoFlag for Germany

asked on

Does anybody know how MS-Paint works ???

Hi all,

While drawing (positioning the second control point of) a line (or circle or rectangle) with any line width and color in MS-Paint you can see that the whole line is drawn in one color independent of the pixels beyond the line (so no 'xor-drawing'). Even you can see no flickering.

I want to know if anybody knows how this is implemented (samples appreciated).

regards,

ZOPPO
ASKER CERTIFIED SOLUTION
Avatar of nils pipenbrinck
nils pipenbrinck

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zoppo

ASKER

Hi nils,

thanks for reply ...

Do you really think it's such simple?

If this works as you told, there would be following steps proceeded each time the mouse moves:

1. BitBlt from the original bitmap to a memory device context
2. Draw the line(circle) to memory device context
3. BitBlt from the memory device context to screen

for full screen size windows on slow computers this is a lot of work. Can you imagine how slow this will work on an old 80386 with a slow graphics card?

Further I do not know any other graphics programm which does drawing like this.

I'm not sure ... I'll let this question open for a while to see if other experts have comments on this.

ZOPPO
Avatar of nietod
nietod

Zopo, that is the way it is done (and I think you explained it better).  
To speed things up, you only do the BitBlt()ing for the clipping box (rectangle), rather than the whole bitmap.  It will go faster that way.  And yes it can get slow, or at least it did on old computers, especially when the object being drawn got large.  (Drawing a large circle on a 286 was noticably slow, you could move the mouse and wait a second before the circle "popped into place".)

but on a any half-decently modern computer it will go very fast.  I use this technique and don't see any speed problems with it, even with large bitblt's.
Avatar of Zoppo

ASKER

ok, I believe it :)

thank you also, nietod ...

ZOPPO
yep.. after re-reading my message I must agree, that it my explanation is a little bit messy..

nils