#! /usr/bin/python -t # _*_ coding: iso-8859-1 _*_ # Last edited on 2010-06-15 21:48:30 by stolfi MODULE_NAME = "jspnm_image" MODULE_DESC = "In-core format and ops for PPM/PGM images" MODULE_VERS = "1.0" MODULE_COPYRIGHT = "Copyright © 2010 State University of Campinas" MODULE_INFO = "!!! MODULE_INFO to be written" import sys import re import string import copy # Functions for parsing UNIX command line arguments. class jspnm_image_t : "A parser for command line options.\n" \ "\n" \ " An {jspnm_image_t} instance is three numbers {chns,cols,rows}, an" \ " integer {maxval}, and a three-dimensional array" \ " of integer samples in the range {0..maxval}. The first index is the channel, then" \ " raster column and row.\n" def __init__(pp, chns, cols, rows, maxval) : "Initalizes a {jspnm_image_t} instance and creates the sample array." # Instance setup: pp.chns = chns; pp.cols = cols; pp.rows = rows; pp.maxval = maxval; pp.smp = make_sample_array(nx, ny) assert (maxval > 0); assert (chns == 1) or (chns == 3); # ---------------------------------------------------------------------- def make_sample_array(chns,cols,rows) : sys.stderr.write("allocating array\n"); a = chns*[None]; for c in range(chns) : a[c] = copy.copy(rows*[None]) for y in range(rows) : a[y] = copy.copy(nx*[None]) return a; # ---------------------------------------------------------------------- help_info_NO_WARRANTY = \ "This software is provided 'as is', WITHOUT ANY EXPLICIT OR" \ " IMPLICIT WARRANTY, not even the implied warranties of merchantibility" \ " and fitness for a particular purpose." help_info_STANDARD_RIGHTS = \ "Permission to use, copy, modify, and redistribute this software and" \ " its documentation for any purpose is hereby granted, royalty-free," \ " provided that: (1) the copyright notice at the top of this" \ " file, and the AUTHOR, WARRANTY and RIGHTS sections of this" \ " text are retained in all derived source files; (2) no executable" \ " code derived from this file is published or distributed without the" \ " corresponding source code; and (3) these same rights are granted to" \ " any recipient of such code, under the same conditions."