PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Please help ME

saurabhinindia · 05 Jun 2002, 20:49 UTC
hi!

i am new to Pocket PC world!

I need your help. Suppose i have to draw some rectangles, circles on the screen (using EVC) and now i want the user to select/mark some objects (like freehand using a stylus..)

How can i do that?

Please let me know.


Thanks

PS: do you know any links of the tutorial related to that?
Conan · 05 Jun 2002, 21:55 UTC — Samples in eVC
There are lots & lots of samples included with eVC and some of these cover the areas you are interested in.

If you want to make up your own code you need to read where the stylus is & draw a 'rubber band' shape around the object. On a design point I don't recommend dragging as this could scratch the screen so perhaps select just with individual taps?
Well, I can't provide any source, and don't know of any specific sites dealing with that type of thing. I can give you a few suggestions though.

What you are trying to create is an object-oriented, or vector paint program. In other words each graphic construct is represented internally by a virtual object, and is rendered to a bitmap for output to a display or printer. This is in contrast to a simple raster paint program, such as the one included with Windows, which just colors in pixels based on drawing activity. The latter scheme makes it impossible to manipulate individual drawing objects, because there is nothing to segregate them from one another.

Basically when the user "draws" they create an object, such as a rectangle. Instead of just drawing the pixels to the bitmap you store the rectangle's properties, such as the coordinates of the top-left corner and its size. In addition you can keep track of the thickness of the lines, line color, interior fill, etc.

Then when the user is in "select" mode, your software needs to map screen coordinates to objects. You will have to decide if the user must click on what is the border of the object, or if they can select by clicking on the interior as well.

You will also need a layer system to control the order of objects, which determines which objects are on top of other objects. That is pretty simple, as you just store all the objects in a linked list, with one end of the list representing the bottom, and the other the top. When drawing you render from bottom to top, when determining what the user clicked on, you do it in reverse.

Maybe that will get you on the right track. :)

Dan East
I just replied to saurabhinindia's private message regarding this as I didn't know there was a public post on this. This might be of use so I'll share what I sent him privately here.


Basically you create an offscreen memory DC and select a 240x320x24-bpp screen-sized bitmap into it. Everytime you draw a primitive to the primary surface, you draw the same primitive to the offscreen DC but with a solid, unique color. You also have to keep a display list of every primitive you draw and the associated unique color you used to draw it into the offscreen DC.

When the user picks a primitive on the screen with the stylus, you get the pixel position, then read that pixel's color in the offscreen bitmap. You then traverse your display list and look for a color match.

If you don't have a lot of primitives, you can get away with a 16-bpp or 8-bpp offscreen bitmap to save some space. You can also use the color value as an index into an array of pointers to structures to make the lookup process a bit easier.

What do you guys think?
Good to see you back Digby! I started replying to a private message as well, but caught the public post in time to copy it over. :)

That sounds like a great solution to determine the regions, and would lead to good code reuse since the same drawing primitives can used to blit to both bitmaps.

Dan East