paint thing

Blitz3D Forums/Blitz3D Beginners Area/paint thing

po(Posted 2003) [#1]
I am making a sort-of MS Paint clone thing(just to see if I could do it)and I am have trouble with being able to draw anything :( I have tried(for the pencil tool):
If MouseDown(1) :Rect MouseX(),MouseY(),1,1,1:EndIf
and I have also tried: pencil=LoadImage("pencil.bmp")
If MouseDown(1) :DrawImage pencil,MouseX(),MouseY():Endif

But those don't seem to work :(
Anybody know?


leeluna(Posted 2003) [#2]
Po,

Are you using blitz+ ?, If you are there is an example paint program in the samples directory:-

BlitsPlus\Samples\EdzUp\EpaintPlus.bb

You may pick-up the method from there.

Luna.


po(Posted 2003) [#3]
Nah, I'm using B3D


WolRon(Posted 2003) [#4]
Either a Rect or bitmap will work.
The problem may lie in the way you are drawing these images to the screen.

If you are drawing to the frontbuffer (NOT backbuffer) only and not using any pageflipping then you should be able to do as you are right now.

If you are using a loop and refreshing the screen by flipping then you need to create and draw to a seperate imagebuffer and copy this imagebuffer to the backbuffer every frame (otherwise the backbuffer and frontbuffer would each contain only bits and pieces of the image).


po(Posted 2003) [#5]
Oh, I was using back buffer and I was refreshing screen in loop.


WolRon(Posted 2003) [#6]
Think of it as having two pieces of paper and showing the user one or the other. If you drew a pixel on one(back) and then flipped it to the front and then drew a pixel on the back one again (which is now the original front) then flipped it again, you would be showing the user only the last pixel drawn and essentially only half of the image.
Sorry for the run on sentence.


jfk EO-11110(Posted 2003) [#7]
basicly all you need to do is:
setbuffer frontbuffer()
while not keydown(1)
if mousedown(1) then plot mousex(),mousey()
wend

of course, you can do this much more sophisticated in many ways.

maybe you should draw into the imagebuffer and then draw the image to the screen. this way you won't have troubles with the flipflop Screen-doublebuffer. example:
graphics 640,480,32,2
setbuffer backbuffer()

pencil=LoadImage("pencil.bmp") 
img=createimage(640,480)

while not keydown(1)
 cls
 if mousedown(1)
  setbuffer imagebuffer(img)
  drawimage pencil,mousex(),mousey()
  setbuffer backbuffer()
 endif
 drawimage img,0,0
 flip
wend


this way you can easily work with more than one image and diffrent image-sizes.
to save the image as a .bmp simply use the savebuffer command.

Personally I would use the entire screen for panting and popup a tools-menu when the right mousebutton was clicked, but other people prefere a standartized menu like in normal win apps.


ford escort(Posted 2003) [#8]
another method is to copy the backbuffer to the frontbuffer
with copyrect command for exemple
instead of using flip
copyrect 0,0,graphicswidth(),graphicsheight(),0,0,backbuffer(),frontbuffer()