DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T v

⟦c0f8dee60⟧ TextFile

    Length: 2530 (0x9e2)
    Types: TextFile
    Names: »var_long_image.c++«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec1/image/varc++/var_long_image.c++« 

TextFile

/*
    This is the interface between the mv image file format
    and my c++ image handling datatype for images full of longs
*/
#include <stream.h>
#include <stdio.h>
#include "error.h++"
#include "var.h++"
#include "image.h++"
#include "for.h++"
#include "long_image.h++"

/*
    Reads in a long image from a mv file
*/
long_image::long_image 
	( 
	const read_image_type rit , 	// marker that the image is being read
	const FILE * image_file ,	// file for image
	const card w_width = 1 ,	// window width
	const card w_length = 1		// window length
	)
    : ( READ , image_file ,  w_width , w_length )
    {
    /* check that the constructor is called correctly */
    if ( rit != READ )
	{
	cerr << "constructor for long_image being called in obscure way\n";
	abort();
	}
    
    /* read in image from file */
    struct var_header *vh = (struct var_header *) header_info;
    long * image_buffer = var_read_longs ( image_file , vh );
    if (error_occured)
	{
	cerr << "error when reading in data from file";
	print_errors_and_abort();
	}
    /* assign fields of the class */
    comments = vh->vh_comments;
    comment_length = strlen(vh->vh_comments);
    number_rows = vh->vh_length;
    number_cols = vh->vh_width;

    /* allocate space for dope vector */
    image_rows = new long * [ number_rows ];
    /* allocate space for window dope vector */
    window_rows = new long * [ w_length ];

    /* initialize dope vector */
    FOR(int i1 = 0 ; i1 < number_rows; i1++)
	{
	image_rows[i1] = image_buffer + i1*number_cols;
	}
    ENDFOR

    /* set up the protection  so the image can be written */
    prot = CAN_READ;

    /* initialize function pointers */
    next = &uninitialized_next;
    prev = &uninitialized_prev;
    get_w_e_pointer = &uninitialized_get_w_e;
    write_w_e_pointer = &uninitialized_write_w_e;
    }

/*
    This writes out a long image to a mv image file
*/
void
long_image::write ( )
    {
    /* do the image independent stuff */
    this->image_class::write();

    /* fill in the relevant fields of the header info */
    struct var_header *vh = var_create_long_header(number_rows,number_cols);
    vh->vh_comments = comments;

    /* put the header, comments and data out to the file */
    var_write_longs(file,vh,image_buffer);
    
    }
/*
Copyright (C) 1986, David Sher in the University of Rochester
Permission is granted to any individual or institution to use, copy, or
redistribute this software so long as it is not sold for profit, provided
this copyright notice is retained.
*/