On Oct-20-06, at 4:46 PM, realbasic-nug-
[EMAIL PROTECTED] wrote:
I'm stuck on this one. I thought I had looked at an example where
this was possible but I either can't find it or I'm imagining it.
Are you thinking of the old DragPics example, perhaps?
I have a canvas that I set the backdrop to a picture.
I create a picture with transparent set that is the same size as the
canvas.
Then I draw the picture into the canvas.
This works and I can draw in the picture which I re-draw to the
canvas and the backdrop picture shows through.
I guess it would -- but note that this works only because you're using
one-bit transparency. If you used a masked picture instead, this
wouldn't work too well, because you'd be drawing the semitransparent
parts multiple times (causing them to get more solid each time).
But when I try to "erase" in the picture it does nothing.
What do you mean by erase, and what do you expect it to do?
By erase I meant that any pixels under the "eraser" cursor would be
set to white which would then be transparent since I set white to
transparent for the picture. Then I expected the backdrop picture to
show through.
If transparent is set I can not set the pixels to white so I can't
get
the effect of erasing and leaving the backdrop image untouched.
Hmm, I'm quite sure you CAN set pixels to white in a transparent
picture; of course this makes them transparent. If you then draw this
picture someplace, those pixels will not get drawn. This will of
course not cause the backdrop to magically reappear -- you've simply
refrained from drawing over the old drawing of the picture in those
places.
I didn't think it was working because when I would re-draw the
picture in the canvas the area I thought I was erasing was still
showing. After reading your reply it made sense that the picture that
was in the canvas was still there. So it was showing through the new
picture transparent areas. If I clear the canvas each time before re-
drawing the picture I see that it does work and I am in fact setting
the pixels to white which makes them transparent.
But my backdrop gets cleared at the same time.
If by "erase" you mean cause the backdrop to reappear, then of course
you have to draw the backdrop in those places. (Or refresh the
canvas,
but that's not a very good idea.)
It sounds to me like you're doing animation over a backdrop, in which
case your technique of just overdrawing any previous content with a
transparent picture is not appropriate. On a double-buffered system
like OS X, whenever the content changes, you should:
1. Draw the backdrop
2. Draw the foreground
On a non-double-buffered system like Windows, you should:
1. Make a "buffer" picture the same size of your canvas
2. Draw the backdrop into your buffer
3. Draw the foreground into your buffer
4. Draw the buffer into the canvas
Note that the buffer is not transparent at all, so overdrawing with
that is just fine.
Maybe I need to rethink the way I'm trying to do this.
Here is what I'm trying to accomplish. I have a form that gets
displayed. I want to be able to display a static background picture
in a canvas on the form and provide basic tools like in a simple
paint application that allows the user to be able to draw over the
picture. But if they want to erase something they added I don't want
the background picture to get erased.
Then, when the form is saved, I save all the input in the fields and
I wanted to save just what they have drawn over the static background
picture. If the form is re-opened I would then display the original
static background picture with what they have drawn over top of it.
So I had set up a buffer to draw into. Then I draw the buffer picture
into the canvas. Handling the erasing part and trying to keep the
static picture separate from the user drawn input is giving me problems.
Maybe I should be creating a mask for the user input drawing? I
realize I don't really understand the way everything gets redrawn.
Any suggestions on what I can read that explains this and could help
with what I'm trying to accomplish? A specific book, or article on
RBLibrary that would be appropriate?
Thanks,
Peter
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>