raveling@venera.isi.edu (Paul Raveling) (07/28/89)
There've been several requests in the last few days for a program to convert from the Img format, used by the images on venera, to Sun rasterfile format. By popular demand, plus natural pity for those who don't use X11 because the display servers are so bizarrely slow on color Suns, the end of this message is a hack to convert "Img" images to Sun rasterfiles. Most of it is a big "README" comment block. I don't have a Sun to test on, but this hack works on my HP in a double conversion test: Convert an image to a Sun rasterfile, then use a different hack to convert back to Img format. It's possible that Ed Falk posted a program to do this once, but I think his may have translated to GIF format. I may have a copy of it tucked away someplace, but can't find it right now. To someone at Georgia Tech whose name I've lost: I apologize for not reaching you through email -- there was trouble with the message bouncing from various mail handlers and I was foolish enough to delete your original message and each attempted reply after I sent it & before it bounced. After a few ricochets the only thing that was certain about your address was domain name gatech.edu. ---------------- Paul Raveling Raveling@isi.edu ----------------------------- Cut Here ------------------------------- /* File imgtosun.c Quickie hack to convert color-mapped Img files to Sun rasterfiles . To run: ------ imgtosun img_file[.p.Z] > sun_rasterfile Output goes to stdout to allow piping to anything useful, such as compress. !!!!!!!! Example: [cd /images/color_mapped] imgtosun billtcat | compress > billtcat.sun.Z or imgtosun billtcat.p.Z | compress > billtcat.sun.Z To build: --------- 1. Build libimg.a by connecting to your equivalent of "/images/libimg" and doing a Make. If necessary, run imake or modify Makefile to suit your system. 2. Connect to the directory containg this hack put the following into a Makefile, and say "make": IMGLIB = /images/imglib # Directory where you've built imglib imgtosun: imgtosun.c cc -O -o imgtosun -I $(IMGLIB) imgtosun.c -L $(IMGLIB) -limg -lX11 To build without X11: --------------------- Same procedure, except: 1. Delete '-lX11' from the one-line cc invocation above. 2. Before building /images/imglib/libimg.a, replace imgXlib.c with a dummy module that defines the same entry points, but doesn't include X11 header files or refer to externals used by X11. This utility uses NO functions in the X11 interface, so the emptier the dummy is, the better. 3. Run make in /images/imglib (or wherever you put it), then in this hack's directory. Disclaimer: This is a hack of a hack of a very old utility. Use it as is, at your own risk -- it wouldn't surprise me if it's not totally sanitary, or even not working at all. (I don't have a Sun to test it on.) Paul Raveling Raveling@isi.edu 7-27-89 */ #include <stdio.h> #include <imglib.h> #define RAS_MAGIC 0x59a66a95 #define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */ #define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */ main(argc, argv) int argc; char *argv[]; { Byte b; int i; Img *image; /* Read images from color mapped Img-format file */ image = read_img ( argv[1], mapped_image ); if ( image == NULL ) { fprintf ( stderr, "Couldn't read image\n" ); exit(2); } write_img ( argv[1], image ); /* Write rasterfile header */ putw(RAS_MAGIC, stdout); /* rf.ras_magic */ putw(image->width, stdout); /* rf.ras_width */ putw(image->height, stdout); /* rf.ras_height */ putw(8, stdout); /* rf.ras_depth */ putw(image->num_pixels, stdout); /* rf.ras_length */ putw(RT_STANDARD, stdout); /* rf.ras_type */ putw(RMT_EQUAL_RGB, stdout); /* rf.ras_maptype */ putw(image->num_colors*3,stdout); /* rf.ras_maplength */ /* Write color map */ for ( i=0; i < image->num_colors; ++i ) putc(image->colormap[i].red, stdout); for ( i=0; i < image->num_colors; ++i ) putc(image->colormap[i].green, stdout); for ( i=0; i < image->num_colors; ++i ) putc(image->colormap[i].blue, stdout); /* Write data */ i = fwrite ( image->pixdata, 1, image->num_pixels, stdout ); if ( i < image->num_pixels ) { fprintf ( stderr, "Couldn't write %d bytes!\n", image->num_pixels - i ); exit(1); } exit(0); }
falk@sun.Eng.Sun.COM (Ed Falk) (08/03/89)
In article <9081@venera.isi.edu>, raveling@venera.isi.edu (Paul Raveling) writes: > It's possible that Ed Falk posted a program to do this once, > but I think his may have translated to GIF format. I may > have a copy of it tucked away someplace, but can't find it > right now. Yes, I did. However if Paul's version works, I don't see any reason to post it again. (Now that I think about it, I haven't seen a request for a program to convert 24-bit images to 8-bit all week. I wonder if our feed is still good). -- -ed falk, sun microsystems, sun!falk, falk@sun.com "If you wrapped yourself in the flag like George Bush does, you'd be worried about flag-burning too"
spencer@heinlein.osc.edu (Stephen Spencer) (08/06/89)
In article <119297@sun.Eng.Sun.COM> falk@sun.Eng.Sun.COM (Ed Falk) writes: >(Now that I think about it, I haven't seen a request for a program to >convert 24-bit images to 8-bit all week. I wonder if our feed is still >good). > Because lots of graphics-minded people made the SIGGRAPH pilgrimage to Boston this week? Nice town, but having the exhibition on THREE floors of a convention center was too tiring. steve (amateur tray racer) ~ -=- Stephen N. Spencer |"For a successful technology, reality must take ACCAD, 1224 Kinnear Rd. | precedence over public relations, for Nature Columbus OH 43212 | cannot be fooled." - Richard P. Feynman spencer@heinlein.cgrg.ohio-state.edu OR spencer@cis.ohio-state.edu
watson@ames.arc.nasa.gov (John S. Watson) (08/08/89)
In article <277@oscsuna.osc.edu> spencer@heinlein.cgrg.ohio-state.edu (Stephen Spencer) writes: > > Because lots of graphics-minded people made the SIGGRAPH pilgrimage to > Boston this week? Nice town, but having the exhibition on THREE floors > of a convention center was too tiring. And climbing all thos escalators might lead to a heart attack. :-) John S. Watson, Civil Servant from Hell ARPA: watson@ames.arc.nasa.gov NASA Ames Research Center UUCP: ...!ames!watson Any opinions expressed herein are, like, solely the responsibility of the, like, author and do not, like, represent the opinions of NASA or the U.S. Government.
falk@sun.Eng.Sun.COM (Ed Falk) (08/14/89)
In article <29918@ames.arc.nasa.gov>, watson@ames.arc.nasa.gov (John S. Watson) writes: > In article <277@oscsuna.osc.edu> spencer@heinlein.cgrg.ohio-state.edu (Stephen Spencer) writes: > > > > Because lots of graphics-minded people made the SIGGRAPH pilgrimage to > > Boston this week? Nice town, but having the exhibition on THREE floors > > of a convention center was too tiring. > > And climbing all thos escalators might lead to a heart attack. :-) NO, NO, NO! Use the *other* escalators. -- -ed falk, sun microsystems, sun!falk, falk@sun.com "If you wrapped yourself in the flag like George Bush does, you'd be worried about flag-burning too"