Sure I get what you are saying Va!n. I meant to say 1-256, but it using a range from 0-256 dosent seem to cause any problems. You can try this test prog, press -= to alter the alpha between 0 and 256.
Global cursor = CreateImage(100, 100)
SetBuffer ImageBuffer(cursor)
For i = 1 To 10
Color (i*20), (i*2), (i*8)
Oval (i*10), (i*10), 100-(i*10), 100-(i*10) , 1
Next
SetBuffer BackBuffer()
RotateImage cursor, 180
Global x_pos = 10
Global y_pos = 10
Global alpha = 129
While Not KeyHit(1)
Cls
DrawText()
LockBuffer BackBuffer()
DrawBackGround()
DrawAlphaSprite()
UnlockBuffer BackBuffer()
KeyInput()
Flip False
Wend
;---------------------------------------------------------------------;
;************************ COLOUR BLEND *******************************;
;---------------------------------------------------------------------;
Function ColourBlend( rgb_1, rgb_2, alpha_1 )
alpha_2 = 256 - alpha_1
rb_1 = ((rgb_1 And $00FF00FF) * alpha_1) And $FF00FF00
g_1 = ((rgb_1 And $0000FF00) * alpha_1) And $00FF0000
rb_2 = ((rgb_2 And $00FF00FF) * alpha_2) And $FF00FF00
g_2 = ((rgb_2 And $0000FF00) * alpha_2) And $00FF0000
rb_1 = rb_1 + rb_2
g_1 = g_1 + g_2
Return (rb_1 Or g_1) Sar 8
End Function
;---------------------------------------------------------------------;
;************************ DEMO FUNCTIONS *****************************;
;---------------------------------------------------------------------;
Function DrawText()
Color 255, 255, 255
Text 280, 20, "MOVE WITH"
Text 280, 40, "ARROW KEYS"
Text 280, 60, "- AND = ALTERS"
Text 280, 80, "ALPHA"
End Function
Function DrawBackground()
For y = 0 To 255
Color 100, 100+(y/2), y
Line 20, 20+y, 275, 20+y
Next
End Function
Function DrawAlphaSprite()
LockBuffer ImageBuffer(cursor)
For y = 1 To 99
draw_y = y+y_pos
For x = 1 To 99
col1 = ReadPixelFast(x, y, ImageBuffer(cursor))
If col1 <> -16777216
col2 = ReadPixelFast(x+x_pos, draw_y)
WritePixelFast(x+x_pos, draw_y, ColourBlend( col1, col2, alpha ))
EndIf
Next
Next
UnlockBuffer ImageBuffer(cursor)
End Function
Function KeyInput()
If KeyDown(203) x_pos = x_pos - 3
If KeyDown(205) x_pos = x_pos + 3
If KeyDown(200) And y_pos > 3 Then y_pos = y_pos - 3
If KeyDown(208) And y_pos < GraphicsHeight()-100 Then y_pos = y_pos + 3
If KeyDown(12) And alpha > 3 Then alpha = alpha -3
If KeyDown(13) And alpha < 253 Then alpha = alpha +3
End Function