ReadPixelFast

Blitz3D Forums/Blitz3D Programming/ReadPixelFast

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.

Hello, im having problems reading a pixel color using readpixel fast :(

Im not sure if there is a problem with blitz3d being able to do this or am I doing it wrong..


Function ColorImage(x%,y%,scolor)

	Local oldimage = LoadImage ("gfx/player.png")
	Local newimage = CreateImage(48,64)
	Local ob = ImageBuffer(oldimage) : LockBuffer ob
	Local nb = ImageBuffer(newimage) : LockBuffer nb
	Local ix,iy
	
	For ix = 0 To 48 - 1
		For iy = 0 To 64 - 1
			Local rbgc = ReadPixelFast(ix+x,iy+y,ob)
			Select scolor
				Case red
					If rbgc = $FF404040
						WritePixelFast ix,iy,($FF400000),nb
					ElseIf rbgc = $FF808080
						WritePixelFast ix,iy,($FF800000),nb
					ElseIf rbgc = $FFC0C0C0
						WritePixelFast ix,iy,($FFC00000),nb
					ElseIf rbgc = GetRGB(232,232,232)
						WritePixelFast ix,iy,($FFFF4040),nb
					Else
						WritePixelFast ix,iy,(rbgc),nb
					EndIf			
				Case blue
				Case green
				Case yellow
			End Select
		Next
	Next
	UnlockBuffer ob : UnlockBuffer nb

	MaskImage newimage,255,0,255
	Return newimage
	
End Function



here is my code please let me know if im doing somethign wrong and also this is very slow :(