How can I merge 2 images on Windows Phone
Asked Answered
M

1

5

I have 2 images and I want to merge them into one on my apps in Windows Phone.

The first image captured by my WP's camera, the second image is a frame (borders, filter, etc.) which user can choose among our templates. So how can I merge them into one.

Thanks and best regards.

Mezoff answered 11/4, 2012 at 4:38 Comment(5)
It's not clear what you're looking to do.Libertine
@ Michael Petrotta : I edited it.Mezoff
Can you explain what you mean by "merge", exactly, on a pixel level?Libertine
I mean the border frame overlaps the captured picture, just like 2 layers on photoshop.Mezoff
So you want to add the pixel values? What do you want to do if both images encode non-black values for the same pixel, or will that never happen?Libertine
T
7

I don't quite understand what you ask. But I guess you want to overlay 1 image on top of another. If so, there is already an answer here. Inside the <grid>, you can provide both the image, and customize the opacity of each image to make it overlay-ed.

EDITED: You can use Writeablebitmap for that and there's an already library for that here. After adding the WriteableBitmapExWinPhone in your WP7 project, you can merge the image and frame by doing this:

    var photo = ...//you writeablebitmap of image here
    var frame = ...//your writeablebitmap of frame here
    var merge = new WriteableBitmap(435, 435); //size of merge canvas
    merge .Clear(Colors.White); //white background
    merge.Blit(new Rect(oX, oY, w, h), photo, new Rect(0, 0, photo.PixelWidth,        photo.PixelHeight)); //draw the photo first
    merge.Blit(new Rect(0, 0, 435, 435), frame, new Rect(0, 0, frame.PixelWidth,        frame.PixelHeight)); //draw the frame
Trueblood answered 11/4, 2012 at 5:2 Comment(1)
Thank Agung Pratama: just what I want to do.Mezoff

© 2022 - 2024 — McMap. All rights reserved.