WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

BMP Color Change


Question:

how can i change an definite color on a BMP or an GIF file. I have an BMP file with white and red pixels. I want that all the red pixels on my picture will be green or an other color. The white color should be not changed. Can i do this with winbatch or winbatch extenders ? I don't found this funktion at pixie.

Answer:

Here's a very simple example of changing red to green in a 2-color BMP:
infile = "input.bmp"
outfile = "output.bmp"

size = FileSize(infile)
buf = BinaryAlloc(size)
BinaryRead(buf, infile)

red = -16777216
green = 16711680

offset = 53

For i = 1 To 2
   color = BinaryPeek4(buf, offset)
   If color == red Then BinaryPoke4(buf, offset, green)
   offset = offset + 4
Next

BinaryWrite(buf, outfile)
BinaryFree(buf)

Article ID:   W17412
File Created: 2008:04:10:15:09:40
Last Updated: 2008:04:10:15:09:40