I can't get this to work (Additive Blend function)

Blitz3D Forums/Blitz3D Beginners Area/I can't get this to work (Additive Blend function)

Hi WarpZone,

i messed with your code and added some blend modes:

Global Target= CreateImage(256,256)
Global Source1= LoadImage("rock.bmp")
Global Source2= LoadImage("water.bmp")

Blend(Source1,Source2,Target,"Average")

SetBuffer BackBuffer()
CopyRect 0,0,256,256,0,0,ImageBuffer(Target),BackBuffer() 
Flip
Repeat
Until KeyDown(1)

Function Blend(SourceTexture1,SourceTexture2,TargetTexture,BlendMode$)
Time1 = MilliSecs()
  For x = 0 To 256
    For y = 0 To 256
      SetBuffer ImageBuffer(SourceTexture1)
      GetColor x,y
      r1#=ColorRed()
      g1#=ColorGreen()
      b1#=ColorBlue()
      SetBuffer ImageBuffer(SourceTexture2)
      GetColor x,y
      r2#=ColorRed()
      g2#=ColorGreen()
      b2#=ColorBlue()
      SetBuffer ImageBuffer(TargetTexture)
      Select BlendMode
	Case "Average"  
	 Color (r1# + r2#) Shr 1 ,(g1# + g2#) Shr 1,(b1# + b2#) Shr 1
	Case "Multiply"
	 Color (r1# * r2#) Shr 8 ,(g1# * g2#) Shr 8,(b1# * b2#) Shr 8
	Case "Screen"
	 Color 255-((255-r1#) * (255-r2#) Shr 8) , 255-((255-g1#) * (255-g2#) Shr 8),255-((255-b1#) * (255-b2#) Shr 8)
      End Select
    Plot x,y
    Next
  Next
Time2 = MilliSecs()
TimeNeeded = Time2 - Time1
End Function


I have tried to speed it up with writepixel etc. but got no luck...

http://www.moonworx.de