How do you manipulate Textures from code?

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Dark Light

FNG / Fresh Meat
Jul 11, 2012
55
0
0
I am wanting to draw a texture to the HUD, the texture I want to use is already in the game, I am managed to get it displaying fine. But I would like to change the black background to transparent and only leave the red channel. So I would like to do something like, new red = red, new green = 0, new blue = 0, new alpha = 255 - red.


Does anyone know how I can manipulate textures in this way?
 

Dark Light

FNG / Fresh Meat
Jul 11, 2012
55
0
0
Canvas.SetDrawColor(Canvas.DrawColor.R, 0, 0, 255);



All that will do it remove the green and blue channels, and set it to non-transparent. What I am wanting is to set the pixels that have no red in them to completely transparent, and the pixels that have some red in them to be semi transparent. So a pixel is no red is transparent, a pixel with 127 red is half transparent and a pixel with 255 red not transparent.
 

FZFalzar

FNG / Fresh Meat
May 11, 2011
128
3
0
UCC.exe
You can't. Do it with an image-editing program, save it with the alpha channel, load it into KFSDK and make sure the Alpha setting is checked. There is no way to modify a Texture's individual data after sticking it into a package
 

Skell

Active member
Mar 21, 2013
1,242
2
38
On the Internet.
If the texture has an alpha channel, you'll need it to be:
Code:
C.Style = ERenderStyle.STY_Alpha;
If it doesn't and you just want to make it so that it says full black is full opacity and white is no opacity, you'll need it to be:
Code:
C.Style = ERenderStyle.STY_Brighten;
EDIT:
or
Code:
C.Style = ERenderStyle.STY_Translucent;
Hope this helps!
 
Last edited: