Draw a rectangle over an image

Dec 3, 2013 at 1:37 PM
Hi ,
I'm trying to use the library in a Metro UI C# app.
I have an Image control filled with an image and I'm trying to draw a red rectangle in some x,y coordinates.
I have used so far from the samples the below code
 public WriteableBitmap ParticleBitmap;
Rect sourceRect = new Rect(0, 0, 32, 32);
Target.Source = ParticleBitmap;
   ParticleBitmap = BitmapFactory.New(512, 512);

 using (var bitmapContext = ParticleBitmap.GetBitmapContext())
                // Init some size vars
                int w = ParticleBitmap.PixelWidth - 2;
                int h = ParticleBitmap.PixelHeight - 2;
                int wh = w >> 1;
                int hh = h >> 1;

                //// Clear 

                ParticleBitmap.DrawRectangle(rand.Next(wh), rand.Next(hh), rand.Next(wh, w), rand.Next(hh, h),


            // Invalidate
So far I can draw the rectangle with the above code and by writing the below
Target.Source = ParticleBitmap;
I can succesfully draw a rectangle.

I have a second image control which contains the original picture.
How am I suppose to take the particlebitmap and display it over my original control ?

I tried to use the blit method but I cannot make it work.
The examples are not compiling.
I tried also the below but nothing happened
        WriteableBitmap TargetBitmap = BitmapFactory.New(512, 512);

        //Rect sourceRect = new Rect(0, 0, 32, 32);
        Point mypoint;
        mypoint.X = 10;
        mypoint.Y = 20;

        using (TargetBitmap.GetBitmapContext())
            TargetBitmap.Blit(mypoint, ParticleBitmap, sourceRect, Colors.Red, WriteableBitmapExtensions.BlendMode.Additive);


        Target1.Source = TargetBitmap;
Is there any simple example to draw a rectangle over an image ?

thank you