change a image color

Blitz3D Forums/Blitz3D Beginners Area/change a image color

Leszek(Posted 2009) [#1]
Hey guys

I don't know how to do a change image color.
For example: I am loading a image (the image is white), I add a mask and I going to change image color on blue.

How to do it?
Please, help !

Yours,
Leszek Król


puki(Posted 2009) [#2]
Technically, you can use ReadPixel and WritePixel to achieve this.

However, this is probably something that has multiple solutions - so someone may come along and post a better method.


Kryzon(Posted 2009) [#3]
Another way, this one in 3D, is using a sprite with a pixel perfect lib like Draw3D or SpriteControl, and then changing the color of that sprite to something else than the entity's default of 255,255,255.


Ross C(Posted 2009) [#4]
A slightly quickier way i reckon, than readpixel/writepixel fast, depending the size of the image of course, would be to change the image before before you add the mask. And the easiest way to do that is to set the drawing buffer to the image buffer of the image you want to change. Then set your color to blue. Then draw you rect over the image.

so:


Global image = LoadImage("image.png")
Global mask = LoadImage("mask.png")
SetBuffer ImageBuffer(image)
Color 0,0,255

Rect 0,0,ImageWidth(image),ImageHeight(image)
DrawImage mask,0,0
SetBuffer BackBuffer()



Keep in mind here, your mask image will need to be the same size as your other image, and, don't make your mask black. If you do that, and try to draw the mask image onto the image, the black pixels won't be drawn as that is considered a mask colour by default.


Leszek(Posted 2009) [#5]
Ok, it's working very nice :)

THX all for help

Yours,
Leszek Król