How to create transparent images with VB6

Source: Internet
Author: User
Tags transparent image
We can see the background image through the previous image and call it a transparent image. We have seen many programs and TV programs that use transparent images, and everyone will be amazed at the transparency of the image. How is a transparent image made? Next we will discuss how to create this transparent image.
Five required steps for creating a transparent image:
Prepare two bitmap files, one as the background and the other as the source bitmap of the transparent image.
1. Obtain the long and wide data of the source bitmap. Save a Background Bitmap of the same size as the source bitmap. The Source bitmap will be drawn on this background bitmap. By displaying the transparent area of the bitmap with white pixels and the opaque area of the bitmap with black pixels, a monochrome mask that determines the transparency of the bitmap is created.
2. The bitmap of the monochrome mask pixel and the used Background Bitmap perform the "and" bitmap operation. The background is black in an opaque area.
3. Create a reverse copy with the monochrome mask in step 1, and then use this reverse copy with the source bitmap used for binary "and" operations, the transparent area of the source bitmap is black.
4. Use the modified background in step 2 and the source bitmap modified in step 3 to perform the binary "exclusive or" (Xor) bit operation. Then, you can see the background through the transparent bitmap.
5. Copy the result bitmap to the background.
Application instance:
Create a form Form1 that contains a CommandButton control and two PictureBox controls. Create a module (click "add module" in the "project" menu ").
Add the following controls to the form and set the relevant property values:
Control Name Property Settings
-----------------------------------------------------------------
PictureBox pictSource Picture = "C: Flower_Vine.bmp"
PictureBox pictDest Picture = "C: Stones_Blue.bmp"
Command button Command1 Caption = "transparent image"
---- Paste the following code into the declaration section of the form,
---- Option Explicit 'The code call process Transparent () copies the source bitmap to the target picturebox control, 'and turns it Transparent so that people can see the background image behind it.

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.