How to add a border in an image with C #

1

I would like to take an image and add a border at the top of the image (BMP). From what I researched I need

  • Load the image into an object
  • create a rectangle object
  • add the rectangle in the image
  • But I've never worked with an image in C #: (

    Example: This image

    Tostaythatway

        
    asked by anonymous 11.01.2017 / 14:31

    2 answers

    0

    I was able to solve this problem by concatenating two images.

                Image principal = Image.FromFile(@"ImagemPrincipal.jpg");
                Image logo = Image.FromFile(@"ImagemHeader.jpg");
    
                int imagemSaida_Width = principal.Width;
                int imagemSaida_Height = principal.Height + logo.Height;
    
                var imagemSaida = new Bitmap(imagemSaida_Width, imagemSaida_Height);
    
                using (principal)
                {
                    using (imagemSaida)
                    {
                        using (var canvas = Graphics.FromImage(imagemSaida))
                        {
    
                            canvas.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            // Definir plano de funda do arquivo de saida como Branco
                            canvas.Clear(Color.White);
    
                            // Adicionar o logo no arquivo de saida
                            canvas.DrawImage(logo, 0, 0);
    
                            // Adidionar principal no arquivo de saida
                            canvas.DrawImage(exame, 0, logo.Height);
                            canvas.Save();
                        }
                        imagemSaida.Save("ImagePrincipalComLogo.jpg");
                    }
                }
    
        
    11.01.2017 / 18:53
    0

    Hello, would you just change the sizes of the border's px no?!

    border-image-width: 10px 10px 10px 10px;
              (top) (right) (bottom) (left)

        
    11.01.2017 / 14:47