This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Dimensions bitmap and mask bitmap are not the same

Hi,
I'm trying this feature to merge 2 image but it has an exception
Dimensions bitmap and mask bitmap are not the same

Please help me
Thanks

This is my code

private void Combine2Image()
		{
			Bitmap sourceBitmap = new Bitmap(Server.MapPath("copyrose.jpg"));
			Bitmap maskBitmap = new Bitmap(Server.MapPath("ipod.png"));
			Bitmap desBitmap = new Bitmap();
								
			PngEncoderOptions pngEncoderOptions = new PngEncoderOptions(0;
						
			Combiner combiner = new Combiner();
			combiner.SourceBitmap = sourceBitmap;
			
			combiner.ApplyMaskTransform(sourceBitmap,maskBitmap,desBitmap);
			desBitmap.Save(Server.MapPath("aaa.png"),pngEncoderOptions);
					
			
		}
Hello,

If you need to merge two bitmaps into one you should use the following code:
Bitmap bitmap1 = new Bitmap(Server.MapPath("copyrose.jpg"));
Bitmap bitmap2 = new Bitmap(Server.MapPath("ipod.png"));

Combiner combiner = new Combiner();
try
{
    combiner.SourceBitmap = bitmap1;
    combiner.ApplyTransform(bitmap2);
}
finally
{
    combiner.Dispose();
}
bitmap2.Save(Server.MapPath("dest.png));
This code sample draws bitmap1 onto bitmap2, and then saves it to PNG format.