hex to rgba.
#1

Hi,

How from hex for ex: 080808
Make RGBA? i want to use that in setobjectmaterialtext...
Reply
#2

You need to extract the channels with bitwise operations.

pawn Код:
new value = 0xFFFFFFFF; // value to extract channels from

new red = (value & 0xFF000000) >> 24;
new green = (value & 0x00FF0000) >> 16;
new blue = (value & 0x0000FF00) >> 8;
Reply
#3

And how to use red, green, blue new's?
Reply
#4

You pass that function a hexadecimal, just in the format of ARGB instead of RGBA. You can switch the R and A values like so:
pawn Код:
new color = 0xFFFFFFAA; // original color

new r = (color & 0xFF000000) >> 24;
new g = (color & 0x00FF0000) >> 16;
new b = (color & 0x0000FF00) >> 8;
new a = (color & 0x000000FF);

// the new color that you pass to SetObjectMaterialText
new value = ( ((a & 0xFF) << 24) | ((g & 0xFF) << 16) | ((b & 0xFF) << 8) | (r & 0xFF) );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)