reading .raw files (windows-linux)

  • Thread starter christos panagiotou
  • Start date
C

christos panagiotou

hi all

I am trying to open some .raw files that represent images (256x256, 8
bit per pixel, no header) in a c++ program
I cannot copy paste the module here as it uses a method from the VTK
(Visualization Toolkit)

the module i ve got is already tested with the same dataset and it works

if these files have been created under windows and copied in linux (i am
developing under linux) would this change something? do they need
different handling? I cannot think something else at the moment as the
module is tested under windows

i would appreciate any help
christos
 
V

Victor Bazarov

christos panagiotou said:
I am trying to open some .raw files that represent images (256x256, 8
bit per pixel, no header) in a c++ program
I cannot copy paste the module here as it uses a method from the VTK
(Visualization Toolkit)

the module i ve got is already tested with the same dataset and it works

if these files have been created under windows and copied in linux (i am
developing under linux) would this change something? do they need
different handling? I cannot think something else at the moment as the
module is tested under windows

Your question has one answer here, in comp.lang.c++, and it's
"Yes, it would potentially change something". What exactly
it would change you need to ask either in a Linux programming
newsgroup or in a newsgroup where 'raw' files are on topic
(comp.graphics.algorithms, maybe?)

Victor
 
V

Vasileios Zografos

if these files have been created under windows and copied in linux (i am
developing under linux) would this change something? do they need
different handling? I cannot think something else at the moment as the
module is tested under windows


Probably, and assuming we are taking about binary files. In *nixes there
are a few differences on how files are handled than in Windows.

More specificaly:

"The C++ library <fstream> recognizes two kinds of files: binary and
text files. By default all files are opened as text files. To open a
binary file you should include the ios::binary value in the openmode
argument for the open function such as:

ifstream inputFile
inputFile.open("somename.bin", ios::in | ios::binary);

On some operating platforms (e.g. Unix) there is no difference between
binary files and text files and the use of the ios::binary argument has
no effect. On other platforms (e.g. MSDos, Windows) they have a distinct
difference.

Thos platforms that differentiate between text files and binary files do
so in these ways:

1. When a program writes a newline (\n) character to a binary file, the
file system writes the single newline character which on most platforms
is the same as the linefeed (0x0a) character
2. When the program writes a newline character to a text file, the files
system writes two characters: a carriage return character (0x0d)
followed by a linefeed character (0x0a)
3. When the program reads a newline character from a binary file, the
file system reads the signle newline character into memory
4. When the program reads a carriage return/linefeed character pair from
a text file, the system translates the pair into a single newline
character in memory.
5. When the program reads a single newline character -a linefeed that is
not preceded by a carriage return character- from a text file, the file
system inserts the newline character into memory.


This approach has significant implications mainly involving file
position operations -seeking and telling. "


Hope this helps
V.Z.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top