Pixel Manipulating ala SetBuffer()

BlitzMax Forums/BlitzMax Beginners Area/Pixel Manipulating ala SetBuffer()

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.

In ye older Blitz programs, setbuffer, Lockbuffer and writepixelfast would be combined to achieve various sorts of effects.

And I've had a last and final attempt to do something akin to it in BMAX. Nothing is happening with the colours being manipulated for the example effect. If you could help that would be great. Also better and clearer details and descriptions in the manual on what the commands do would be great.

The Theory is, this should work with all kinds of special effects, and other drawing like how you would with SetBuffer() etc.

Here's the duff code, for anyone interested in taking a look. As Im flumuxed over it all.
'====================================================
' Copying and manipulating images
' Care Of Setbuffer Imagebuffer() and WritePixelFast
' attempt 4000
'====================================================

Strict

'
' Screen setup dimensions.
'
Const XRES=640
Const YRES=480

Graphics XRES,YRES


Global MainImage=CreateImage(32,32)		' the main image to be used for manipulating.
Global TempImage						' used temporarily for manipulating and redrawing.

'
' create a custom makeshift image.
'
For Local a=0 To 31
	SetColor Rand(255),Rand(255),Rand(255)
	DrawRect 0,a,32,1
Next
GrabImage MainImage,0,0



'
' the main loop.
'
While Not KeyHit(KEY_ESCAPE)
Cls
	DrawImage MainImage,0,0

	Draw2Images(MainImage)
	
	DrawImage TempImage,0,64

Flip
Wend

EndGraphics



Function Draw2Images(ImageName)

TempImage=CreateImage(32,32)

Local xx,yy
Local RGB1
Local RGB2
Local RED1,GRN1,BLU1
Local RED2,GRN2,BLU2
Local Colour

LockImage(ImageName)
		
	For xx=0 To 31
		For yy=0 To 31
			
			'
			' Fetch colours to be manipulated.
			'
			RGB1	=ReadPixel(ImageName,xx,yy)
			
			RED1	=(RGB1 & $00FF0000)	/$FFFF
			GRN1	=(RGB1 & $00FF00)	/$FF
			BLU1	=(RGB1 & $00FF)
			
			'
			' Makeshift colour change effect.
			'
			RGB2	=(RED1*.222)+(GRN1*0.555)+(BLU1*0.125)
			
			'
			' Convert to viewable colours.
			'
			RED2	=RGB2 Shl 16
			GRN2	=RGB2 Shl 8
			BLU2	=RGB2 
			
			'
			' Combine them all and draw them ala WPF
			'
			Colour	=RED2 | GRN2 | BLU2
		
			WritePixel Temp,xx,yy,Colour

		Next
	Next

UnlockImage	(ImageName)
'
' Grab the image
'
GrabImage 	TempImage,0,0

End Function


Thanks