Qbasicnews.com

Full Version: Editing an existing array..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Lets say i got an array and i want to add a black pixel to it.. One thing to do is to use put and pset, and then use get to store it..
I want to skip that part, and edit it without putting it out on the screen!
I have had a routine like that on my computor, but i can't find it on my hdd or on the web..

Anybody here got it?

Thx!
I found the main module on my hdd but not the function ReadPixel and the sub WritePixel.. I was hoping that someone got these?

Code:
Here's a demo of how to use the GETPIXEL and READPIXEL routines.


DECLARE FUNCTION READPIXEL%(MODE AS INTEGER,SM AS INTEGER,OS AS
INTEGER,X AS INTEGER,Y AS INTEGER)
DIM PICT(1 TO 101) AS LONG,ATTRIB AS INTEGER,SM AS INTEGER,OS AS
INTEGER
SCREEN 13
'
'  Draw 20 x 20 box on screen with attribute 13 and GET it to array
PICT.
'
LINE (40,40)-(59,59),13,B
GET (40,40)-(59,59),PICT
'
'  Now, let's say we want to read the attribute of the pixel that was
at
' (59,59) on the screen from the array PICT.  Although that pixel was
at
' (59,59) on the screen, as far as the array is concerned, it was at
' (19,19)--because GET started at (40,40).  (The array acts as if the
' picture was at the upper lefthand corner of the screen, once the data
is
' inside of it, regardless of where it really was on the screen.)  So,
' you would use the function READPIXEL to read that attribute.
'
'  First, get the memory segment and offset of the array.  (Note that
SM
' and OS, as with all variables/data input to READPIXEL/WRITEPIXEL
' routines, are INTEGER variables.)
'
SM=VARSEG(PICT(1))
OS=VARPTR(PICT(1))
'
'  Now get the attribute of the pixel at (19,19) in the array and
display
' it.
'
ATTRIB=READPIXEL(13,SM,OS,19,19)
LOCATE 1,1
PRINT ATTRIB
'
'  Pause so you can see picture and attribute displayed on screen.
'
WHILE INKEY$="" : WEND
'
'  Okay, now let's say you want to change the attribute of the pixel at
' the upper righthand corner of the box to attribute 9.  That pixel is
at
' (19,0) as far as the array is concerned.
'
'  Clear the display and use WRITEPIXEL and then PUT to redisplay the
' changed picture.  (You don't have to clear the display.  I'm just
' demonstrating that what happens with the array doesn't depend on the
' picture being on the screen.)
'
CLS
CALL WRITEPIXEL(13,SM,OS,19,0,9)
PUT (60,60),PICT
WHILE INKEY$="" : WEND
END
Don't worry folks.. I phoned a buddy, and he had the routine..
MAIN routine, I think the subroutine and function you were looking for are in

http://www.geocities.com/gstumpff/offscrn.zip