Page 1 of 1

PostPosted: Wed Aug 02, 2006 4:09 pm
by jnetzley
Was wondering if someone could help me.

I have set up a buffer with the background image and copied it to the screen. I am trying to make it so a drawn line on the screen can be erased but only the drawn line, nothing around it. I have only found 2 ways to do this:

One way (but really slow) is to go through each point of the line, do a GetPixel of each dot in the buffer, and 'pixel' this color onto the screen. The second way (faster) is to do a CopyRect on each point of the line from the clear background to the screen. The line algorithm I am using for this is:


This basically mimics the 'line' function in PocketC and copies the clear pixel from the background buffer onto the screen one pixel at a time, clearing the drawn line with the background.

The problem is this is reasonably slow (as I am copying over every pixel of the line.) Obviously, copying the background as one CopyRect and covering the whole line would be better, but the problem is that things are being drawn around the line and these would be cleared if I copied the box the line was in.

I have also tried some tricks like saving into a buffer under the line before the line is drawn, therefore allowing it to be copied back when you want to erase the line, but this doesn't work as, if there is anything updated on the screen in this box between the time the line was drawn and the time it needs to be erased, this info would be lost.

I am racking my brain over this one. I have considered doing it in native, but I can't believe there isn't a way to do this in PocketC.

Any help would be appreciated.

PostPosted: Wed Aug 02, 2006 4:26 pm
by jstadolnik
Try playing with the different draw modes with CopyRect. Erase or Mask modes may be useful.


The PToolboxLib guy.

PostPosted: Thu Aug 03, 2006 3:16 pm
by jnetzley
Yes, I believe it can be done this way. Let me ask you, what exactly does the 'Swap' function in CopyRect do? Is it affected by the source buffer at all or does it just affect the destination buffer? Does it actually copy anything? My first thought was that if the source buffer had black , it would copy as white to the destination and vice-versa, but it doesn't seem to work this way.

PostPosted: Thu Aug 03, 2006 3:24 pm
by jstadolnik
It does a bit wise XOR.


The PToolboxLib guy.