sow@cad.luth.se (Sven-Ove Westberg) (04/24/88)
Did anyone know the format of Suns runlength encoding in the Run rasterfiles. I also appreciate a RTFM if you enclose the manual name and page number. The only information I have found is this short comment in the "rasterfile.h". #define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */ Please note, I am asking for the format not how to read a rasterfile with the sunlibraries. All hints is very much appreciated. Sven-Ove Westberg, CAD, University of Lulea, S-951 87 Lulea, Sweden. Tel: +46-920-91677 (work) +46-920-48390 (home) UUCP: {uunet,mcvax}!enea!cad.luth.se!sow ARPA: sow%cad.luth.se@ucbvax.berkeley.edu Internet: sow@cad.luth.se
kyriazis@pawl4.pawl.rpi.edu (George Kyriazis) (05/02/88)
In article <1051@luth.luth.se> Sven-Ove Westberg <sow@cad.luth.se> writes: > >Did anyone know the format of Suns runlength encoding in the >Run rasterfiles. I also appreciate a RTFM if you enclose the >manual name and page number. The only information I have found >is this short comment in the "rasterfile.h". > >#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */ > >Please note, I am asking for the format not how to read a rasterfile >with the sunlibraries. > You can certainly write a RT_BYTE_ENCODED rasterfile pretty easy using the appropriate pixrect routine. You have a pixrect and you dump it to a rasterfile with pr_dump(). You can give the RT_BYTE_ENCODED option there. ******************************************************* *George C. Kyriazis * Gravity is a myth *kyriazis@mts.rpi.edu or kyriazis@rpitsmts.bitnet * \ / *kyriazis@life.pawl.rpi.edu kyriazis@docsun.rpi.edu * \ / *Electrical and Computer Systems Engineering Dept. * || *Rensselaer Polytechnic Institute, Troy, NY 12180 * Earth sucks *******************************************************
paul@hpldola.HP.COM (Paul Bame) (05/03/88)
> >You can certainly write a RT_BYTE_ENCODED rasterfile pretty easy using the >appropriate pixrect routine. You have a pixrect and you dump it to a >rasterfile with pr_dump(). You can give the RT_BYTE_ENCODED option there. > I assume pixrect format is documented in the Sun manuals and I think it's used on the Mac as well. It's real simple and goes something like: control-byte,data-byte[s],control-byte,data-byte[s].... Where the control byte tells how to interpret the following data byte(s). If the sign bit is set (or clear? can't remember) then the number in the lower 7 bits tells how many times to repeat the value of the single following data byte. If the sign bit is the other way, the lower 7 bits tell how many data bytes follow - which should be copied verbatum to the output (this helps prevent 2x expansion on 01010101010 images). --Paul Bame hplabs!hpldola!paul hpldola!paul@hp-labs.csnet 719-590-5557
mae%vygr@Sun.COM (Mike Ekberg, Sun {Graphics Product Division}) (05/21/88)
Check out Pixrects manual, p 41. "...This support is implemented by passing raster files with non-standard types through filters founbd in /usr/lib/rasfilters. This directory also includes sample source code for a filter ..." Also, here's a start: /* dumprf.c - dump rasterfile formater */ #include <stdio.h> #include <suntool/sunview.h> #include <pixrect/pixrect.h> FILE * fp; main(argc, argv) int argc; char **argv; { Pixrect *pr; struct rasterfile rh; colormap_t colormap; if( (fp = fopen(argv[1],"r")) == NULL) { perror(argv[1]); exit(-1); } if( pr_load_header(fp,&rh) == PIX_ERR) { perror("Header"); exit(-1); } dump_rh(&rh); if( pr_load_colormap(fp,&rh,&colormap) == PIX_ERR) { perror("Colormap"); exit(-1); } if( (pr = pr_load_image(fp,&rh,&colormap)) == NULL) { perror("Image"); exit(-1); } } dump_rh(rh) /* dump rasterefile header */ struct rasterfile *rh; { printf("ras_magic = 0x%x.\n",rh->ras_magic); printf("ras_width = 0x%x.\n",rh->ras_width); printf("ras_height = 0x%x.\n",rh->ras_height); printf("ras_depth = 0x%x.\n",rh->ras_depth); printf("ras_length = 0x%x.\n",rh->ras_length); printf("ras_type = 0x%x.\n",rh->ras_type); printf("ras_maptype = 0x%x.\n",rh->ras_maptype); printf("ras_maplength = 0x%x.\n",rh->ras_maplength); } mike (sun!mae), M/S 5-40 "There's nothing human that's alien to us." - A. Einstein
david@sun.uucp (David DiGiacomo) (05/21/88)
In article <54042@sun.uucp> mae@sun.UUCP (Mike Ekberg, Sun {Graphics Product Division}) writes: > colormap_t colormap; > > ... > > if( pr_load_colormap(fp,&rh,&colormap) == PIX_ERR) { > perror("Colormap"); > exit(-1); > } Please note that it's not quite this easy to get the colormap if you are not lucky enough to have a 3.4 or newer pixrect library. Even if you have the right library, you must initialize the colormap struct before calling pr_load_colormap(); you can zero it or just set colormap.type to RMT_NONE. For an example of this look at /usr/lib/rasfilters/convert.2.c. Refer to the 3.[45] release manual or 4.0 pixrect manual for details. P.S. perror() is not likely to print anything sensible after a pixrect function fails. P.P.S. Is this stuff too vendor specific for comp.graphics? Does everyone who is interested get sun-spots?