Buffer and Read/Write pixel problems ...

Blitz3D Forums/Blitz3D Beginners Area/Buffer and Read/Write pixel problems ...

Hansie(Posted 2004) [#1]
@all

what's wrong with this:

		Dim pix(vh_scrwidth,vh_scrheight) 
		LockBuffer(FrontBuffer)
 		For y=0 To vh_scrwidth 
		For x=0 To vh_scrheight 
		pix(x,y)=ReadPixelFast(x,y) 
		Next 
		Next

		LockBuffer(FrontBuffer)
		For y=0 To vh_scrwidth 
		For x=0 To vh_scrheight 
		WritePixelFast x,y,$00,$00,$00,pix(x,y) 
		Next 
		Next 
		UnlockBuffer (FrontBuffer)



Neo Genesis10(Posted 2004) [#2]
What seems to be the problem. What I see here is a piece of code which takes the existing buffer and copies it onto itself (this ultimately assumes FrontBuffer is the set buffer). If it worked you would see nothing apparent happening.

Try looking at this:
Dim pix(vh_scrwidth,vh_scrheight) 

CopyBuffer = FrontBuffer()	; Change this to the buffer you're copying from
TargetBuffer = BackBuffer()	; again, change this how you want
PreviousBuffer = GraphicsBuffer() ; So we can reset back to orignal buffer


SetBuffer CopyBuffer		; Important to tell the compiler which buffer you're reading
LockBuffer(CopyBuffer)
For y=0 To vh_scrwidth 
	for x=0 To vh_scrheight 
		pix(x,y)=ReadPixelFast(x,y) 
	Next 
Next
UnlockBuffer CopyBuffer

SetBuffer TargetBuffer
LockBuffer(TargetBuffer)
For y=0 To vh_scrwidth 
	For x=0 To vh_scrheight 
		WritePixelFast x,y,$00,$00,$00,pix(x,y) 
	Next 
Next 
UnlockBuffer (TargetBuffer)
SetBuffer PreviousBuffer



Hansie(Posted 2004) [#3]
true! - nothing happens!


Hansie(Posted 2004) [#4]
what I want is to read every single pixel of the active buffer and to display the R,G,B values in hex format like $XX,$XX,$XX


skidracer(Posted 2004) [#5]
Use LockBuffer(GraphicsBuffer()) and same with UnlockBuffer if you want your routines to work with the active buffer. And whats with all the parameters in your WritePixelFast call???


(tu) ENAY(Posted 2004) [#6]
I didn't realise you could do "$00,$00,$00"
I thought "$000000" was the way to do it.

I think you should be doing

WritePixelFast x,y,pix(x,y)


Hansie(Posted 2004) [#7]
@enay

you're right. I have too many parameters ... I am still struggling to get this thing to work ... it really annoys me that there is only one simple sample in the original docs ...