Jump to content

Set color tranparent to a region in an image

Recommended Posts


I'm looking for a way to apply a transparent color to a region in an image (crop a rect into the image).

In the helpfile, I found _GDIPlus_BitmapSetPixel but I don't know if there is a constant for the transparent color (and if there is a faster way).

The goal is to build some puzzle pieces from a bitmap


Thanks in advance



Share this post

Link to post
Share on other sites

Hi jguinch!

I don't have a code to your question. But, see this post: https://www.autoitscript.com/forum/topic/174611-have-some-autoit-code-to-cut-a-image-in-png-file/

This code can found every neighboor pixel with same color, the result of all neighbor pixels is an array.

With this array you can re-paint or apply the transparency.

I thinking in this way, you get the pixel in this format:

0xTTRRGGBB (TT: transparency, RR, GG, BB) and change the TT's value to 0 (or other value).

You can obtain the pixel color with tranparency with _GDIPlus_BitmapGetPixel.

Br, Luigi.

Edited by Luigi

Share this post

Link to post
Share on other sites

A faster solution is to use _GDIPlus_BitmapLockBits. Check out the help file for an example.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites


Luigi : I want to apply a transparency to a region, not depending of a pixel color. Your link is still interesting.

Danyfirex : nice, it works (it risks to be slow for several images, but it's a very good way).

UEZ : OK, i will try it and come with either the solution, or probably questions.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...