Merge Images Using VB. NET and vb.net

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.