Quantcast
Channel: WPF Paint App with WriteableBitmap
Viewing all articles
Browse latest Browse all 4

WPF Paint App with WriteableBitmap

$
0
0

Hi, I have been currently developing a Pain app using WriteableBitmap +  http://writeablebitmapex.codeplex.com/ (Extended WriteableBitmap) in VisualStudio 2010 using WPF.

In the first day i encountered the first obstacle;

==================================================================================

 

===============================================================================================

It seems that the event OnMouseMove isn't called as frequently as it is needed.

Here's my code ( I know that there just a few lines of codes :D i've just started my Project )

 

namespace Bitmap___Paint_Application
{publicpartialclass MainWindow : Window
    {static WriteableBitmap wbitmap;public MainWindow()
        {
            InitializeComponent();
            bitmap();
        }void bitmap()
        {
            wbitmap = new WriteableBitmap(900, 500, 96, 96, PixelFormats.Bgr32, null);
            myCanvas.Source = wbitmap;
            myCanvas.Stretch = Stretch.None;
            wbitmap.FillRectangle(0, 0, 900, 500, Colors.White);
        }privatevoid myCanvas_MouseMove(object sender, MouseEventArgs e)
        {
                Point position = e.GetPosition(myCanvas);
                wbitmap.SetPixel((int)position.X, (int)position.Y, Colors.Black);
        }
    }
}

One more thing, i can handle drawing lines, i am just having problems with freehand draw - the "spaces" that appear while drawing.

 



Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images