The imagelist image display is transparent. In XP, the 16-bit color display attribute is different from the 32-Color Display attribute.

Source: Internet
Author: User
The imagelist image display is transparent. In XP, the 16-bit color display attribute is different from the 32-Color Display attribute. Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiMultimedia/html/delphi_2006120700102477.html
Call up a bitmap from imagelist1 and display it in image1. Set image1.transparent to true. The 16-bit color is transparent, and the white box around the image is still displayed in 32-bit color.

Set the color quality in the display property to 32 bits.

Code As follows:
// 32-bit color environment with a white box
Procedure tform1.button1click (Sender: tobject );
Begin
Image1.transparent: = true;
Imagelist1.getbitmap (0, image1.picture. Bitmap );
End;

// 32-bit color environment without a white box
Procedure tform1.button1click (Sender: tobject );
Begin
Image1.transparent: = true;
Image1.picture.bitmap.loadfromfile('cms.bmp ');
End;

In addition, use image1.picture. bitmap. loadfromresource (hinstance, 'b1 '). That is, the image can be normally displayed after being transferred from the resource.

There is a problem with calling imagelist in 32 colors. In fact, other methods can solve this problem, but wondering why imagelist has this problem? Is it related to the imagelist option setting? I tried several options and it didn't work.

The 32-color environment you are talking about refers to a 32-color image? Or is the 32-Bit mode set on the screen?

The 32-color environment you are talking about refers to a 32-bit image? Or is the 32-Bit mode set on the screen?

The form's transparent ??

Maozefa (AFA)
The 32-color environment you are talking about refers to a 32-color image? Or is the 32-Bit mode set on the screen?
==========
In the 32-bit color environment, the screen is set to 32-bit color, the screen display attribute, and the "color quality" is set to "maximum (32-bit )". The hosts file is related to this file... I will try again, maybe.

Qzmp_ SC (You are a white cloud ~ I am a crow)
The form's transparent ??
==========
I am not talking about the form's transparent. It is to put an image on the form. The image is called out from imagelist as needed to make the image transparent.

I tried it. The BMP file only contains the following types: monochrome, 8-color, 256-color, and 24-bit colors. The BMP file does not contain 32-bit colors. I will explain it in detail; put an image component on the form, and then an imagelist component. Open the windows paint brush, create a 64*64 image, and fill it with white, draw a few red strokes (do not draw to the bottom-left corner), save it as a BMP file, change the size of imagelist to 64 × 64, and transfer the newly prepared BMP file. Put a button on the form.
Code:
Procedure tform1.button1click (Sender: tobject );
Begin
Image1.transparent: = true;
Imagelist1.getbitmap (0, image1.picture. Bitmap );
End;
At this time, image1 will display both the white background and the red pattern-the white part should be transparent.
Do not change Program , To the desktop, right-click and select "properties", go to the display settings to select the "color quality" of the desktop, change it to "medium (16 bits)", and then run this program, now the white part is transparent, and only the red pattern is displayed.

I just want to ask: is transparency related to the color quality settings of the desktop? However, another example shows that it is irrelevant:
Change the Desktop color to 32-bit.
Then change the code:
Procedure tform1.button1click (Sender: tobject );
Begin
Image1.transparent: = true;
Imagelist1.picture.bitmap.loadfromfile('1.bmp '); // 1.bmp is the image we just created
End;
Run now: we can see that in a 32-bit desktop environment, the white part of the image is transparent ~ I'm a little confused. Can you give me some advice?

I'm a little confused. Can you give me some advice?
========================================================== ============================================
I'm confused. I never tried what you said. My video card has been 32 bits. I ran your code and can display it transparently.

Whether you have installed a third-party unit or component similar to JPEG. Pas used to open graphical files. If yes, it may be related to these files.

Maozefa (a fa) () reputation: 110 blog 19:33:41 score: 0

I'm confused. I never tried what you said. My video card has been 32 bits. I ran your code and can display it transparently.
======================================
Haha, I have installed a lot of components on my machine. Now I am on a business trip and will try again when I have time to find another machine. Thank you for your attention. Have a good weekend and work hard for the overtime team.
Close the post first.

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.