How do you know the bytes to dim using a PUT command? 
Author Message
 How do you know the bytes to dim using a PUT command?

I want to know how to tell how many numbers to dim and GET before
using a PUT command. I know it has to do with how big the picture
is, but I usually mess up. I only know 1 way to GET a picture from
using the LINE commands on the program, but that way only works
once in awhile, I got it out of a book.

                From,
                Kenneth Green

  P.S. Please post an explanation, it will help me write games
to put on my homepage.



Sun, 15 Nov 1998 03:00:00 GMT  
 How do you know the bytes to dim using a PUT command?


Quote:
> I want to know how to tell how many numbers to dim and GET before
> using a PUT command. I know it has to do with how big the picture
> is, but I usually mess up. I only know 1 way to GET a picture from
> using the LINE commands on the program, but that way only works
> once in awhile, I got it out of a book.

>                 From,
>                 Kenneth Green

>   P.S. Please post an explanation, it will help me write games
> to put on my homepage.

Why not look up get/put in the HELP section.  It will explain how it
works and give you a simple example to look at and play with. Here is an
e.g. anyway

cls
screen 13
line(160,100)-(180,120),4,bf
dim a(200)     'number can vary depending on size of object
GET(160,100)-(180,120),a
CLS
for x = 1 to 100
put(x,100),a,xor
for t=1 to 1000:next  'change 1000 to different value if too fast/slow
put(x,100),a,xor
next
end

--------------------------------------------------------------
Caleb Joliffe
Alias: Cujo



Cronulla Sharks Homepage:
http://student.canberra.edu.au/~u953592/home.html

"Don't be afraid to go for what you want, or what you want to
 be, but don't be afraid to pay the price." --Lane Frost
--------------------------------------------------------------



Tue, 17 Nov 1998 03:00:00 GMT  
 How do you know the bytes to dim using a PUT command?

Quote:

> I want to know how to tell how many numbers to dim and GET before
> using a PUT command. I know it has to do with how big the picture
> is, but I usually mess up.

The number of array elements you need is:

The number of bytes needed to store one plane of one row of your picture
(rounded up to the nearest byte) multiplied by the number of planes,
multiplied by the number of rows, plus four bytes to store the x and y
dimensions (as two 2-byte integers), divided by the number of bytes per
element in whatever numeric type you're using.

So, how many bytes do you need to store a row?  Well, that depends on
what screen mode you're using, and how many bits-per-pixel it uses, and
how many bit planes it has.

The following table and formula are from the QBASIC Help system (follow
the "Screen Image Arrays and Compatability" link in the "GET (Graphics)"
Help screen):

                                                               Horizontal
                                  Bits-per-pixel-              resolution
  Screen mode                     per-plane          Planes    (in pixels)
             
  1                               2                  1         320
  2, 4, 11                        1                  1         640
  3                               1                  1         720
  7                               1                  4         320
  8, 9(> 64K video memory), 12    1                  4         640
  9(64K video memory), 10         1                  2         640
  13                              8                  1         320

The following formula gives the required size, in bytes, of an array used
to hold a captured image:

size% = 4 + INT(((PMAP (x2!, 0) - PMAP (x1!, 0) + 1) *
        (bits-per-pixel-per-plane%) + 7) / 8) * planes% *
        (PMAP (y2!, 1) - PMAP (y1!, 1) + 1)

=-=-=-=-=-=-=-=-=-=-=-=

That formula may seem a bit daunting at first, so let's break it down into
individual steps:

'First, convert from World Coordinates to physical screen coordinates.
'This step is not necessary if you're not using the World Coordinates as
'set by a WINDOW statement:

RealX1% = PMAP(x1!, 0)
RealX2% = PMAP(x2!, 0)
RealY1% = PMAP(y1!, 1)
RealY2% = PMAP(y2!, 1)

'Next, determine the X and Y size of your graphic:

Xsize% = RealX2% - RealX1%
YSize% = RealY2% - RealY1%

'Now, determine how many 8-bit bytes are needed for each line of pixels in
each plane, and round up to the nearest whole byte:

PixelBytes% = ((XSize% * bits-per-pixel-per-plane%) + 7) \ 8

'Multiply that by the number of planes:

BytesPerLine% = PixelBytes% * planes%

'Then multiply by the total number of lines:

BytesNeeded% = BytesPerLine% * YSize%

'Add 4 bytes to store the X and Y dimensions:

TotalBytes% = BytesNeeded% + 4

'And finally, divide by the number of bytes per array element (2 for
INTEGER arrays, 4 for LONG or SINGLE, and 8 for DOUBLE), rounding up:

ElementsNeeded% = (TotalBytes% + BytesPerElement% - 1) \ BytesPerElement%

Now you know how many array elements you need.  DIMension an
appropriately-sized array, and you're ready to go.

Hope that helps.

---
Glen Blankenship




Mon, 23 Nov 1998 03:00:00 GMT  
 How do you know the bytes to dim using a PUT command?



] > I want to know how to tell how many numbers to dim and GET before
] > using a PUT command. I know it has to do with how big the picture
] > is, but I usually mess up.
]
] The number of array elements you need is:
]
] The number of bytes needed to store one plane of one row of your picture
] (rounded up to the nearest byte) multiplied by the number of planes,
] multiplied by the number of rows, plus four bytes to store the x and y
] dimensions (as two 2-byte integers), divided by the number of bytes per
] element in whatever numeric type you're using.
]
] So, how many bytes do you need to store a row?  Well, that depends on
] what screen mode you're using, and how many bits-per-pixel it uses, and
] how many bit planes it has.
]
] The following table and formula are from the QBASIC Help system (follow
] the "Screen Image Arrays and Compatability" link in the "GET (Graphics)"
] Help screen):
]
]                                                                Horizontal
]                                   Bits-per-pixel-              resolution
]   Screen mode                     per-plane          Planes    (in pixels)
]              
]   1                               2                  1         320
]   2, 4, 11                        1                  1         640
]   3                               1                  1         720
]   7                               1                  4         320
]   8, 9(> 64K video memory), 12    1                  4         640
]   9(64K video memory), 10         1                  2         640
]   13                              8                  1         320
]
] The following formula gives the required size, in bytes, of an array used
] to hold a captured image:
]
] size% = 4 + INT(((PMAP (x2!, 0) - PMAP (x1!, 0) + 1) *
]         (bits-per-pixel-per-plane%) + 7) / 8) * planes% *
]         (PMAP (y2!, 1) - PMAP (y1!, 1) + 1)
]
] =-=-=-=-=-=-=-=-=-=-=-=
]
] That formula may seem a bit daunting at first, so let's break it down into
] individual steps:
]
] 'First, convert from World Coordinates to physical screen coordinates.
] 'This step is not necessary if you're not using the World Coordinates as
] 'set by a WINDOW statement:
]
] RealX1% = PMAP(x1!, 0)
] RealX2% = PMAP(x2!, 0)
] RealY1% = PMAP(y1!, 1)
] RealY2% = PMAP(y2!, 1)
]
] 'Next, determine the X and Y size of your graphic:
]
] Xsize% = RealX2% - RealX1%
] YSize% = RealY2% - RealY1%
]
] 'Now, determine how many 8-bit bytes are needed for each line of pixels in
] each plane, and round up to the nearest whole byte:
]
] PixelBytes% = ((XSize% * bits-per-pixel-per-plane%) + 7) \ 8
]
] 'Multiply that by the number of planes:
]
] BytesPerLine% = PixelBytes% * planes%
]
] 'Then multiply by the total number of lines:
]
] BytesNeeded% = BytesPerLine% * YSize%
]
] 'Add 4 bytes to store the X and Y dimensions:
]
] TotalBytes% = BytesNeeded% + 4
]
] 'And finally, divide by the number of bytes per array element (2 for
] INTEGER arrays, 4 for LONG or SINGLE, and 8 for DOUBLE), rounding up:
]
] ElementsNeeded% = (TotalBytes% + BytesPerElement% - 1) \ BytesPerElement%
]
] Now you know how many array elements you need.  DIMension an
] appropriately-sized array, and you're ready to go.
]
] Hope that helps.
]
] ---
] Glen Blankenship


]

Takes too damn long.  Just guess and check.  Works for me.  Go down to the
smallest number you can without getting an error.  Does not hurt your head a
smuch with all those damned formulas.

Mike



Sun, 24 Jan 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Put Byte Array Descriptor Length = 12 bytes?

2. This can be done by using the Visual Basic Shell command

3. using a command button to change what a loop is doing

4. Type Missmatch [dim b() as byte]

5. Type Missmatch [dim b() as byte]

6. How to put a DIM statement for an entire project

7. how to put exactly 1 byte to COM

8. Put writes one extra byte...

9. ITC - doing http PUT

10. Help Using VB4.0 - Trying to open database using Dynaset in Dim Statment

11. Need to convert a 16 byte array of bytes to 4 byte integer

12. Basic VBA question....DIM commands

 

 
Powered by phpBB® Forum Software