Looking for Grayscaling Effect?

Blitz3D Forums/Blitz3D Programming/Looking for Grayscaling Effect?

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.

Well this is what I came up with. For some reason I couldn't just use Read/Write PixelFast cause of a MAV. But whatever.

Function GrayScaleFX()
	LockBuffer(BackBuffer())
	For x%=0 To gfx_width%
		For y%=0 To gfx_height%
			pxl = ReadPixel(x%,y%)
			bl = pxl And 255
 			gr = (pxl Shr 8) And 255
 			rd = (pxl Shr 16) And 255
  			clr = .3 * rd + .59 * gr + .11 * bl
  			WritePixel x,y,clr + clr Shl 8 + clr Shl 16 - 16777216
		Next
	Next
	UnlockBuffer()
End Function


And why I'm posting it here is so that if you guys have any speed ideas in mind you can throw them in!

But basicly its the classic Grayscale algorithm. But what I believe makes this faster then others is that it is Reading and over-Writing in the same pass. I've seen other grayscale effects try and save screenshots or save the screen data to dim/array. But I figured that wasn't neccessary. And so running on the locked backbuffer I'm hoping my hunch of DirectDraw operating on a harware surface with the BackBuffer is true cause then that should speed this up more!

And I call this last before the FLIP.