Colour Tinting Images

BlitzMax Forums/BlitzMax Beginners Area/Colour Tinting Images

Steve Elliott(Posted 2005) [#1]
I've tried changing the colour of an image with some success using setcolor, but the lighter shades of the original image now seem to be missing (I'm using alpha blending).

Is there a better way or a range of colours to mix and give a better result?


Emmett(Posted 2005) [#2]
As a beginner I can't say much but:
If the image is an image file as in .png or .jpg etc. the way to change any colors in that image is to create a 2nd version with the colors wanted and swap images when desired.
If the image is created by drawing lines, ovals, rectangles and using createimage then my suggestion is to study the grabimage code in the IDE modules help.
I played around with that and created multiple images all with different colors.
Here is the modified version of that help code using alphablend.
Graphics 640,480
Cls
SetColor 255,0,0
For Local i=1 To 100
DrawLine 0,0,32,32
DrawLine 32,0,0,32
DrawOval 0,0,32,32
Local image=CreateImage(32,32)
GrabImage image,0,0
DrawImage image,Rnd(640),Rnd(480)
SetColor Rnd(255),Rnd(255),Rnd(255)
SetBlend alphablend
Next
Flip
WaitKey

Cheers


Steve Elliott(Posted 2005) [#3]
You've misunderstood Emmett. Because BlitzMax is 2d - but in 3d, loaded images can have transparency effects, realtime scaling and rotation and colours completely changed without the extra memory of drawing another graphic for each colour.