Buffer and Read/Write pixel problems ...
Blitz3D Forums/Blitz3D Beginners Area/Buffer and Read/Write pixel problems ...
| ||
@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) |
| ||
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 |
| ||
true! - nothing happens! |
| ||
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 |
| ||
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??? |
| ||
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) |
| ||
@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 ... |