RGBAtoARGB
#1

Hi,

I'am using this function:

Код:
RGBAToARGB(color)
{
	new alpha = color & 0xFF;
 	return ((color >>> 8) | (alpha << 24));
}
It's good function?

And then i want player let write hex code in dialog, when i format it like that

Код:
format( Writenhexcode, 20,"0x%sAA", inputtext );
Код:
new hexxxxx = HexToInt( Writenhexcode );

YOURHHEEX[ playerid ] = hexxxxx;



And then i use:


RGBAToARGB(YOURHHEEX[ playerid ]);
Reply
#2

If you need convert string RGB to RGBA (player color)
PHP код:
new hexxxxx HexToInt(Writenhexcode); //example Writenhexcode is "FF6600" orange
YourColor[playerid] = RGBToRGBA(hexxxxx) + alpha//you color is 0xFF660000 + alpha 
RGB Include:
https://sampforum.blast.hk/showthread.php?tid=590770
Reply
#3

But my writen is good or no?
Reply
#4

in your example, the value will be in the format RGB

PHP код:
new hexxxxx HexToInt(Writenhexcode); //FF6600
YOURHHEEX[playerid] = hexxxxx;

YOURHHEEX[playerid] = RGBAToARGB(YOURHHEEXplayerid ]); // return 0x0000FF66 and should 0xFF660000 
Reply
#5

new hexxxxx = HexToInt(Writenhexcode); //example Writenhexcode is "FF6600" orange
YourColor[playerid] = RGBToRGBA(hexxxxx) + alpha; //you color is 0xFF660000 + alpha

alpha what i need to write?
Reply
#6

mistake
Код:
RGBToRGBA(color,alpha);
Example:
PHP код:
YourColor[playerid] = RGBToRGBA(hexxxxx,0xFF); 
Reply
#7

I don't want to download all that include, can you make little function RGBToRGBA ?
Reply
#8

PHP код:
#define RGBToRGBA(%0,%1)            (((%0) << 8) | (%1)) 
Reply
#9

Because i want player write hex code and use it in SetObjectMaterialText, i can use?


Код:
format( blabla, 49,"Your color is:{%06x}COLOR", SAVEDHEXCODE[ playerid ] >>> 8);
SAVEDHEXCODE is

SAVEDHEXCODE[ playerid ] = HexToInt( inputtext );

Can i use that format to show color?
Reply
#10

PHP код:
SAVEDHEXCODEplayerid ] = HexToIntinputtext ); //string "FF6600" Int 0xFF6600 is RGB
formatblabla49,"Your color is:{%06x}COLOR"SAVEDHEXCODEplayerid ]); //<--- Your color is:{FF6600}COLOR 
For Set(Dynamic)ObjectMaterial
PHP код:
#define RGBToARGB(%0,%1) ((%0) | ((%1) << 24))
color RGBToARGB(SAVEDHEXCODEplayerid ],0xFF); //0xFFFF6600 
For player color:
PHP код:
#define RGBToRGBA(%0,%1)            (((%0) << 8) | (%1))  
color RGBToRGBA(SAVEDHEXCODEplayerid ],0xFF); //0xFF6600FF 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)