This project is read-only.

issues using blit for simple 'color me' (coloring picture) app: inkmanager's size limited to strokes

Apr 8, 2013 at 8:45 PM
Am trying to develop a simple 'color me' app for kids on winRT. I have a canvas that shows a simple line drawing of something kids can color using touch.
For capturing the strokes I use an inkmanager.
I would like to render an image with the 'background' line drawing and the strokes on the inkmanager.
When using the blit function I run into trouble since the inkmanager (by design it seems) reports a size that is a rectangle around the strokes. For my scenario I would like the inkmanager to take into account the whole canvas, i.e. essentially I would then be blitting two images of the exact same size (one with the background line drawing, and one with the stroks from the inkmanager).

Can someone help me out here? It seems to me that this should be easy, but can't get it to work. Tried experimenting with several settings for the rectangles as parameters for the blit function to no avail...

Apr 9, 2013 at 8:37 AM
I guess that thread can help you:
  • Rene
Apr 9, 2013 at 1:35 PM
I previously have had a look at the thread, however I still cannot figure out how to get it to work properly. A bit more explaining would be helpful.. should I indeed focus on doing something with the rectangles?
Apr 15, 2013 at 8:14 AM
My current code is this:
//Image background
            var backgroundBmp = await BitmapFactory.New(1, 1).FromContent(new Uri(BackgroundImage));
            //Image foreground
            WriteableBitmap foregroundBmp;
            using (InMemoryRandomAccessStream a = new InMemoryRandomAccessStream())
                await _inkManager.SaveAsync(a);
                foregroundBmp = await new WriteableBitmap(1, 1).FromStream(a,BitmapPixelFormat.Bgra8);
            // Combined
            backgroundBmp.Blit(new Rect(0, 0, foregroundBmp.PixelWidth,foregroundBmp.PixelHeight), foregroundBmp, new Rect(0, 0,backgroundBmp.PixelWidth,backgroundBmp.PixelHeight), WriteableBitmapExtensions.BlendMode.Alpha);

            // Save
            FileSave = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(TempFileNameForDrawing, CreationCollisionOption.ReplaceExisting);
            Guid encoderId = Windows.Graphics.Imaging.BitmapEncoder.PngEncoderId;
            await WinRTXamlToolkit.Imaging.WriteableBitmapSaveExtensions.SaveToFile(backgroundBmp, FileSave, encoderId);
In the backgroundBmp.Blit line I use the rectangle from the foregroundBmp and the backgroundBmp. They are however different in size, which you would expect since the inkManager on which the foregroundBmp is based only returns the actual strokes and the rectangle bounding those. How would I go about getting the inkmanager to return the full canvas?