Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Cannot store RGBA values in in integer when RED > 127

Author
Message
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 30th Mar 2020 21:52
When I do this, the number become negative. Is there a way to store an RGBA value inside a variable without losing value ?
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 30th Mar 2020 22:06 Edited at: 30th Mar 2020 22:16
It depends on how you're attempting to access / use the Data.
Remember that by default an AppGameKit Integer is a 32-bit Signed Variable., so if you're just doing "Normal" Mathematics with it... it'll behave as a value between 2,147,483,647 > 0 > -2,147,483,648
Unlike most Languages (like DBP for example) that uses an Unsigned 32-bit., thus it's a value between 0 > ‭4,294,967,295‬

Bitwise Mathematics however are exclusively unsigned by nature... because you're working with the Bits themselves, and those can only have 2 States (On / Off or 1 / 0)
This means these


Work perfectly... and as a note., these specifically convert between AppGameKit's ABGR and Dark BASIC Professional's ARGB Pixel Formats.
Oh and while this is AppGameKit "Code" so-to-speak., it'll work identically on Dark BASIC Professional.
Now while these don't actually "Return" the individual Alpha, Red, Green, Blue Terms... if you look at the "To" Functions, strictly speaking that's exactly what I'm going to basically Flip the Red and Blue Channels to each format.
So if you want the specific Colour from said format; then:



Should return the correct 0-255 Value.
I mostly use these Functions because I prefer to use Hexidecimal Definitions for Colours... used for Browsers, Photoshop, Microsoft Paint, Maya, etc.
It's just easier to use with 0xRRGGBBAA (i.e. 0xFF0000FF = 100% Brightness Red), then I can use these Functions to convert it to the same Colour as AppGameKit would use.
Freddix
AGK Developer
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 30th Mar 2020 22:36 Edited at: 30th Mar 2020 22:38
@Raven : It's what I've understood (differency between dbpro & appGameKit)
In fact I compose RGBA values and I extract R,G,B,A from RGBA values
But I have found a workAround.

Your functions are nice but for memblock AppGameKit uses RGBA and not ARGB

I have also discovered that AppGameKit sometimes dislike Function as a parameter for another function call ... I'll try to reproduce the issue if possible (it said me offest 4107 is higher than memblock size 4108 ... loool)

Login to post a reply

Server time is: 2024-11-22 05:22:13
Your offset time is: 2024-11-22 05:22:13