Problrem with program...

Hello..
I'm a C-sharp beginner and I have a question: I've made a program that can draw shapes (like windows "paintbrush"), and I have this problem: When I draw a shape (for example , rectangle) , while its being drawed the shape itself "flickers" (I believe it's because that when im in "mouse-move" and im actually creating the shape its being created over and over again and thats why it disppears and reappears over and over and thats what causes the "flickering".. I would like to know what can I do about it? Thakn u..

Rotem

Comments

  • : Hello..
    : I'm a C-sharp beginner and I have a question: I've made a program that can draw shapes (like windows "paintbrush"), and I have this problem: When I draw a shape (for example , rectangle) , while its being drawed the shape itself "flickers" (I believe it's because that when im in "mouse-move" and im actually creating the shape its being created over and over again and thats why it disppears and reappears over and over and thats what causes the "flickering".. I would like to know what can I do about it? Thakn u..
    :
    : Rotem
    :

    I think you want to stop flickering when drawing images.
    I think this happens because when you are dragging your mouse the screen is refreshing - redrawing itself with the position of the mouse.

    Whenever i have used images i write them off screen, and then write the full image to the screen.
    Could you not some how use Threading to overcome this problem. I'm not sure how? hopefully someone will follow it up.
  • This is a big issue on slow machines so they invented buffers a lot of years ago. Like Ribbleton said, make a bitmap and draw everything on it, and in the paint func of the picturebox(or whatever you'r using), draw the bitmap.

    Some very bad psuedo code:
    [code]
    mousemove(){
    draw oldbitmap on bitmap
    draw rectangle on bitmap
    picturebox.refres()
    }
    mouseUp(){
    draw rectangle on oldbitmap
    }

    picturebox_paint(){
    draw bitmap
    }
    [/code]

    I hope you figure the rest out

    Happy coding wishes
    the one and only
    [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories