I got a snake head like this, and now I'm looking for something that I can use to make ONLY white color different. I though 'tinted bitmap' would be good, but it's also coloring eyes, and tongue. Furthermore, I found al_get_pixel and al_put_pixel, but in this I need to give x and y of pixel, so it's difficult to make it with that bitmap So the thing I'm looking for is something like al_get_pixel but with given color, not x/y.
al_get_pixel returns an ALLEGRO_COLOR, so run through all the x/y combinations and check if that color is white. If it is, use al_put_pixel on that same x/y with the replacement color and when you're done, save the png.
Am I must save bitmap as .png file? If I want to do it in .png I will color it in Inkscape and then export . I want to do in live in program. Like in MENU:
1) User input numbers from 0 to 255 to R, G, B.
2) Function change white color from bitmap to color, which user input into it.
3) Game start with colored bitmap.
I would:
edit the bitmap so the parts you want to change colour are transparent
draw a coloured square
draw the bitmap on top
you can do this on an offscreen bitmap and then re-use that bitmap
[edit] hm, that doesn't work if you want the surroundings of the head to be transparent.
[edit2] Better but I had to split the snake into two layers (you will be able to do this better if you have the original vector image!) (see attachments)
{"name":"612929","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/6\/9669099af39149b4ea8c2e52e39b4737.png","w":560,"h":146,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/6\/9669099af39149b4ea8c2e52e39b4737"}
you can read about al_lock_bitmap/al_unlock_bitmap, This function allows you to access the bitmap directly in memory and modify the colors of the pixels one by one. It's much faster if you know how.
https://liballeg.org/a5docs/trunk/graphics.html#al_lock_bitmap
This should get you started, this loads your snake_white.png, then saves it as snake_green.bmp, which I have attached.
You would obviously want to put this in a function, so you can use different colours etc, but this will get you started!
These getpixel/putpixel solutions aren't ever going to work well because of the grey pixels at the edge of the outlines (antialiasing isn't it?). Depends on the image, I guess it would be fine for pixel-art type images.
(antialiasing isn't it?)
Yes, exactly! I did say "this should get you started"
Some math would be required to properly colour those antialiased areas to the new colour, but I'm not going to provide that solution straight away
[EDIT]
Oh go on then, it is nearly the weekend after all! New images attached