Blit images of different sizes?

Sep 2, 2013 at 10:43 PM
Hi, first thanks for the WriteablebitmapEx library, it has help me write a cool app for Windows Phone and now I'm porting it to Windows RT.

I need to overlay an image on a background image, and am trying to use the blit functions. I've see the example where two images are overlayed, and both are the same size.

Can .blit merge two images of different sizes? In my app I'm adding small graphic elements to a large background image.

FYI, my app is using .Blit today to overlay two images of the same size, and it works perfectly:
            writeableBmp_Bkgrnd.Blit(
                new Rect(0, 0, writeableBmp_Bkgrnd.PixelWidth, writeableBmp_Bkgrnd.PixelHeight), wbAddOnTop,
                new Rect(0, 0, wbAddOnTop.PixelWidth, wbAddOnTop.PixelHeight),
                WriteableBitmapExtensions.BlendMode.Alpha);
Thanks!
Coordinator
Sep 3, 2013 at 7:51 AM
Sure, you can do that, but the destination rectangle should fit the size of the source image (wbAddOnTop) since the source is smaller, so check that destRect parameter and use the destination X and Y where the top should be overlayed and use the source rect's width and height.
  • Rene
Sep 5, 2013 at 5:58 AM
I got it working, thanks for the tip!

The code:
        writeableBmp_Bkgrnd.Blit(
            new Rect(wherex, wherey, wbAddOnTop.PixelWidth, wbAddOnTop.PixelHeight),
            wbAddOnTop,
            new Rect(0, 0, wbAddOnTop.PixelWidth, wbAddOnTop.PixelHeight),
            WriteableBitmapExtensions.BlendMode.Alpha);

-B