[comp.lang.pascal] Storing screen image for quick display

6500boo@ucsbuxa.ucsb.edu (William Bushing) (01/22/91)

I'm not the World's Greatest Turbo Pascal programmer, but once
I get a sense of direction I can muddle through.

I wrote software to read a data file and display 512 x 512
images in 800 x 600 sVGA mode. After displaying the image I
want to do things like thresholding, creating binary images,
applying false color palettes, etc., without destroying the
original image. In other words I want to temporarily apply
thresholding, etc., then be able to QUICKLY redisplay the 
original screen image.

I tried using arrays to store the pixel values in a [512,512]
array (too large for TP 5.5) and a series of four [512,128]
arrays. No luck. What data structure should I use to store the
image and then quickly recall it? If it involves pointers, I
don't feel comfortable with them. Can I use my computer's RAM
to store the pixel values in a contiguous set of memory addresses
and then retrieve the values?

All I need is the proper direction to turn, not complete code
(although a basic idea might help). Many thanks in advance
for any help.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
William W. (Boo) Bushing  |  "Life is too important to be
6500boo@ucsbuxa.bitnet    |       taken seriously"
6500boo@ucsbuxa.ucsb.edu  |            - Einstein
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

mcastle@mcs213f.cs.umr.edu (Mike Castle {Nexus}) (01/23/91)

In article <8416@hub.ucsb.edu> 6500boo@ucsbuxa.ucsb.edu (William Bushing) writes:
>I tried using arrays to store the pixel values in a [512,512]
>array (too large for TP 5.5) and a series of four [512,128]
>arrays. No luck. What data structure should I use to store the
>image and then quickly recall it? If it involves pointers, I
>don't feel comfortable with them. Can I use my computer's RAM
>to store the pixel values in a contiguous set of memory addresses
>and then retrieve the values?

Try GetImage/PutImage along with ImageSize.  Good examples on how to use these
in the manual (and since using 5.5, in online help as well). 

The only thing you might have problems with it changing the palette.  I'm not
sure in what format it's saved in with GetImage, but my guess would be the entry
to the color map, rather than the RGB values themselves.  So, you might want to
save and restore the current palette as well as the bit image.
-- 
Mike Castle (Nexus) S087891@UMRVMA.UMR.EDU (preferred)       | ERROR:  Invalid
                mcastle@mcs213k.cs.umr.edu (unix mail-YEACH!)| command 'HELP'
Life is like a clock:  You can work constantly, and be right | try 'HELP'
all the time, or not work at all, and be right twice a day.  |

zhou@brazil.psych.purdue.edu (Albert Zhou) (01/23/91)

The quickest way is to use direct address, I think.

ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (01/23/91)

If you're willing to run in EGA mode, you can "redisplay" images quickly and
very easily.  In EGA mode there are multiple pages, only one of which is 
active.  While the active page is being displayed, you can draw to a 
non-active page.  Once the drawing's done, you can "flip" the pages, making
the non-active page active (hence visible on the screen).

Anyway this is a common way to do animation.  Unfortunately TP does not
support multiple pages for VGA or SVGA.

Terrell

mpe@shamash.cdc.com (Mike Ebsen) (01/23/91)

If you read many of the svga ads you'll see references to either 256K, 512K
or even a 1meg vga board.  This is the amount of "RAW" storage which the
CRT display controller has to maintain the images that we see.  Using 
rather simple mathematics you can compute the actual requirements:
     Total := getmaxx * getmaxy * bytes_per_pixel;
           := 640     * 480     * 1 (usually)
           := 307200 (a bit more than the 64K max data segment allows!)

You could create 10 (or so) smaller array structures, each approx 30K but
this is messy and comsumes all of the available heap and static memory.  The
best approach that I can think of is to use the paging structure built into 
every graphics display card.  By  setting SetActivePage and SetDisplayPage
correctly, you can manage two seperate display maps, completely within the
hardware and memory you already have and not be troubled by large messy 
data structers.

a499@mindlink.UUCP (Robert Salesas) (01/24/91)

Isn't it possible to use 2 graphic pages?  Keep an original in page 1
and the mods in page one, then switch when you need it?
Rob

steven@ozonebbs.UUCP (Steven Rubin) (01/25/91)

6500boo@ucsbuxa.ucsb.edu (William Bushing) writes:

> I tried using arrays to store the pixel values in a [512,512]
> array (too large for TP 5.5) and a series of four [512,128]
> arrays. No luck. What data structure should I use to store the
> image and then quickly recall it? If it involves pointers, I
> don't feel comfortable with them. Can I use my computer's RAM
> to store the pixel values in a contiguous set of memory addresses
> and then retrieve the values?
> 
Of course you can use your computers RAM to store the pixel values !  Thats 
what you do when you are using a pointer!  

---
Steven Rubin
E-Mail: steven%ozonebbs@netcom.uucp
 Snail: 3670 Rollingside Dr, San Jose, CA 95148-2822
 Phone: +1 408 238 2818, +1 408 223 1738 (bbs)
Disclaimer: My mommy told me not to talk to strangers
 (Note: The FROM: line is incorrect, use steven%ozonebbs@netcom.uucp)

nate@neutron.lcs.mit.edu (01/25/91)

I have used the two graphic pages in hercules mode to do animation by
creating the next image in the page not showing and then switching to
it.  I believe that this can also be done in ega mode.

nate liskov

tamari@bimacs.BITNET (tamari zvi) (02/12/91)

In article <1991Jan23.051813.12112@isis.cs.du.edu> ebergman@isis.UUCP (Eric Bergman-Terrell) writes:
>
>Anyway this is a common way to do animation.**  Unfortunately TP does not
>support multiple pages for VGA or SVGA. **
>
>Terrell

not exactly. it's true that the best multiple pages support is for the
EGA (256k) in the low resolution mode (640x200) it allows to use 4
pages.

In the EGA (256k) High resolutiom mode (640x350), EGA-MONO (256k),
Hercules, AND VGA in it's low (640x200) and medium (640x350)
resolution support 2 pages each.
                                                        Zvi Tamari.


 --
Name : Zvi Tamari

E-Mail Addresses : BitNet   : tamari@bimacs.bitnet
                   InterNet : tamari@bimacs.cs.biu.ac.il

Address : 3   Hameiri  st.
          Ramat Gan 52 651
          ISRAEL            Telephone : 03-340169

ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (02/16/91)

Good info.  When I said that TP didn't support multiple pages of graphics
for VGA or SVGA boards, I should have said "except when such boards are
emulating an EGA or in a low res mode".

Furthermore it's probably not fair to blame TP - I believe the limitation
exists in the graphics board, not in any driver...

Terrell