Skip to main content
GameDev.net gamedev.net
🔒 Locked

Colorpicker

Started by NewDeal Jan 20, 2001 at 6:09 PM 0 replies 300+ views
Original Post
NewDeal
NewDeal
I know this is easy but somehow i cant figure it out. You know those color tables in graphics programs. I need an algorithm for drawing a 16bit colortable representing all 65000 some colors. Any help will be very appreciated. Thanks
forgotton_associator
forgotton_associator
My info's kinda useless i spoze.....

void __16BitINC565(DWORD 16BitValueP, BYTE C565)
{__asm{
PUSHAD

MOV EDI, 16BitValue
MOV BL, C565
MOV AX, WORD PTR [EDI]
MOV CX, AX
MOV DX, AX

CMP BL, 1
JGE __565Decode

AND CX, 31
AND AX, 992
SHR DX, 10
SHR AX, 5
JMP __5x5Continue

__565Decode:
AND CX, 31
AND AX, 2016
SHR DX, 11
SHR AX, 5

__5x5Continue:
INC CX
CMP CX, 31
JLE __555Restore

XOR CX, CX

INC AX
CMP BL, 1
JGE __565RestofCode

CMP AX, 31
JLE __555Restore

XOR AX, AX
INC DX
CMP DX, 31
JLE __555Restore
XOR DX, DX
JMP __555Restore

__565RestofCode:
CMP AX, 63
JLE __565Restore

XOR AX, AX
INC DX
CMP DX, 31
JLE __565Restore
XOR DX, DX
JMP __565Restore


__555Restore:
SHR AX, 5
SHR DX, 10
OR CX, AX
OR CX, DX
JMP __DONE

__565Restore:
SHR AX, 5
SHR DX, 11
OR CX, AX
OR CX, DX

__DONE:
MOV WORD PTR [EDI], CX
POPAD

}}


16BitValueP is a pointer to the 16bit word pixel...it gets changed to the next value jic u need the old value
C565 is a byte flag....set it to 1 for 565 (65536) colors or 0 for 32768 colors (x555)

Once all values have been through (all bits are on) the value returns to all bits off...so check for either the highest value or a second zero for termination

if u need to convert the values to 24bit...

void __16BitPxlto24BitPxl(DWORD 16BitValueP, DWORD 32b24BitValueP, BYTE C565)
{__asm{
PUSHAD

XOR EAX, EAX
MOV EDI, 16BitValueP
MOV ESI, 32b24BitValueP
MOV BL, C565
MOV AX, WORD PTR [EDI]
MOV CX, AX
MOV DX, AX

CMP BL, 1
JGE __565BitPxl

SHR AX, 10
SHL AX, 18
SHR CX, 5
SHL CX, 11
MOV AH, CH
SHL DX, 11
MOV AL, DH
JMP __DONEPXL

__565BitPxl:

SHR AX, 11
SHL AX, 19
SHR CX, 5
SHL CX, 10
MOV AH, CH
SHL DX, 11
MOV AL, DH

__DONEPXL:
MOV DWORD PTR [ESI], EAX
POPAD
}}

32b24BitValueP is a pointer to a 32bit DWORD which will contain the 24bit return data

bah all dat shit took me over an hour and it prob dont work

oh ye.....its proberbly got some compiler specific errors in the procedure header...shouldnt be too hard to fix that though

Edited by - forgotton_associator on January 20, 2001 10:37:50 PM
eh?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.