如何在asp.net中正确显示图像

时间:2016-12-16 04:39:31

标签: asp.net image

在我的应用程序中,我有3张图片,但没有显示正确的结果。我需要将3个图像显示为单个垂直我试过的代码

   using (Bitmap FinalBitmap = new Bitmap(Math.Max(img3.Width, Math.Max(img1.Width, img2.Width)),img1.Height + img2.Height + img3.Height))
 {
                using (Graphics FinalImage = Graphics.FromImage(FinalBitmap))
                {
                    // Draw the first image staring at point (0,0) with actual width and height of the image, in final image
                     FinalImage.DrawImage(img1, new Rectangle(0, 0, img1.Width, img1.Height));                 
                    // and Draw the second image staring at point where first image ends in the final image and save changes
                     FinalImage.DrawImage(img2, 0, img1.Height);                 
                     FinalImage.DrawImage(img3,  0,img2.Height);

                    FinalImage.Save();


                }
        }

谢谢

1 个答案:

答案 0 :(得分:0)

您创建的矩形需要是所有图像的高度。 Img1.Height + img2.Height + img3.height

当您绘制最后一张图像时,您需要从img1.height + img2.height

开始