Turbo Pascal GetImage/PutImage format--a summary

Turbo Pascal GetImage/PutImage format--a summary

Post by Tom Swing » Wed, 17 Jul 1991 11:36:23

Here is what I have found out about my recent question regarding the format
used with GetImage and PutImage by Turbo Pascal, partly with the help of other
people on the net, partly through my own experimentation:

The first six bytes contain information used to restore the image--the first
word contains the width of the image, the second word contains the height, and
the third word is reserved (for what I have no idea).  Actually, the values
stored for width and height are one less than the actual width and height.  

The rest of the image contains the image data, but it is not quite as
straightforward as one might expect.  If you want to know how much storage your
image will occupy, you have to round the width of the image up to the nearest
eight pixels.  In other words, Turbo stores the rows of the image in eight
pixel chunks, with the rows following one after the other in memory.  So
depending on how many bits per pixel are used, the storage requirements for
each row must be rounded up--to the nearest b bytes, where b is the number of
bits per pixel (1 for a 2-color mode, 2 for a 4-color mode, 4 for a 16-color
mode, and 8 for a 256-color mode).  This had me seriously thrown off for the
longest time, but with many comparisons of image sizes in various modes, I
finally recognized the pattern.  So if I'm not mistaken, ImageSize(x1,y1,x2,y2)
works out to be

 (x2-x1+1 rounded up to the nearest 8)*(y2-y1+1)*(bitsperpixel/8), or
 ((x2-x1) div 8+1)*8*(y2-y1+1)*bitsperpixel div 8

I believe these results are correct.  If anyone else has played around with
the BGI who can confirm or deny it, please share your knowledge.


1. How is data stored with getimage/putimage in Turbo Pascal?

I am writing an application for which I need to know what data GetImage stores
and what PutImage expects.  I am familiar with the way the image data itself is
stored; what I need to know is the stuff that is stored *before* the image data
is written (block width and height and other stuff that might be stored).  What
I am really trying to do is build an image in a buffer and then send it to
putimage so that putimage thinks it is an image that was captured from the
screen, all without actually drawing the image on the screen.  The image will
be very simple, but it could have varying width and (possibly) height, so it
is not practical to have an image stored beforehand; I definitely need to be
able to build it on the fly.  Any info would be appreciated.  If anyone has a
better way to do what I am thinking of, I would welcome hearing that also, but
I would still like to know the storage method anyhow for future reference.

2. Problem with relay

3. TP6.0 GetImage/PutImage data format?

4. 1. Buy Electronic Components Online 2. Get Manufacturing Services 3. High Tech News

5. Turbo C getimage() image format?

6. Updating a DB record - fixing "data type mismatch" error

7. getimage()/putimage() Success, but two more problems! :(

8. TMON still around?

9. Help with blitting/getimage/putimage!

10. Need putimage/getimage routine...

11. help with getimage/putimage...can some one fix this?

12. How do you get GETIMAGE PUTIMAGE to work for 48k size under TC??

13. Help with Putimage/getimage...