Umm! this was along the lines of what I meant, but it refuses to compile, I guess I have some error in the & syntax, but with no idea what it should be you will just have to try to make sense of it, I havent the time at the moment, I was just able to spare the time to run this up, but I expected it to work (at least sortof), no time to debug, be my guest.
`%picture inverter%
`======================
`©%Mentor.%
`======================
`Main Source File
set display mode 320,240,16
load bitmap "C:\Program Files\Dark Basic Software\media\bitmaps\photos\landscap\forest01.bmp",0
firstcall=1
set text size 40
text 40,100,"Space to toggle"
do
if spacekey() then togglescreen()
sync
loop
function togglescreen()
rem invert all the pixel colours
if firstcall=1 then make memblock from image 1,0:firstcall=0
for i=12 to 76812
rem get the r,g,b for a pixel
blue_data = 31 & (memblock byte 1,(i+1))
green_data = (124 & (memblock byte 1,i))/4
red_data = ((3 & (memblock byte 1,i))*8)+((224 & (memblock byte 1,i+1))/32)
rem invert the colours (dark go light and light dark), this could be done with
inv_blue = 31-blue_data
inv_green = 31-green_data
inv_red = 31-red_data
rem make the first byte (5 bits of green data and 2 of red), *4 moves it 2 bits up
green_bits = inv_green*4
red_bits = 3 & inv_red
first_byte = green_bits+red_bits
write memblock byte 1,i,first_byte
rem now make the second byte, this is the blue data plus 3 bits of red data
red_bits = (28 & inv_red)*32
second_byte = red_bits+blue_bits
write memblock byte 1,i+1,second_byte
next i
endfunction
cheers.
Mentor.
PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.