Lockimage and image frames

BlitzMax Forums/BlitzMax Beginners Area/Lockimage and image frames

Robb(Posted 2010) [#1]
I have adapted a piece of code to change a specific colour within an image: -

Function changecolor:TImage(Image:TImage,pal:Int[])

	Local pimage:TPixmap = LockImage(image)
	
	
	For Local x:Int = 0 Until pimage.Width
	    For Local y:Int = 0 Until pimage.Height
	      Local PixelData:Byte Ptr = pimage.PixelPtr(x,y)
	
			
		If pixeldata[0]=pal[0] And pixeldata[1]=pal[1] And pixeldata[2]=pal[2]
	
	          PixelData[0]= rand(255)
	          PixelData[1]= rand(255)
		  PixelData[2]= rand(255)]
		
	

		EndIf
		
		

		Next 
	Next 
	
	UnlockImage(image)
	
End Function


The code works fine with a single image, however if I load an image with loadanimimage() then the code only affects the first frame of the animation.

Is it possible to use the same code to alter all of the frames within the image? How would I go about doing this?


Robb(Posted 2010) [#2]
Ahh...somehow I had missed the 'frame' argument to lockimage. Its all working now :-D