GLBasic forum

Main forum => GLBasic - en => Topic started by: Kyo on 2014-Oct-30

Title: Question about conversion Palette
Post by: Kyo on 2014-Oct-30
Hi,
when I read one pixel of a sprite with this system:
Code (glbasic) Select

LOADSPRITEMEM("1.png", w2%, h2%, pixels[])
FOREACH pix IN pixels[]
FOR x% = 0 TO value_palette
IF pix = memo[x][0]
pix =  memo[x][1]
BREAK
ENDIF
NEXT
        NEXT


the var pix return this value: -5462343
I have to convert in Hex (Exmple: #000301), it's possible?
Title: Re: Question about conversion Palette
Post by: Moru on 2014-Oct-30
This is one way of doing it:
http://www.glbasic.com/forum/index.php?topic=9975.msg87520#msg87520
Title: Re: Question about conversion Palette
Post by: erico on 2014-Oct-31
exactly! I havenĀ“t implemented it yet though. :-[
Title: Re: Question about conversion Palette
Post by: Kyo on 2014-Oct-31
Quote from: Moru on 2014-Oct-30
This is one way of doing it:
http://www.glbasic.com/forum/index.php?topic=9975.msg87520#msg87520

I have to use the command GETPIXEL/SETPIXEL or it's possible with this system?
Code (glbasic) Select

LOADSPRITEMEM("1.png", w2%, h2%, pixels[])
        FOREACH pix IN pixels[]
                FOR x% = 0 TO value_palette


-------------------------

I tried some tests, but I could not get anybody can help me?

First i read from a txt file a sequence of color value:
Code (glbasic) Select

#000301
#160000
#0e0300
#270000

after I compare with those in sprite on memory, and I have to replace them if they are equal, but when i read the pixel of the sprite in memory, he gives me these values:

Code (glbasic) Select

9474192
-5462343
-4605498
-3158058
Title: Re: Question about conversion Palette
Post by: Moru on 2014-Oct-31
The commands I posted above helps you convert the

9474192
-5462343
-4605498
-3158058

to rgb components
Title: Re: Question about conversion Palette
Post by: Kyo on 2014-Oct-31
Quote from: Moru on 2014-Oct-31
The commands I posted above helps you convert the

9474192
-5462343
-4605498
-3158058

to rgb components

ok and for this?

Code (glbasic) Select

#000301
#160000
#0e0300
#270000
Title: Re: Question about conversion Palette
Post by: kanonet on 2014-Oct-31
How should we know how you created/calculated that values? If you got them from someone else, ask him whats his formula.
Title: Re: Question about conversion Palette
Post by: Kyo on 2014-Oct-31
I export this value:
Code (glbasic) Select

#000301
#160000
#0e0300
#270000

with gimp (Export Palette .TXT)
Title: Re: Question about conversion Palette
Post by: kanonet on 2014-Nov-01
Since this are 6 digits, I guess its simply a hex number so 0x0e0300 = RGB(0x0e,0x03,0x00) = 918272 = RGB(14,3,0). But thats just a guess, I would recommend that you simply try it yourself. Of cause this would work perfectly together with SPRITE2MEM: 9474192 = 0x909090 = RGB(0x90,0x90,0x90) = RGB(144,144,144).
Title: Re: Question about conversion Palette
Post by: Kyo on 2014-Nov-01
Quote from: kanonet on 2014-Nov-01
Since this are 6 digits, I guess its simply a hex number so 0x0e0300 = RGB(0x0e,0x03,0x00) = 918272 = RGB(14,3,0). But thats just a guess, I would recommend that you simply try it yourself. Of cause this would work perfectly together with SPRITE2MEM: 9474192 = 0x909090 = RGB(0x90,0x90,0x90) = RGB(144,144,144).

OK Thanks  :good: