Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!UMIX.CC.UMICH.EDU!krowitz%richter From: krowitz%richter@UMIX.CC.UMICH.EDU (David Krowitz) Newsgroups: comp.sys.apollo Subject: Re: APOLLO.gmf format Message-ID: <8911301532.AA01677@richter.mit.edu> Date: 30 Nov 89 15:32:41 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 263 You can write a relatively simple Fortran program on your Apollo to solve this problem. Use the GMF_$ calls to open the bitmap file and copy it into a GPR bitmap. Then use the GPR_$READ_PIXELS call to read the pixel values into a memory array and use the standard Fortran (or C) I/O calls to write the array out in whatever format you like. I've got a simple Fortran program that does this for GPR bitmaps which I've included below. Just change the code that reads in the GPR bitmap to use GMF calls. -- David Krowitz krowitz@richter.mit.edu (18.83.0.109) krowitz%richter.mit.edu@eddie.mit.edu krowitz%richter.mit.edu@mitvma.bitnet (in order of decreasing preference) ===================================cut here========================= {***************************************************************************** ***** ***** ***** GPRDUMP.PAS ***** ***** ***** ***** Program to read GPR bitmap files and dump the color map and ***** ***** the contents of the bitmap into a unformatted binary data ***** ***** file which can be read by a Fortran program. ***** ***** ***** ***** Version 2 ***** ***** David M. Krowitz September 9, 1988. ***** ***** ***** ***** Copyright (c) 1988 ***** ***** David M. Krowitz ***** ***** Massachusetts Institute of Technology ***** ***** Department of Earth, Atmospheric, and Planetary Sciences ***** ***************************************************************************** } PROGRAM GPR_DUMP; %NOLIST; %INCLUDE '/sys/ins/base.ins.pas'; %INCLUDE '/sys/ins/error.ins.pas'; %INCLUDE '/sys/ins/gpr.ins.pas'; %INCLUDE '/sys/ins/ios.ins.pas'; %INCLUDE '/sys/ins/pgm.ins.pas'; %INCLUDE '/sys/ins/type_uids.ins.pas'; %LIST; CONST {Program version number - should be same as in file header above} version_number = 2; TYPE byte = 0..255; color_map_entry = PACKED RECORD unused: byte; red: byte; green: byte; blue: byte; END; VAR infile: ARRAY[1..80] OF CHAR; infile_len: PINTEGER; outfile: ARRAY[1..80] OF CHAR; outfile_len: PINTEGER; out: IOS_$ID_T; hi_plane: GPR_$PLANE_T; bitmap: GPR_$BITMAP_DESC_T; window: GPR_$WINDOW_T; file_bm: GPR_$BITMAP_DESC_T; { Bitmap descriptor for GPR bitmap file } file_cm: GPR_$COLOR_VECTOR_T; { Color map for the GPR bitmap file } attribs: GPR_$ATTRIBUTE_DESC_T; version: GPR_$VERSION_T; header: GPR_$BMF_GROUP_HEADER_ARRAY_T; groups: INTEGER; created: BOOLEAN; i,j: LINTEGER; { Counters } pixel_size: PINTEGER; { Size of bitmap pixels (1 to 8, or 24) } pixels_24: ARRAY[1..4096] OF GPR_$PIXEL_VALUE_T; { Pixel values read from bitmap } pixels_8: PACKED ARRAY[1..4096] OF CHAR; { 8-bit pixels from bitmap } source: GPR_$WINDOW_T; { Window from which pixels are being read } status: STATUS_$T; BEGIN {Type initial greetings to user.} WRITELN ('This is GPRDUMP Version ',version_number:-1,'.'); WRITELN; {Get the names of the input and output files.} IF (PGM_$GET_ARG (1, infile, status, SIZEOF(infile)) <> 0) THEN BEGIN infile_len := PGM_$GET_ARG (1, infile, status, SIZEOF(infile)); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - argument 1 exists, but bad status? ****'); PGM_$EXIT; END; END ELSE BEGIN WRITE ('Enter name of GPR bitmap file for input: '); READLN (infile); infile_len := SIZEOF(infile); END; IF (PGM_$GET_ARG (2, outfile, status, SIZEOF(outfile)) <> 0) THEN BEGIN outfile_len := PGM_$GET_ARG (2, outfile, status, SIZEOF(outfile)); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - argument 2 exists, but bad status? ****'); PGM_$EXIT; END; END ELSE BEGIN WRITE ('Enter name of unformatted binary file for output: '); READLN (outfile); outfile_len := SIZEOF(outfile); END; { Initialize the GPR library with a 1x1 dummy bitmap in main memory } WITH window.window_size DO BEGIN x_size := 1; y_size := 1; END; GPR_$INIT (gpr_$no_display, 0, window.window_size, 0, bitmap, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not initialize GPR library ****'); ERROR_$PRINT (status); PGM_$EXIT; END; { Open the output file } IOS_$CREATE (outfile, outfile_len, RECORDS_$UID, IOS_$RECREATE_MODE, [IOS_$WRITE_OPT], out, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not open output file ****'); ERROR_$PRINT (status); PGM_$EXIT; END; { Get the GPR bitmap into memory along with it's color map } GPR_$ALLOCATE_ATTRIBUTE_BLOCK (attribs, status); GPR_$OPEN_BITMAP_FILE (GPR_$WRITE, infile, infile_len, version, window.window_size, groups, header, attribs, file_bm, created, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not open GPR bitmap file ****'); ERROR_$PRINT (status); PGM_$EXIT; END; GPR_$INQ_BITMAP_FILE_COLOR_MAP (file_bm, 0, 256, file_cm, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not read color map for bitmap file ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; { Set the current bitmap to be the GPR bitmap file } GPR_$SET_BITMAP (file_bm, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not make bitmap file the current bitmap ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; { Calculate pixel size from the number of bitmap sections and the per-section pixel size } pixel_size := header[0].n_sects*header[0].pixel_size; { Output the size of the bitmap } WRITELN ('Bitmap size is: ', window.window_size.x_size:-1, ' by ', window.window_size.y_size:-1); WRITELN ('Pixel size is: ', pixel_size:-1); IOS_$PUT (out, [IOS_$PARTIAL_RECORD_OPT], window.window_size, SIZEOF(window.window_size), status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not write bitmap size to output file header record ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; IOS_$PUT (out, [], pixel_size, SIZEOF(pixel_size), status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not write pixel size to output file header record ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; { Output the color map entries if the bitmap is a psuedo-color (1 to 8 planes) bitmap } IF (pixel_size <= 8) THEN BEGIN for i := 0 to 255 do writeln (file_cm[i]); IOS_$PUT (out, [], file_cm, SIZEOF(file_cm), status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not write GPR color map to output file ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; END; { Write out the bitmap, one line per record } source.window_size.x_size := window.window_size.x_size; source.window_size.y_size := 1; source.window_base.x_coord := window.window_base.x_coord; source.window_base.y_coord := window.window_base.y_coord; FOR i := 1 TO window.window_size.y_size DO BEGIN GPR_$READ_PIXELS (source, pixels_24, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not read GPR pixel values for line ',i:-1,' ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; FOR j := 1 TO source.window_size.x_size DO BEGIN pixels_8[j] := CHR(pixels_24[j]); IF (pixels_24[j] > 255) THEN WRITELN ('Warning - pixel value greater than 8-bits'); END; IOS_$PUT (out, [], pixels_8, source.window_size.x_size, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not write pixel values into output file for line ',i:-1,' ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; source.window_base.y_coord := source.window_base.y_coord+1; END; { Close up the output file and cleanup } IOS_$CLOSE (out, status); IF (status.all <> STATUS_$OK) THEN BEGIN WRITELN ('**** GPRDUMP: Error - could not close output file ****'); ERROR_$PRINT (STATUS); PGM_$EXIT; END; END.