| |

VerySource

 Forgot password?
 Register
Search
View: 725|Reply: 4

How do I draw a HICON icon and how to use GDI + Graphics object?

[Copy link]

3

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-3 11:40:02
| Show all posts |Read mode
I got a HICON handle. I tried to use the Bitmap class constructor (HICON hIcon) to create a Bitmap object, and then used Graphics' DrawImage to draw the picture, but the icon became opaque (annoying!). Is there any way to do it in Graphics A transparent icon is drawn on the top. Thank you heroes, I ca n’t find a way.
Reply

Use magic Report

1

Threads

2

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-4 00:28:22
| Show all posts
Novice passing by! !! !! !! !! !!
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-5 19:18:01
| Show all posts
That seems to involve pixel mixing. It's not as simple as you think. You must first take out the piece of land (rect) to be covered by the bitmap to save it, then determine the color depth, then mix it, and draw it out. The alpha blending Blit is very similar.
Pseudo-ma:
RGB16bit 565 color depth
pixel_high = pixel&(1111100000011111) b // take the high bit
pixel_mid = pixel&(0000011111100000) b // take the median
pixel_low = pixel&(0000000000011111) b // take the lower bit
pixel_rect is similar
pixeled_high = pixel_high * alpha + pixel_rect_high (1-alpha)
pixeled_mid = pixel_mid * alpha + pixel_mid_high (1-alpha)
pixeled_low = pixel_low * alpha + pixel_low_high (1-alpha)
Finally, draw the pixeled soil.
Alpha is a parameter between 1, 0. Setting the size can change the transparency.
There are better algorithms, I ca n’t remember, you can go online to check
I wrote this algorithm down from the book. I have n’t actually used it yet. Do n’t blame me if you have a mistake.
But if you want to get a dynamic transparency effect, it will not work without mixing pixels! !!
Reply

Use magic Report

3

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-7 03:09:01
| Show all posts
This had to do so, thank you.
Microsoft's obscenity, isn't it enough to get a DrawIcon function in Gdiplus? Look at none in his profile! There is a DrawIcon function in .Net FrameWork, but it is separated from MFC, which is useless.
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-25 11:36:01
| Show all posts
Any graphic image is only valid if it is converted into a data stream. There is no difference between the icon and the bitmap when it is finally displayed. It is just the method, size, and decompression algorithm (the bitmap does not seem to be different). No, novice, I dare not say too much.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list