Changing color of already plotted pixel

BlitzMax Forums/BlitzMax Beginners Area/Changing color of already plotted pixel

With Blitsmax, you should do things like this:

Function SetPixelsColor(pixmap:TPixmap,r1,g1,b1,r2,g2,b2)
	Local p:Byte Ptr,i%,j%,w%,h%
	For j=0 Until PixmapHeight(pixmap)
		For i=0 Until PixmapWidth(pixmap)
			p=Pixmap.PixelPtr(i,j)
			If p[0]=r1 And p[1]=g1 And p[2]=b1 Then
				p[0]=r2
				p[1]=g2
				p[2]=b2
			EndIf
		Next
	Next
End Function

'--- Demo----------------------------------------------
'Use your own medias to replace mine ("Medias\ms.png") 
'Replace the "first r,g,b component" to match one
'color present in your media
'------------------------------------------------------
Graphics 640,480

Global image:TImage,pixmap:TPixmap,r1,g1,b1,r2,g2,b2
image=LoadImage("Medias\ms.png")

r1=255 '
g2=0   ' first r,g,b components 
b1=255 '
While Not KeyDown(KEY_ESCAPE)
	Cls
	If KeyHit(KEY_SPACE) Then
		pixmap=LockImage(image)
		r2=Rand(255)
		g2=Rand(255)
		b2=Rand(255)
		SetPixelsColor pixmap,r1,g1,b1,r2,g2,b2
		UnlockImage(image)
		r1=r2
		g1=g2
		b1=b2
	EndIf
	DrawImage image,100,100
	DrawText "Press SPACE to change pixels of "+r1+","+g1+","+b1+" color values",0,0
	Flip
Wend