openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openexr-devel] Read OpenEXR from memory data source ?


From: Gernot Ziegler
Subject: [Openexr-devel] Read OpenEXR from memory data source ?
Date: Sun, 6 Mar 2005 22:19:42 +0100 (MET)

Hej !

I am currently implementing an OpenEXR input plugin and would need to read
from a memory source that is defined in the call:

load_openexr(unsigned char *mem, int size)

So far, I have implemented a Mem_IStream (see code below), but the problem
is that I can't get past the filename check -
> OpenEXR-load: testing input
> Cannot read image file "dummy". File is not an image file.

Did I miss something here ?

IStream should by design be able to read from memory, right ?

Hints are welcome :-)

----
class Mem_IStream: public IStream
{
 public:

  Mem_IStream (unsigned char *exrbuf, int exrsize):
    IStream("dummy"), _exrpos (0), _exrsize(exrsize)  { _exrbuf = exrbuf;
}

  virtual bool  read (char c[], int n);
  virtual Int64 tellg ();
  virtual void  seekg (Int64 pos);
  virtual void  clear ();

 private:

  Int64 _exrpos;
  Int64 _exrsize;
  unsigned char *_exrbuf;
};

bool Mem_IStream::read (char c[], int n)
{
  if (n + _exrpos < _exrsize)
    {
      memcpy(c, (void *)(_exrbuf[_exrpos]), n);
      _exrpos += n;
      return true;
    }
  else
    return false;
}

Int64 Mem_IStream::tellg ()
{
  return _exrpos;
}

void Mem_IStream::seekg (Int64 pos)
{
  _exrpos = pos;
}

void Mem_IStream::clear ()
{
}


Servus,
  Gernot

-- 
T----------------------------W-E-L-C-O-M-E------------------------------T
|  The Austria <=> Sweden <=> Germany <=> Netherlands connection.....   H
O  http://www.mpi-sb.mpg.de/~gziegler | http://lysator.liu.se/~gz       E
\------------------------------F-U-T-U-R-E------------------------------/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]