01.10.2010, 21:21
(
Последний раз редактировалось Kyosaur; 01.10.2010 в 21:52.
)
IntToRGBA(Number, &Red, &Green, &Blue, &Alpha); by kyoshiro aka kyosaur
What is this?
This define is the inverse to THIS. It takes a color and returns its RGBA values. Its probably not as useful as the RGBAToInt function, but i decided to make it anyways for shits and giggles. Once again i made multiple versions and ran speed tests, the results are at the bottom.
Note: This can not be used inside of an if statement. I have no idea why someone would want to put it in one, i just thought i would say so for the n00bs.
Code (for those who dont care about the tests):
pawn Код:
#define IntToRGBA(%0,%1,%2,%3,%4) \
(%1) = ((%0) >>> 24); (%2) = (((%0) >>> 16) & 0xFF); (%3) = (((%0) >>> 8) & 0xFF); (%4) = ((%0) & 0xFF)
Speed results (10,000,000 loops)
Unfortunately i couldnt think of a way to break it down any further. If anyone can think of an improvement or another method, im all ears.
pawn Код:
#define IntToRGBA(%0,%1,%2,%3,%4) \
(%1) = ((%0) >>> 24); (%2) = (((%0) >>> 16) & 0xFF); (%3) = (((%0) >>> 8) & 0xFF); (%4) = ((%0) & 0xFF)
#define IntToRGBA2(%0,%1,%2,%3,%4) \
(%1) = ((%0) >>> 24); (%2) = (((%0) << 8) >>> 24); (%3) = (((%0) << 16) >>> 24); (%4) = (((%0) << 24) >>> 24)
#define IntToRGBA3(%0,%1,%2,%3,%4) \
(%1) = ((%0) >>> 24); (%2) = (((%0) * 256) >>> 24); (%3) = (((%0) * 65536) >>> 24); (%4) = (((%0) * 16777216) >>> 24)
IntToRGBA(1): R:28 || G:28 || B:81 || A:6 || Time: 4199ms
IntToRGBA(2): R:28 || G:28 || B:81 || A:6 || Time: 4332ms
IntToRGBA(3): R:28 || G:28 || B:81 || A:6 || Time: 4357ms
IntToRGBA(1): R:93 || G:173 || B:182 || A:3 || Time: 4147ms
IntToRGBA(2): R:93 || G:173 || B:182 || A:3 || Time: 4300ms
IntToRGBA(3): R:93 || G:173 || B:182 || A:3 || Time: 4310ms