www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/13/10:00:01

From: Nathan <ucgansj AT ucl DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP: seekg 16/8bit problem!!! CODE C++
Date: Thu, 13 Jan 2000 11:34:33 +0000
Organization: University College London
Lines: 142
Message-ID: <387DB849.986184E@ucl.ac.uk>
References: <387C4E01 DOT 112479F3 AT ucl DOT ac DOT uk> <85iad1$eu3$2 AT antares DOT lu DOT erisoft DOT se>
NNTP-Posting-Host: psaurus.anat.ucl.ac.uk
Mime-Version: 1.0
X-Trace: uns-a.ucl.ac.uk 947762874 17916 128.40.53.42 (13 Jan 2000 11:27:54 GMT)
X-Complaints-To: usenet AT ucl DOT ac DOT uk
NNTP-Posting-Date: 13 Jan 2000 11:27:54 GMT
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

No, this works like gibberish,
	nathan

// program for working out file size

#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>
#include <iomanip.h>

long image=0, matrix_r=0, matrix_c=0, depth=0, i=0;
char if_name[80], of_name[80];
// declare variables

void main(int argc, char **argv)
{

// check for input error

 cout << "number of rows:";
 cin >> matrix_r;
 cout << "number of columns:";
 cin >> matrix_c;
 cout << "pixel depth (8 or 16):";
 cin >> depth;
 cout << "output name:";
 cin >> of_name;
 // input variables


 if (!of_name)
    {
    cout << "File output not specified" << endl;
    exit (-1);
    }

 if (depth!=8 && depth!=16)
    {
    cout << "wrong depth value, try 8 or 16" << endl;
    exit (-1);
    }
 // error checking

 ofstream output(of_name, ios::binary | ios::out );
 if (!output)
    {
     cout << "couldn't open file" << endl;
     exit (-1);

     }
 // open output and check for errors

 for (i=1; i<argc; i++)
     {
// define for loop

 ifstream input(argv[i], ios::binary | ios::in );

 if (!input)
    {
    cout << "couldn't open file" << endl;
    exit (-1);
    }
// open input and check for error

image = (((matrix_r*matrix_c)*(depth/8))-1);
//work out header length with -1 so that seekg skips the correct no.
bytes


if (image < 0 )
    {
    cout << "Estimated file size incorrect!!, check matrix size and
depth"<< endl;
    exit (-1);
    }
 //check file and header sizes

 input.seekg(-image, ios::end);
// jump header length from begining of while
// this is where big problems start occuring with 16bit files.The images
appear with
// very abnormal grey distributions. Appears to work fine with 8bit
images???

while (!input.eof())
      {
      char ch;
      ch=input.get();
      output << ch;
      }

// write the rest to output file

cout << "reading file...., size ="<<image <<endl;

 input.close();

}
 output.close();
 }



Martin Stromberg wrote:
> 
> Nathan (ucgansj AT ucl DOT ac DOT uk) wrote:
> : This is a multi-part message in MIME format.
> : --------------5138758AE268DEF0F6B08126
> : Content-Type: text/plain; charset=us-ascii
> : Content-Transfer-Encoding: 7bit
> 
> : Here is the code,
> 
> No here is unreadable gibberish:
> 
> : Ly8gcHJvZ3JhbSBmb3Igd29ya2luZyBvdXQgZmlsZSBzaXplDQoNCiNpbmNsdWRlIDxpb3N0
> : cmVhbS5oPg0KI2luY2x1ZGUgPHN0ZGxpYi5oPg0KI2luY2x1ZGUgPGZzdHJlYW0uaD4NCiNp
> : bmNsdWRlIDxpb21hbmlwLmg+DQoNCmxvbmcgaW1hZ2U9MCwgbWF0cml4X3I9MCwgbWF0cml4
> : X2M9MCwgZGVwdGg9MCwgaT0wOw0KY2hhciBpZl9uYW1lWzgwXSwgb2ZfbmFtZVs4MF07DQov
> 
> Right,
> 
>                                                         MartinS

-- 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Nathan Jeffery
Evolutionary Anatomy Unit
Dept. of Anatomy & Developmental Biology
Rockefeller Building, University Street
University College London
London WC1E 6JJ
UK

tel: 0171-209-6215
fax: 0171-209-0346
email: ucgansj AT ucl DOT ac DOT uk
http://evolution.anat.ucl.ac.uk/people/nathan/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019