Working with image in C #

0

I have two images:

Atruntime,Ineedtomergethetwoimagestogether.Candeterminethepositionofthedollontheladder.Bothimagesareondisk.

Theresultwouldbeimagesliketheseinbase64:

  

Are there any libraries that can help me with this? Which are the   better?

Note: I am in an Asp.Net MVC .Net Framework 4 project

    
asked by anonymous 10.11.2015 / 14:21

1 answer

1

Use as follows:

var Ima = Image.FromFile(@"C:\Users\PC\Desktop\kOWnj.jpg");
var Imb = Image.FromFile(@"C:\Users\PC\Desktop\AlaDL.jpg");
Image IMGfinal = MergeTwoImages(Ima, Imb);

I already did with the 2 images:

public Bitmap MergeTwoImages(Image ImagemA, Image ImagemB)
        {
            if (ImagemA == null)
            {
                throw new ArgumentNullException("ImagemA");
            }

            if (ImagemB == null)
            {
                throw new ArgumentNullException("ImagemB");
            }

            int outputImageWidth = ImagemA.Width + ImagemB.Width;
            int outputImageHeight = ImagemA.Height + ImagemB.Height;

            int imagemAx = 0;
            int imagemAy = 100;

            int imagemBx = 140;
            int imagemBy = -10;

            Bitmap outputImage = new Bitmap(outputImageWidth, outputImageHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (Graphics graphics = Graphics.FromImage(outputImage))
            {
                graphics.FillRectangle(new SolidBrush(Color.White), new Rectangle(new Point(), new Size(outputImageWidth,outputImageHeight))); //fundo branco
                graphics.DrawImage(ImagemA, new Rectangle(new Point(imagemAx, imagemAy), ImagemA.Size), new Rectangle(new Point(), ImagemA.Size), GraphicsUnit.Pixel);//imagem 1
                graphics.DrawImage(ImagemB, new Rectangle(new Point(imagemBx, imagemBy), ImagemB.Size), new Rectangle(new Point(), ImagemB.Size), GraphicsUnit.Pixel);//imagem 2
            }

            return outputImage;
        }

You can also find other ways in this link .

    
10.11.2015 / 14:39