From Igor Kravtchenko, new HDR plugin.
This commit is contained in:
parent
5215d43e14
commit
d706e9e795
@ -36,12 +36,15 @@ WRAPPER_DIRS = \
|
||||
# Directories traversed in the TOPDIR/src/osgPlugins directory
|
||||
|
||||
PLUGIN_DIRS = \
|
||||
3dc\
|
||||
ac3d\
|
||||
bmp\
|
||||
directx\
|
||||
dds\
|
||||
directx\
|
||||
dw\
|
||||
flt\
|
||||
hdr\
|
||||
ive\
|
||||
lib3ds\
|
||||
logo\
|
||||
lwo\
|
||||
@ -49,26 +52,24 @@ PLUGIN_DIRS = \
|
||||
md2\
|
||||
net\
|
||||
obj\
|
||||
osgParticle\
|
||||
osgText\
|
||||
osgSim\
|
||||
osgFX\
|
||||
osg\
|
||||
osga\
|
||||
osgFX\
|
||||
osgParticle\
|
||||
osgSim\
|
||||
osgText\
|
||||
osgtgz\
|
||||
pic\
|
||||
pnm\
|
||||
rgb\
|
||||
tga\
|
||||
tgz\
|
||||
txp\
|
||||
zip\
|
||||
3dc\
|
||||
ive\
|
||||
rot\
|
||||
scale\
|
||||
stl\
|
||||
tga\
|
||||
tgz\
|
||||
trans\
|
||||
txp\
|
||||
zip\
|
||||
|
||||
|
||||
ifeq ($(GDAL_INSTALLED),yes)
|
||||
|
@ -2484,6 +2484,27 @@ Package=<4>
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin hdr"=.\osgPlugins\hdr\hdr.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osg
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgDB
|
||||
End Project Dependency
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name Core osgUtil
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "osgPlugin stl"=.\osgPlugins\stl\stl.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
119
VisualStudio/osgPlugins/hdr/hdr.dsp
Normal file
119
VisualStudio/osgPlugins/hdr/hdr.dsp
Normal file
@ -0,0 +1,119 @@
|
||||
# Microsoft Developer Studio Project File - Name="osgPlugin hdr" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=osgPlugin hdr - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "hdr.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "hdr.mak" CFG="osgPlugin hdr - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "osgPlugin hdr - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "osgPlugin hdr - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "osgPlugin hdr - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "../../../lib"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 OpenThreadsWin32.lib /nologo /dll /pdb:none /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_hdr.dll" /libpath:"../../../lib" /libpath:"../../../../OpenThreads/lib/win32" /libpath:"../../../../Producer/lib" /libpath:"../../../../3rdParty/lib"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "osgPlugin hdr - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "../../../lib"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /vmg /vd0 /GR /GX /Zi /Od /I "../../../include" /I "../../../../OpenThreads/include" /I "../../../../Producer/include" /I "../../../../3rdParty/include" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WIN32" /D "_DEBUG" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 OpenThreadsWin32d.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"LIBC" /out:"../../../bin/osgdb_hdrd.dll" /pdbtype:sept /libpath:"../../../lib" /libpath:"../../../../OpenThreads/lib/win32" /libpath:"../../../../Producer/lib" /libpath:"../../../../3rdParty/lib"
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "osgPlugin hdr - Win32 Release"
|
||||
# Name "osgPlugin hdr - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\hdr\hdrloader.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\osgPlugins\hdr\ReaderWriterHDR.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Src\osgPlugins\hdr\hdrloader.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
14
src/osgPlugins/hdr/GNUmakefile
Normal file
14
src/osgPlugins/hdr/GNUmakefile
Normal file
@ -0,0 +1,14 @@
|
||||
TOPDIR = ../../..
|
||||
include $(TOPDIR)/Make/makedefs
|
||||
|
||||
CXXFILES =\
|
||||
hdrloader.cpp\
|
||||
ReaderWriterHDR.cpp\
|
||||
|
||||
LIBS += $(OSG_LIBS) $(OTHER_LIBS)
|
||||
|
||||
TARGET_BASENAME = hdr
|
||||
include $(TOPDIR)/Make/cygwin_plugin_def
|
||||
PLUGIN = $(PLUGIN_PREFIX)$(TARGET_BASENAME).$(PLUGIN_EXT)
|
||||
|
||||
include $(TOPDIR)/Make/makerules
|
112
src/osgPlugins/hdr/ReaderWriterHDR.cpp
Normal file
112
src/osgPlugins/hdr/ReaderWriterHDR.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2004 Mekensleep
|
||||
*
|
||||
* Mekensleep
|
||||
* 24 rue vieille du temple
|
||||
* 75004 Paris
|
||||
* licensing@mekensleep.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author:
|
||||
* Igor Kravtchenko <igor@obraz.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <osg/Image>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Geode>
|
||||
#include <osg/GL>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "hdrloader.h"
|
||||
|
||||
class ReaderWriterHDR : public osgDB::ReaderWriter
|
||||
{
|
||||
public:
|
||||
virtual const char* className() { return "HDR Image Reader"; }
|
||||
virtual bool acceptsExtension(const std::string &extension) { return osgDB::equalCaseInsensitive(extension, "hdr"); }
|
||||
|
||||
virtual ReadResult readImage(const std::string &_file, const osgDB::ReaderWriter::Options *_opts) const
|
||||
{
|
||||
if (!HDRLoader::isHDRFile(_file.c_str()))
|
||||
return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
float mul = 1.0f;
|
||||
bool bYFlip = false;
|
||||
if(_opts) {
|
||||
std::istringstream iss(_opts->getOptionString());
|
||||
std::string opt;
|
||||
while (iss >> opt) {
|
||||
if(opt == "RGBMUL") {
|
||||
iss >> mul;
|
||||
}
|
||||
else if(opt == "YFLIP") {
|
||||
bYFlip = true; // TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HDRLoaderResult res;
|
||||
bool ret = HDRLoader::load(_file.c_str(), res);
|
||||
if (!ret)
|
||||
return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
int nbPixs = res.width * res.height;
|
||||
int nbElements = nbPixs * 3;
|
||||
unsigned char *rgb = new unsigned char[ nbElements ];
|
||||
unsigned char *tt = rgb;
|
||||
float *cols = res.cols;
|
||||
|
||||
for (int i = 0; i < nbElements; i++) {
|
||||
float element = *cols++;
|
||||
element *= mul;
|
||||
if (element < 0) element = 0;
|
||||
else if (element > 1) element = 1;
|
||||
int intElement = (int) (element * 255.0f);
|
||||
*tt++ = intElement;
|
||||
}
|
||||
|
||||
delete [] res.cols;
|
||||
|
||||
int pixelFormat = GL_RGB;
|
||||
int dataType = GL_UNSIGNED_BYTE;
|
||||
|
||||
osg::Image *img = new osg::Image;
|
||||
img->setFileName(_file.c_str());
|
||||
img->setImage( res.width, res.height, 1,
|
||||
3,
|
||||
pixelFormat,
|
||||
dataType,
|
||||
(unsigned char*) rgb,
|
||||
osg::Image::USE_NEW_DELETE);
|
||||
|
||||
return img;
|
||||
}
|
||||
};
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriterHDR> g_readerWriter_HDR_Proxy;
|
233
src/osgPlugins/hdr/hdrloader.cpp
Normal file
233
src/osgPlugins/hdr/hdrloader.cpp
Normal file
@ -0,0 +1,233 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2004 Mekensleep
|
||||
*
|
||||
* Mekensleep
|
||||
* 24 rue vieille du temple
|
||||
* 75004 Paris
|
||||
* licensing@mekensleep.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author:
|
||||
* Igor Kravtchenko <igor@obraz.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hdrloader.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef unsigned char RGBE[4];
|
||||
#define R 0
|
||||
#define G 1
|
||||
#define B 2
|
||||
#define E 3
|
||||
|
||||
#define MINELEN 8 // minimum scanline length for encoding
|
||||
#define MAXELEN 0x7fff // maximum scanline length for encoding
|
||||
|
||||
static void workOnRGBE(RGBE *scan, int len, float *cols);
|
||||
static bool decrunch(RGBE *scanline, int len, FILE *file);
|
||||
static bool oldDecrunch(RGBE *scanline, int len, FILE *file);
|
||||
|
||||
bool HDRLoader::isHDRFile(const char *_fileName)
|
||||
{
|
||||
FILE *file;
|
||||
file = fopen(_fileName, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
char str[10];
|
||||
fread(str, 10, 1, file);
|
||||
fclose(file);
|
||||
|
||||
if (memcmp(str, "#?RADIANCE", 10) && memcmp(str, "#?RGBE", 6))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HDRLoader::load(const char *_fileName, HDRLoaderResult &_res)
|
||||
{
|
||||
int i;
|
||||
char str[200];
|
||||
FILE *file;
|
||||
|
||||
file = fopen(_fileName, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
fread(str, 10, 1, file);
|
||||
if (memcmp(str, "#?RADIANCE", 10)) {
|
||||
fseek(file, 0, SEEK_SET);
|
||||
fread(str, 6, 1, file);
|
||||
if (memcmp(str, "#?RGBE", 6)) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
fseek(file, 1, SEEK_CUR);
|
||||
|
||||
char cmd[2000];
|
||||
i = 0;
|
||||
char c = 0, oldc;
|
||||
while(true) {
|
||||
oldc = c;
|
||||
c = fgetc(file);
|
||||
if (c == 0xa && oldc == 0xa)
|
||||
break;
|
||||
cmd[i++] = c;
|
||||
}
|
||||
|
||||
char reso[2000];
|
||||
i = 0;
|
||||
while(true) {
|
||||
c = fgetc(file);
|
||||
reso[i++] = c;
|
||||
if (c == 0xa)
|
||||
break;
|
||||
}
|
||||
|
||||
int w, h;
|
||||
if (!sscanf(reso, "-Y %ld +X %ld", &h, &w)) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
|
||||
_res.width = w;
|
||||
_res.height = h;
|
||||
|
||||
float *cols = new float[w * h * 3];
|
||||
_res.cols = cols;
|
||||
|
||||
RGBE *scanline = new RGBE[w];
|
||||
if (!scanline) {
|
||||
fclose(file);
|
||||
return false;
|
||||
}
|
||||
|
||||
// convert image
|
||||
cols += (h-1) * w * 3;
|
||||
for (int y = h - 1; y >= 0; y--) {
|
||||
if (decrunch(scanline, w, file) == false)
|
||||
break;
|
||||
workOnRGBE(scanline, w, cols);
|
||||
cols -= w * 3;
|
||||
}
|
||||
|
||||
delete [] scanline;
|
||||
fclose(file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float convertComponent(int _expo, int _val)
|
||||
{
|
||||
float v = _val / 256.0f;
|
||||
float d = powf(2, _expo);
|
||||
return v * d;
|
||||
}
|
||||
|
||||
void workOnRGBE(RGBE *_scan, int _len, float *_cols)
|
||||
{
|
||||
int ii = 0;
|
||||
while (_len-- > 0) {
|
||||
int expo = _scan[0][E] - 128;
|
||||
_cols[0] = convertComponent(expo, _scan[0][R]);
|
||||
_cols[1] = convertComponent(expo, _scan[0][G]);
|
||||
_cols[2] = convertComponent(expo, _scan[0][B]);
|
||||
_cols += 3;
|
||||
_scan++;
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
|
||||
bool decrunch(RGBE *_scanline, int _len, FILE *_file)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (_len < MINELEN || _len > MAXELEN)
|
||||
return oldDecrunch(_scanline, _len, _file);
|
||||
|
||||
i = fgetc(_file);
|
||||
if (i != 2) {
|
||||
fseek(_file, -1, SEEK_CUR);
|
||||
return oldDecrunch(_scanline, _len, _file);
|
||||
}
|
||||
|
||||
_scanline[0][G] = fgetc(_file);
|
||||
_scanline[0][B] = fgetc(_file);
|
||||
i = fgetc(_file);
|
||||
|
||||
if (_scanline[0][G] != 2 || _scanline[0][B] & 128) {
|
||||
_scanline[0][R] = 2;
|
||||
_scanline[0][E] = i;
|
||||
return oldDecrunch(_scanline + 1, _len - 1, _file);
|
||||
}
|
||||
|
||||
// read each component
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < _len; ) {
|
||||
unsigned char code = fgetc(_file);
|
||||
if (code > 128) { // run
|
||||
code &= 127;
|
||||
unsigned char val = fgetc(_file);
|
||||
while (code--)
|
||||
_scanline[j++][i] = val;
|
||||
}
|
||||
else { // non-run
|
||||
while(code--)
|
||||
_scanline[j++][i] = fgetc(_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return feof(_file) ? false : true;
|
||||
}
|
||||
|
||||
bool oldDecrunch(RGBE *_scanline, int _len, FILE *_file)
|
||||
{
|
||||
int i;
|
||||
int rshift = 0;
|
||||
|
||||
while (_len > 0) {
|
||||
_scanline[0][R] = fgetc(_file);
|
||||
_scanline[0][G] = fgetc(_file);
|
||||
_scanline[0][B] = fgetc(_file);
|
||||
_scanline[0][E] = fgetc(_file);
|
||||
if (feof(_file))
|
||||
return false;
|
||||
|
||||
if (_scanline[0][R] == 1 &&
|
||||
_scanline[0][G] == 1 &&
|
||||
_scanline[0][B] == 1) {
|
||||
for (i = _scanline[0][E] << rshift; i > 0; i--) {
|
||||
memcpy(&_scanline[0][0], &_scanline[-1][0], 4);
|
||||
_scanline++;
|
||||
_len--;
|
||||
}
|
||||
rshift += 8;
|
||||
}
|
||||
else {
|
||||
_scanline++;
|
||||
_len--;
|
||||
rshift = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
50
src/osgPlugins/hdr/hdrloader.h
Normal file
50
src/osgPlugins/hdr/hdrloader.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2004 Mekensleep
|
||||
*
|
||||
* Mekensleep
|
||||
* 24 rue vieille du temple
|
||||
* 75004 Paris
|
||||
* licensing@mekensleep.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author:
|
||||
* Igor Kravtchenko <igor@obraz.net>
|
||||
*
|
||||
* Description:
|
||||
* Class to load a HDR file
|
||||
* An HDR file is an image file where each pixel is stored as float values in opposite
|
||||
* of traditional other formats (BMP, TGA, etc.) where integerer values are used.
|
||||
* see http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-HDRImageReader&forum=cotd&id=-1 for more informations
|
||||
*/
|
||||
|
||||
#ifndef HDRLOADER_H
|
||||
#define HDRLOADER_H
|
||||
|
||||
class HDRLoaderResult {
|
||||
public:
|
||||
int width, height;
|
||||
// each pixel takes 3 float32, each component can be of any value...
|
||||
float *cols; // this is to be freed using free() and not delete[]
|
||||
};
|
||||
|
||||
class HDRLoader {
|
||||
public:
|
||||
static bool isHDRFile(const char *fileName);
|
||||
static bool load(const char *fileName, HDRLoaderResult &res);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user