If you can come up with a colour or colour range that you want to change, then it is possible - as long as you don't want it to be lightning fast too.
Here is a very basic example - run in 32 bit mode only:
` Simplified colour constants
#constant C_BLACK 0x00
#constant C_BLUE 0x01
#constant C_GREEN 0x02
#constant C_CYAN 0x03
#constant C_RED 0x04
#constant C_PURPLE 0x05
#constant C_YELLOW 0x06
#constant C_WHITE 0x07
sync on
sync rate 0
sync
sync
set window off
set display mode 640, 480, 32
for i=0 to 40
ink SelectColour( rnd(6)+1 ), 0
DrawBox(rnd(47), rnd(47), 16-rnd(15), 16-rnd(15))
next i
get image 1, 0, 0, 64, 64, 1
do
cls
ChangeFrom = rnd(7)
repeat
ChangeTo = rnd(7)
until ChangeTo <> ChangeFrom
ConvertImageColour(1, 2, SelectColour( ChangeFrom ), SelectColour( ChangeTo ) )
sprite 1, 50, 50, 1
sprite 2, 120, 50, 2
text 0, 0, "Changing the colour " + ColourName(ChangeFrom) + " to " + ColourName(ChangeTo)
sync
wait key
loop
function ConvertImageColour(SourceImg as integer, DestImg as integer, SourceCol as dword, DestCol as dword)
local i as integer
make memblock from image 1, SourceImg
i=12
while i < get memblock size(1)
if (memblock dword(1, i) || 0xff000000) = SourceCol then write memblock dword 1, i, DestCol
inc i, 4
endwhile
make image from memblock DestImg, 1
delete memblock 1
endfunction
function DrawBox(x as integer, y as integer, width as integer, height as integer)
box x, y, x+width, y+height
endfunction
` Provide simplified colours
function SelectColour(Colour as dword)
local Red as integer
local Green as integer
local Blue as integer
local Result as dword
if (Colour && 4) > 0 then Red = 255
if (Colour && 2) > 0 then Green = 255
if (Colour && 1) > 0 then Blue = 255
Result = rgb(Red, Green, Blue)
endfunction Result
function ColourName(colour as dword)
local Name as string
select colour
case C_BLACK : Name = "Black" : endcase
case C_BLUE : Name = "Blue" : endcase
case C_GREEN : Name = "Green" : endcase
case C_CYAN : Name = "Cyan" : endcase
case C_RED : Name = "Red" : endcase
case C_PURPLE : Name = "Purple" : endcase
case C_YELLOW : Name = "Yellow" : endcase
case C_WHITE : Name = "White" : endcase
endselect
endfunction Name
*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++
http://www.matrix1.demon.co.uk