Colors manipulation - inverse, decreasing bitdepth...

MIRKOSOFT

New Member
Hi!

I'm new on this forum, so I decided to work more with graphics.
I'm programmer and want to create own tools to manipulate with pictures.
My Qs:

Color inversion:
Inverting color is on binary base?
When I look at white and black - in 24-bit depth $FFFFFF vs $000000
means <any> color is inverted by COLOR = NOT (COLOR) - simple 1=0 and 0=1 ?
When we use assembler or any CPU, we have here few more operations:
AND, OR, EOR and of course results can be finally NOT modified e.g. NAND
AND result is if both bits are 1 result is 1, otherwise 0
OR result is if at least one bit is 1 result is 1, if both bits are 0 then result is 0
EOR result if have bits different value is 1, if are same result is 0
Here i for me Q: How to name these modifications? Graphic utilities programmers must to name them, but I'm really beginner, but it looks:
NOT = invert colors
OR = mix colors
AND = ?
EOR = ?
and what NOR, NAND, NEOR ?

Color depth decreasing:
Again when I look at this in binary base, but here really don't know if it is correct, it's possible to do so by bit shifting or simple dividing and multiplying like this:
Example 1: decrease 24bit depth to 4bit
RED=HI, GREEN=MI, BLUE=LO
R=Int(HI/16): G=Int(MI/16): B=Int(LO/16)
result is 12bit digit created by:
HIGH=R: LOW=(G*16)+B
HIGH & LOW are high byte, low byte of 16bit digit. but here it makes me confusing: in what are stored red, green, bluee colors? simple 4bit color is: IRGB = bit3:intensity, bit2:red, bit1:green, bit0:blue, or not?
When we have 16bit number of 12bit color, we can decrease 16bit to 8bit:
COL=16bit digit, HI=high 8 bits of COL, LO=low 8 bits of COL
H=(Int(HI/16)*16): L=Int(LO/16): BYTE= HL where H are high 4 bits and L are low 4 bits or H = high nibble and L = low nibble
here is finalization - 8bit to 4bit color depth:
BYTE is 8bit color
FINAL=Int(BYTE/16)
final is 4bit color of 24bit RGB color...
These multiply and dividing can be used with different values to create for example 8bit color decrased 6bit color.
But I'm not sure about Red Green Blue order in binary arithmetic.
Also is for me unknown Alpha channel
RGB and RGBA are 24bit vs 32bit color
when we look at this model each color is 8bit in order HI=bit16 to bit23, MI=bit8 to bit15, LO=bit0 to bit7
where is stored Red? - in HI or MI or LO, also Green, also Blue - I mean order:
RR=HI: GG=MI: BB=LO
but where is A (Alpha channel)?
is it HIMILOAA
or AAHIMILO?
By paint program RealWorld Paint I know that order of hexadecimal number of color it is AAHIMILO exacly byte after byte Alpha, Red, Green, Blue
And creating colors is in that order, but Alpha $00 is transparent and $FF is opaque?

Thnk you all for each reply to this topic, I know that here are many Qs, but somewhere I must begin and I hope that I found good forum.

Miro
 
Back
Top