MixImages function help

BlitzPlus Forums/BlitzPlus Programming/MixImages function help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I've tried to make something like what you said:
Dim c1(Screen_Width-1,Screen_Height-1) 
Dim c2(Screen_Width-1,Screen_Height-1) 
Dim cm(Screen_Width-1,Screen_Height-1) 

Function MixImages(mix,ima1,ima2)

	buf1=ImageBuffer(ima1)
	buf2=ImageBuffer(ima2)
	bufm=ImageBuffer(mix)

	LockBuffer buf1
	LockBuffer buf2
	LockBuffer bufm
	
	For y=0 To Screen_Height-1
		For x=0 To Screen_Width-1
			c1(x,y)=ReadPixelFast(x,y,buf1)
			c2(x,y)=ReadPixelFast(x,y,buf2)
		Next
	Next
	
	For y=0 To Screen_Height-1
		For x=0 To Screen_Width-1
			red1=GetRed(c1(x,y))     :  red2=GetRed(c2(x,y))
			green1=GetGreen(c1(x,y)) :  green2=GetGreen(c2(x,y))
			blue1=GetBlue(c1(x,y))   :  blue2=GetBlue(c2(x,y))
			
			rm=red1+red2 : If rm>255 Then rm=255
			gm=green1+green2 : If gm>255 Then gm=255
			bm=blue1+blue2 : If bm>255 Then bm=255
			
			cm(x,y)=Combine(rm,gm,bm)
		Next
	Next

	For y=0 To Screen_Height-1
		For x=0 To Screen_Width-1
			WritePixelFast x,y,cm(x,y),bufm
		Next
	Next

	UnlockBuffer bufm
	UnlockBuffer buf2
	UnlockBuffer buf1
	
End Function

But it is slower than what I wrote yesterday! I think that using all this arrays it isn't usefull.
Is the code similar to what you thought?

A last question: how can I wrote the codes in green in this forums? Thanks!