home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jhunix.hcf.jhu.edu!fmsrl7!destroyer!gatech!swrinde!network.ucsd.edu!pitstop.ucsd.edu!spl
- From: spl@pitstop.ucsd.edu (Steve Lamont)
- Newsgroups: sci.image.processing
- Subject: Re: conversion to xv formats
- Date: 22 Jan 1993 22:17:40 GMT
- Organization: University of Calif., San Diego/Microscopy and Imaging Resource
- Lines: 43
- Message-ID: <1jprq4INN320@network.ucsd.edu>
- References: <1993Jan22.184317.1411@igor.tamri.com>
- NNTP-Posting-Host: pitstop.ucsd.edu
-
- In article <1993Jan22.184317.1411@igor.tamri.com> ilya@igor.tamri.com (Ilya Simovsky) writes:
- >Dear gurus:
- >Could anybody, please, advise me where I can find a program for UNIX to convert
- >a 16 bit binary grayscale image (i.e a file with say 256*256 short int) to one
- >of the following formats : GIF, JPEG, TIFF, PBM, PGM, PPM, X11 bitmap, Utah Raster Toolkit RLE, PDS/VICAR, Sun Rasterfile, PM.
-
- #include <stdio.h>
-
- /*
- * Raw 16 bit to pgm "translator"
- * Copyright abandoned.
- */
-
- main()
-
- {
-
- short int inbuffer[256 * 256];
- char outbuffer[256 * 256];
- int i;
-
- fread( inbuffer, sizeof( short int ), 256 * 256, stdin );
-
- for ( i = 0; i < 256 * 256; i++ )
- outbuffer[i] = inbuffer[i] >> 8;
-
- printf( "P5\n256 256\n255\n" );
- fwrite( outbuffer, sizeof( char ), 256 * 256, stdout );
-
- exit( 0 );
-
- }
-
- Error checking and enhancements are left as an exercise for the student.
-
- I mean, it ain't that difficult...
-
- spl
- --
- Steve Lamont, SciViGuy -- (619) 534-7968 -- spl@szechuan.ucsd.edu
- UCSD Microscopy and Imaging Resource/UCSD Med School/La Jolla, CA 92093-0608
- "The English are drinking the better beer in Bavaria."
- - Archibald Macleish, "Lines for an Interment"
-