123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|428|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Read/Write Pixel Help

Mon, 17 Sep 2007, 13:58
JL235
Here you go. The important thing to remember is to lock and unlock the buffers appropriately.


If you also draw an image to the backbuffer before the two for loops it should be combined with the red lines.
Mon, 17 Sep 2007, 14:11
mike_g
Not locking the buffer will be very slow, but it shouldent make blitz crash.

Tikihead: you arent using Read/WritePixelFast are you? If you are then you need to make sure that you are drawing inside the buffer, or the prog will likely crash. Maybe you could post an example of your code? It would be easier to tell whats going wrong that way.

|edit| Diablo: I havent had this problem myself, but some people have told me that using WritePixelFast() together with GraphicsWidth() / Height() in my progs had caused crashes for them. When I stopped doing it there dident seem to be a problem. |edit|
Mon, 17 Sep 2007, 14:38
Phoenix
Reading/writing pixels outside of the screen/buffer will cause the program to crash, so make sure that you check the screen boundaries before performing any pixel operations.
Mon, 17 Sep 2007, 14:48
Jayenkai
Yeah, don't forget that, for example, GraphicsWidth() gives you 1 to 800, whilst Pixel Read+Write's should go from 0 to 799..

|edit| Re-read.. Oh, that's not what you meant! Could be an issue with GraphicsWidth not returning the right data whilst the buffer's locked. In that case, it's probably better to keep ScrW and ScrH in a couple of globals. |edit|

-=-=-
''Load, Next List!''
Mon, 17 Sep 2007, 15:55
JL235
Mike_G Diablo: I havent had this problem myself, but some people have told me that using WritePixelFast() together with GraphicsWidth() / Height() in my progs had caused crashes for them. When I stopped doing it there dident seem to be a problem.

I haven't encountered that problem either, and it shouldn't exist. I feel it's also better practice to use GraphicsHeight/Width rather then storing the value in a constant because it's more dynamic. When you call the function you are getting the definitive, guaranteed width or height of the program. This is opposed to what you believe should be the definite width and height of the program.

Jayenkai Yeah, don't forget that, for example, GraphicsWidth() gives you 1 to 800, whilst Pixel Read+Write's should go from 0 to 799.

I completely agree. Another thing I dislike about Blitz, it's loops are inclusive.
Mon, 17 Sep 2007, 17:16
steve_ancell
I've just had a little peek into it. Accoring to the Blitz 3D help docs, WritePixelFast & ReadPixelFast will cause the computer to crash if the screen coordinates are not valid. I'm not sure if the same applies to the standard ReadPixel & WritePixel commands though.
Mon, 17 Sep 2007, 18:23
mike_g
I feel it's also better practice to use GraphicsHeight/Width

I would agree but for some reason in won't work on all computers. And thats including subtracting 1 from it, for arrays starting at 0.

I've just had a little peek into it. Accoring to the Blitz 3D help docs, WritePixelFast & ReadPixelFast will cause the computer to crash if the screen coordinates are not valid. I'm not sure if the same applies to the standard ReadPixel & WritePixel commands though.

It dosent necessarily crash the computer, on mine it works fine but it writes to other areas of memory and then weird things happen, such as the image for my mouse pointer turns into a fuzzy lump. WritePixel does bounds checking so you should not have any problems writing out of buffer with it.