🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: sci.image.processing
Article #913

Re: conversion to xv formats

#913
From: Steve Lamont
Date: Fri, 22 Jan 1993 22:17
43 lines
1762 bytes
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"
Technical Details
Message-ID: <1jprq4INN320@network.ucsd.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!jhunix.hcf.jhu.edu!fmsrl7!destroyer!gatech!swrinde!network.ucsd.edu!pitstop.ucsd.edu!spl
References: <1993Jan22.184317.1411@igor.tamri.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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