Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

graphics, buffering, PUT

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
0
0
US
say I have this image stored in a text file.

0,0,0,0,0,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0
0,0,0,1,1,1,0,0,0,0
0,0,1,1,1,1,1,0,0,0
0,0,0,0,1,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0

is there a way to transfer that into a format the PUT and deliver to the screen (without actually drawing and GETting it)
 
I dont know the answer, but that's one heck of a cool question...
 
I don't see why not....
Code:
DEFINT A-Z
DIM Garr(208)
P$ = P$ + "017000017000000000000000"
P$ = P$ + "000000000000000000000000"
P$ = P$ + "007192000007192000007192"
P$ = P$ + "000000000000024048000031"
P$ = P$ + "240000031240000000000000"
P$ = P$ + "039200000040040000047232"
P$ = P$ + "000000000000072036000080"
P$ = P$ + "020000091180000000000000"
P$ = P$ + "211150000227142000252126"
P$ = P$ + "000000000000169042000204"
P$ = P$ + "102000240030000000000000"
P$ = P$ + "170170000204102000240030"
P$ = P$ + "000000000000169042000204"
P$ = P$ + "102000240030000000000000"
P$ = P$ + "211150000227142000252126"
P$ = P$ + "000000000000072036000080"
P$ = P$ + "020000091180000000000000"
P$ = P$ + "039200000040040000047232"
P$ = P$ + "000000000000024048000031"
P$ = P$ + "240000031240000000000000"
P$ = P$ + "007192000007192000007192"
Cnt = 0
FOR Re = 1 TO LEN(P$) STEP 6
    C$ = CHR$(VAL(MID$(P$, Re, 3)))
    C$ = C$ + CHR$(VAL(MID$(P$, Re + 3, 3)))
    Garr(Cnt) = CVI(C$)
    Cnt = Cnt + 1
NEXT
SCREEN 7
PUT (0, 0), Garr
All this does is draw a series of concentric circles in the upper left of the screen. The string of digits could easily be stored in a text file (I see that your digits are separated with commas, as if you intended to use INPUT # to read them one at a time.... just add a comma between each set of three digits in the string I posted above if you want to add slowness to your program.)

The trick here is understanding the type of data that QB expects in the array you PUT to the screen (a subject I really don't understand very well). You might start by examining the first line of data: "017000017000000000000000".

This code writes a graphic block 17 pixels high by 17 pixels wide. The first 12 digits, representing 4 bytes of data, representing the first two integers in the PUT array seem to coincide with the size of the graphics block....

Hmmm... coincidence or conspiracy?

Nyaj2k1 is right. This is a cool question and I am as anxious as any to find a convenient way to read graphics blocks with GET, modify the array elements directly and write them back to the screen with PUT.


VCA.gif
 
The better way I found is to create "file editor" for previously saving picture in the "get/put" format. Because dealing with the data structure as Alt155 have done is a very complicated task, getting the picture done and saving the variable as it is into the file is a good way to avoid playing with the internal structure of the variable.

The application could be pretty short as it stand uncompiled for internal changes such variable lenght, picture borders and so on.

On the main application runtime, you should then load the picture from the file and then you're set for PUTting it!
 
one way would be to use "poke" to imput the image data into the storage array.

to do this you will need to put the width of the image (in bits) into the first array segment.

eg... width = 10 , width in bits = 10*8 (there beeing 8 bits per pixle in mode 13)

then put the height of the image in pixle's into the next segment of your array.

next to put the rest of the image into the array:

first set the defalt segment to the fist byte of the array
eg... def seg = varseg(array%(0))
then poke your color into the the next byte after the two elements you just set.
eg... poke varptr(array%(2))+(x*y)+width,color

i hope this answer's your question.
 
Again sorry if my QBasic expertise is a little rusty.

Try the folowing procedure.

Draw the ARROW (I thing thats what the BINARIES represent)

GET it into an array.

BSAVE the array to disk.

Now using BLOAD "Filename.ext", VARPTR (Arrayname)
(Or something. I can't remember how this function works exactly, I hope though that this is sufficient).

will reload the ARROW image into your array.

TIP: If you want to simulate the cursor arrow pointer, There is a much better way by invoking a call to an interrupt (I'm not sure exactly).

Have fun and let me know what happens.
ARISTON Engineering Ltd
Michael Vezyrgianopoulos
R&D Manager
 
You can refer to these faq ->
faq314-136
faq314-87
It should help. ;-)
 
the image:
0,0,0,0,0,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0
0,0,0,1,1,1,0,0,0,0
0,0,1,1,1,1,1,0,0,0
0,0,0,0,1,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0
is X=10 Y=7...

I would round it off to 8x8, you'll see why the more you program... and put the size at the top (x,y)
8,8
0,0,0,0,0,0,0,0
0,0,0,1,0,0,0,0
0,0,1,1,1,0,0,0
0,1,1,1,1,1,0,0
0,0,0,1,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,1,0,0,0,0
0,0,0,0,0,0,0,0

the formula for the image size is...
4+int(((x)*(bpp)+7)/8)*(planes)*(y)
bpp(bits-per-plane) and planes differ with the screen mode

Screen 13 is bpp=8 planes=1
so... 4+int(((8)*(8)+7)/8)*(planes)*(8)= 68

you Can read it in Like so...
DIM PIC(68) as INTEGER
GET (0,0)-(7,7),PIC '<-short cut
DEF SEG = VARSEG(PIC(0))
DST& = VARPTR(PIC(2))
OPEN &quot;FILE.BLA&quot; FOR INPUT AS #1
DST2&=0
INPUT #1,X:INPUT #1,Y
FOR B=1 TO Y
FOR A=1 TO X
INPUT #1,C
POKE DST& + DST2&, C
DST2&=DST2&+1
NEXT
NEXT
CLOSE #1
DEF SEG
...
PUT(X1,Y1),PIC

MY WEB SITE IS...
 
ok
i think i know what your asking
i don't know what you have the file name saved as but i'll use the name arrow.txt. i will also use screen 7 but you can change this

'init screen 7
screen 7
'start of x point
x=1
'start of y point
y=1
'open the file arrow.txt so you can get info from it
open &quot;arrow.txt&quot; for input as #1
'start loop
do
'get color of pixel
input #1, rtrim$(ltrim$(color))
'put point on screen
pset (x,y), color
'increase x
x=x+1
'increase y
y=y+1
' loop until end of file
loop until eof(1)
'since the x and y coordinates are 1 above the actual
'perimeter, we will subtract 2 instead of 1
arraysize=((x-2)*(x-2)+1)
dim pic%(arraysize)
'get the picture and store it into the array
get (1,1)-(x-1,y-1), pic%


thats it, now all you have to do is PUT it on the screen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top