Question about conversion Palette

Previous topic - Next topic

Kyo

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?


erico

exactly! I haven´t implemented it yet though. :-[

Kyo

#3
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

Moru

The commands I posted above helps you convert the

9474192
-5462343
-4605498
-3158058

to rgb components

Kyo

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

kanonet

How should we know how you created/calculated that values? If you got them from someone else, ask him whats his formula.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Kyo

I export this value:
Code (glbasic) Select

#000301
#160000
#0e0300
#270000

with gimp (Export Palette .TXT)

kanonet

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).
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Kyo

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: