Colorizing a specific area on the screen.

BlitzMax Forums/BlitzMax Programming/Colorizing a specific area on the screen.

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.

or if you want to dirrectly affect the pixels in the pixmap without creating a new pixmap
Function replacecolour2:Int(p:TPixmap,old_rgb:Int,new_rgb:Int,threshold:Int)
	Local w:Int = PixmapWidth(p)
	Local h:Int = PixmapHeight(p)
	Local x:Int,y:Int
	Local c:Int
	Local r1:Int,g1:Int,b1:Int
		
'	Local n:TPixmap = CreatePixmap(w,h,pf_BGRA8888)
	
	Local r:Int = (old_rgb Shr 16) & 255
	Local g:Int = (old_rgb Shr 8) & 255
	Local b:Int = (old_rgb Shr 0) & 255
	
'	Local p1:TPixmap = ConvertPixmap(p,PF_BGRA8888)
	
	' scan through image
	x  =0
	While x < w
		y = 0
		While y < h
			c = ReadPixel(p,x,y)
			r1 = (c Shr 16) & 255 
			g1 = (c Shr 8) & 255 
			b1 = (c Shr 0) & 255 
			
			If threshold_check(r,r1,threshold) And threshold_check(g,g1,threshold) And threshold_check(b,b1,threshold)
				WritePixel p,x,y,new_rgb
			EndIf
			
			y:+1
		Wend
		x:+1
	Wend

	Return True	
End Function




if you have an image you can call the routines with
image.pixmaps[frame]

this gets the pixmap for the relevant frame in the image