1 /*! ========================================================================
4 ** $Id: mptr_openexr.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This software and associated documentation
9 ** are CONFIDENTIAL and PROPRIETARY property of
10 ** the above-mentioned copyright holder.
12 ** You may not copy, print, publish, or in any
13 ** other way distribute this software without
14 ** a prior written agreement with
15 ** the copyright holder.
17 ** === N O T E S ===========================================================
19 ** ========================================================================= */
21 /* === H E A D E R S ======================================================= */
30 #include "mptr_openexr.h"
31 #include <sinfg/sinfg.h>
32 #include <ETL/stringf>
38 #include <ImfRgbaFile.h>
43 /* === M A C R O S ========================================================= */
45 using namespace sinfg;
49 /* === G L O B A L S ======================================================= */
51 SINFG_IMPORTER_INIT(exr_mptr);
52 SINFG_IMPORTER_SET_NAME(exr_mptr,"exr_mptr");
53 SINFG_IMPORTER_SET_EXT(exr_mptr,"exr");
54 SINFG_IMPORTER_SET_VERSION(exr_mptr,"0.1");
55 SINFG_IMPORTER_SET_CVS_ID(exr_mptr,"$Id: mptr_openexr.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $");
57 /* === M E T H O D S ======================================================= */
59 exr_mptr::exr_mptr(const char *file)
69 exr_mptr::get_frame(sinfg::Surface &out_surface,Time, sinfg::ProgressCallback *cb)
74 Imf::RgbaInputFile in(filename.c_str());
76 int w = in.dataWindow().max.x - in.dataWindow().min.x + 1;
77 int h = in.dataWindow().max.y - in.dataWindow().min.y + 1;
78 //int dx = in.dataWindow().min.x;
79 //int dy = in.dataWindow().min.y;
82 out_surface.set_wh(w,h);
83 in.setFrameBuffer (reinterpret_cast<Imf::Rgba *>(out_surface[0]), 1, w);
85 in.readPixels (in.dataWindow().min.y, in.dataWindow().max.y);
88 etl::surface<Imf::Rgba> in_surface;
89 in_surface.set_wh(w,h);
90 in.setFrameBuffer (reinterpret_cast<Imf::Rgba *>(in_surface[0]), 1, w);
92 in.readPixels (in.dataWindow().min.y, in.dataWindow().max.y);
96 out_surface.set_wh(w,h);
97 for(y=0;y<out_surface.get_h();y++)
98 for(x=0;x<out_surface.get_w();x++)
100 Color &color(out_surface[y][x]);
101 Imf::Rgba &rgba(in_surface[y][x]);
109 catch (const std::exception &e)
111 if(cb)cb->error(e.what());
112 else sinfg::error(e.what());