reading .raw files (windows-linux)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • christos panagiotou

    reading .raw files (windows-linux)

    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

  • Victor Bazarov

    #2
    Re: reading .raw files (windows-linux)

    "christos panagiotou" <cpanagio@cs.uc l.ac.uk> wrote...[color=blue]
    > 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[/color]

    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


    Comment

    • Vasileios Zografos

      #3
      Re: reading .raw files (windows-linux)

      > if these files have been created under windows and copied in linux (i am[color=blue]
      > 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[/color]


      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.b in", 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.

      Comment

      Working...