Jump to content

Set color tranparent to a region in an image


jguinch
 Share

Recommended Posts

Hello

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

 

 

Link to comment
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

Visit my repository

Link to comment
Share on other sites

Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks.

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.

 

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...