Merge Images Using VB. NET and vb.net
In one scenario, I want to merge two images.
The first is on and the second is on. The height of the new image is equal to the height of the two images, and the width is equal to the width of the two images.
The most stupid way is to create an image and then assign values cyclically. However, the speed is too slow and the efficiency is too low.
Therefore, I want to use GDI + to draw images.
Public Function MergeImages (ByVal Pic1 As Image, ByVal pic2 As Image) As Image Dim MergedImage As Image Dim Wide, high As Integer High = Pic1.Height + pic2.Height If Pic1.Width> = pic2.Width Then Wide = Pic1.Width Else Wide = pic2.Width End If Dim bm As New Bitmap (Wide, High) Dim gr As Graphics = Graphics. fromImage (bm) Dim rect As New Rectangle (0, 0, Wide-1, High-1) gr. drawRectangle (Pens. white, rect) gr. fillRectangle (Brushes. white, rect) gr. drawImage (Pic1, 0, 0) gr. drawImage (pic2, 0, Pic1.Height) MergedImage = bm gr. dispose () Return MergedImageEnd Function
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.