root/OpenSceneGraph/trunk/src/osgPlugins/jp2/ReaderWriterJP2.cpp @ 12597

Revision 12597, 16.8 kB (checked in by robert, 3 years ago)

Resolved warnings reported by g++ 4.6's -Wunused-but-set-variable.

Warnings were:

/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osg/ShapeDrawable.cpp: In member function ‘void PrimitiveShapeVisitor::createHalfSphere(unsigned int, unsigned int, float, int, float, const Matrix&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osg/ShapeDrawable.cpp:1409:11: warning: variable ‘nzBase’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osg/ShapeDrawable.cpp:1410:11: warning: variable ‘nRatioBase’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp: In function ‘osgUtil::Triangle_list osgUtil::fillHole(osg::Vec3Array*, std::vector<unsigned int, std::allocator<unsigned int> >)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp:569:27: warning: variable ‘ptest’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp: In member function ‘bool osgUtil::DelaunayTriangulator::triangulate()’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/DelaunayTriangulator.cpp:979:45: warning: variable ‘curp’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/RenderStage.cpp: In member function ‘void osgUtil::RenderStage::runCameraSetUp(osg::RenderInfo?&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgUtil/RenderStage.cpp:631:18: warning: variable ‘stencilAttached’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/FadeText.cpp: In member function ‘void FadeTextPolytopeData::buildPolytope()’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/FadeText.cpp:74:20: warning: variable ‘edge23’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/FadeText.cpp:75:20: warning: variable ‘edge30’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/Text.cpp: In member function ‘void osgText::Text::computeBackdropPositions(unsigned int) const’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgText/Text.cpp:747:10: warning: variable ‘is_valid_size’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/NodeTrackerManipulator.cpp: In member function ‘virtual bool osgGA::NodeTrackerManipulator::performMovementLeftMouseButton(double, double, double)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/NodeTrackerManipulator.cpp:257:21: warning: variable ‘lookVector’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/NodeTrackerManipulator.cpp:259:21: warning: variable ‘upVector’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/TerrainManipulator.cpp: In member function ‘virtual bool osgGA::TerrainManipulator::performMovementMiddleMouseButton(double, double, double)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/TerrainManipulator.cpp:217:11: warning: variable ‘lookVector’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgGA/TerrainManipulator.cpp:219:11: warning: variable ‘upVector’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgVolume/FixedFunctionTechnique.cpp: In member function ‘virtual void osgVolume::FixedFunctionTechnique::init()’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgVolume/FixedFunctionTechnique.cpp:124:30: warning: variable ‘tf’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgParticle/FluidProgram.cpp: In member function ‘virtual void osgParticle::FluidProgram::execute(double)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgParticle/FluidProgram.cpp:38:23: warning: variable ‘velBefore’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgShadow/ParallelSplitShadowMap.cpp: In member function ‘virtual void osgShadow::ParallelSplitShadowMap::cull(osgUtil::CullVisitor?&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgShadow/ParallelSplitShadowMap.cpp:593:22: warning: variable ‘bb’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgTerrain/GeometryTechnique.cpp: In member function ‘virtual void osgTerrain::GeometryTechnique::generateGeometry(osgTerrain::GeometryTechnique::BufferData?&, osgTerrain::Locator*, const osg::Vec3d&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgTerrain/GeometryTechnique.cpp:777:12: warning: variable ‘i_sampleFactor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgTerrain/GeometryTechnique.cpp:778:12: warning: variable ‘j_sampleFactor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp: In function ‘osg::Image* ReadDDSFile(std::istream&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp:314:10: warning: variable ‘is3dImage’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp: In function ‘bool WriteDDSFile(const osg::Image*, std::ostream&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/dds/ReaderWriterDDS.cpp:721:10: warning: variable ‘is3dImage’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/hdr/hdrloader.cpp: In static member function ‘static bool HDRLoader::load(const char*, bool, HDRLoaderResult&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/hdr/hdrloader.cpp:101:10: warning: variable ‘cmd’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/vtf/ReaderWriterVTF.cpp: In function ‘osg::Image* ReadVTFFile(std::istream&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/vtf/ReaderWriterVTF.cpp:360:23: warning: variable ‘base’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/jp2/ReaderWriterJP2.cpp: In function ‘int putdata(jas_stream_t*, jas_image_t*, int)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/jp2/ReaderWriterJP2.cpp:41:13: warning: variable ‘linelen’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertToInventor.cpp: In member function ‘void ConvertToInventor::processGeometry(const osg::Geometry*, ConvertToInventor::InventorState?*)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertToInventor.cpp:1639:10: warning: variable ‘ok’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertFromInventor.cpp: In member function ‘virtual SbBool? SoVRMLImageTextureOsg::readInstance(SoInput?*, short unsigned int)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/Inventor/ConvertFromInventor.cpp:1264:16: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp: In member function ‘virtual void flt::Face::readRecord(flt::RecordInputStream?&, flt::Document&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp:369:19: warning: variable ‘secondaryPackedColor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp: In member function ‘virtual void flt::Mesh::readRecord(flt::RecordInputStream?&, flt::Document&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/GeometryRecords.cpp:942:19: warning: variable ‘secondaryPackedColor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp: In member function ‘virtual osgDB::ReaderWriter::ReadResult? FLTReaderWriter::readNode(std::istream&, const Options*) const’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp:427:40: warning: variable ‘pos’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ive/ShapeAttributeList.cpp: In member function ‘void ive::ShapeAttributeList::write(ive::DataOutputStream?*)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ive/ShapeAttributeList.cpp:31:48: warning: variable ‘it’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp: In member function ‘void ac3d::Geode::ProcessGeometry?(std::ostream&, unsigned int)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:806:35: warning: variable ‘fRep_s’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:806:43: warning: variable ‘fRep_t’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:807:35: warning: variable ‘fOffset_s’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:807:46: warning: variable ‘fOffset_t’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/ac/Geode.cpp:932:38: warning: variable ‘primLength’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_geom.cpp: In member function ‘virtual bool trpgGeometry::Write(trpgWriteBuffer&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_geom.cpp:615:19: warning: variable ‘u’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_material.cpp: In member function ‘int trpgMatTable::AddMaterial?(const trpgMaterial&, bool)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_material.cpp:103:10: warning: variable ‘spaceInTable’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_rarchive.cpp: In member function ‘virtual bool trpgr_Archive::ReadHeader?(bool)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/txp/trpage_rarchive.cpp:261:14: warning: variable ‘headerHasTexTable’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp: In member function ‘ZRESULT TUnzip::Get(int, ZIPENTRY*)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp:4055:8: warning: variable ‘hidden’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp:4055:22: warning: variable ‘system’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/unzip.cpp:4055:36: warning: variable ‘archive’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/ZipArchive.cpp: In member function ‘virtual bool ZipArchive::getFileNames(osgDB::Archive::FileNameList?&) const’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/zip/ZipArchive.cpp:91:37: warning: variable ‘iterEnd’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/pvr/ReaderWriterPVR.cpp: In member function ‘osgDB::ReaderWriter::ReadResult? ReaderWriterPVR::readPVRStream(std::istream&) const’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/pvr/ReaderWriterPVR.cpp:155:14: warning: variable ‘hasAlpha’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp: In function ‘osg::Geometry* create3DSphericalDisplayDistortionMesh(const Vec3&, const Vec3&, const Vec3&, double, double, osg::Image*, const Matrix&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp:737:15: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp: In function ‘osg::Geometry* createParoramicSphericalDisplayDistortionMesh(const Vec3&, const Vec3&, const Vec3&, double, double, osg::Image*, const Matrix&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp:1130:19: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/View.cpp:1118:15: warning: variable ‘dx’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/GraphicsWindowX11.cpp: In member function ‘virtual void osgViewer::GraphicsWindowX11::checkEvents()’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgViewer/GraphicsWindowX11.cpp:1181:10: warning: variable ‘destroyWindowRequested’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/cfg/ConfigParser.cpp: In member function ‘bool osgProducer::CameraConfig::parseFile(const string&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/cfg/ConfigParser.cpp:2247:13: warning: variable ‘result’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgQt/QGraphicsViewAdapter.cpp: In member function ‘bool osgQt::QGraphicsViewAdapter::handlePointerEvent(int, int, int)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgQt/QGraphicsViewAdapter.cpp:344:17: warning: variable ‘viewportGeometry’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp: In function ‘osg::Node* createDistortionSubgraph(osg::Node*, const Vec4&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp:125:19: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp:126:19: warning: variable ‘texcoord’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp: In function ‘osg::Geometry* createDomeDistortionMesh(const Vec3&, const Vec3&, const Vec3&, osg::ArgumentParser?&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgdistortion/osgdistortion.cpp:358:15: warning: variable ‘cursor’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgposter/osgposter.cpp: In function ‘int main(int, char**)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgposter/osgposter.cpp:253:31: warning: variable ‘outputTiles’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgthreadedterrain/osgthreadedterrain.cpp: In function ‘int main(int, char**)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgthreadedterrain/osgthreadedterrain.cpp:669:10: warning: variable ‘readParameter’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgtext3D/TextNode.cpp: In member function ‘virtual void osgText::Layout::layout(osgText::TextNode?&) const’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgtext3D/TextNode.cpp:80:11: warning: variable ‘characterHeightScale’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgvolume/osgvolume.cpp: In function ‘int main(int, char**)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgvolume/osgvolume.cpp:678:38: warning: variable ‘internalFormatMode’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp: In function ‘bool windowMouseOver(osgWidget::Event&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp:27:24: warning: variable ‘xy’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp: In function ‘bool widgetMouseOver(osgWidget::Event&)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/examples/osgwidgetcanvas/osgwidgetcanvas.cpp:35:24: warning: variable ‘xy’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/p3d/ReaderWriterP3D.cpp: In member function ‘osg::Node* ReaderWriterP3DXML::parseXmlGraph(osgDB::XmlNode?*, bool, osgDB::Options*) const’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/src/osgPlugins/p3d/ReaderWriterP3D.cpp:2121:10: warning: variable ‘readSlide’ set but not used [-Wunused-but-set-variable]
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/applications/present3D/present3D.cpp: In function ‘int main(int, char**)’:
/home/stephan/Dev/LibSources/OpenSceneGraph-3.0.0-rc2/applications/present3D/present3D.cpp:639:10: warning: variable ‘sizesSpecified’ set but not used [-Wunused-but-set-variable]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#include <osg/Image>
2#include <osg/Notify>
3
4#include <osg/Geode>
5
6#include <osg/GL>
7
8#include <osgDB/FileNameUtils>
9#include <osgDB/FileUtils>
10#include <osgDB/Registry>
11
12#include <string>
13#include <sstream>
14#include <vector>
15#include <stdio.h>
16#include <stdlib.h>
17
18extern "C"
19{
20    #include <jasper/jasper.h>
21}
22
23#ifndef SEEK_SET
24define SEEK_SET 0
25#endif
26
27using namespace osg;
28
29
30extern "C" {
31
32    static int putdata(jas_stream_t *out, jas_image_t *image, int numcmpts)
33    {
34        int ret;
35        int cmptno;
36        int x;
37        int y;
38        jas_matrix_t *data[4];
39        jas_seqent_t *d[4];
40        jas_seqent_t v;
41        int width, height;
42
43        width = jas_image_cmptwidth(image, 0);
44        height = jas_image_cmptheight(image, 0);
45
46        ret = -1;
47
48        data[0] = 0;
49        data[1] = 0;
50        data[2] = 0;
51        data[3] = 0;
52        for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
53            if (!(data[cmptno] = jas_matrix_create(1, width))) {
54                goto done;
55            }
56        }
57
58        for (y = height - 1; y >= 0; --y) {
59            for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
60                if (jas_image_readcmpt(image, cmptno, 0, y, width, 1,
61                  data[cmptno])) {
62                    goto done;
63                }
64                d[cmptno] = jas_matrix_getref(data[cmptno], 0, 0);
65            }
66            for (x = 0; x < width; ++x) {
67                for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
68                    v = *d[cmptno];
69                    if (v < 0) {
70                        v = 0;
71                    }
72                    if (v > 255) {
73                        v = 255;
74                    }
75                    unsigned char c;
76                    c = v;
77                    if (jas_stream_putc(out, c) == EOF) {
78                        goto done;
79                    }
80                    ++d[cmptno];
81                }
82            }
83            if (jas_stream_error(out)) {
84                goto done;
85            }
86        }
87
88        jas_stream_flush(out);
89        ret = 0;
90
91    done:
92
93        for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
94            if (data[cmptno]) {
95                jas_matrix_destroy(data[cmptno]);
96            }
97        }
98
99        return ret;
100    }
101
102    static int getdata(jas_stream_t *in, jas_image_t *image)
103    {
104        int ret;
105        int numcmpts;
106        int cmptno;
107        jas_matrix_t *data[4];
108        int x;
109        int y;
110        int width, height;
111
112        width = jas_image_cmptwidth(image, 0);
113        height = jas_image_cmptheight(image, 0);
114        numcmpts = jas_image_numcmpts(image);
115
116        ret = -1;
117
118        data[0] = 0;
119        data[1] = 0;
120        data[2] = 0;
121        data[3] = 0;
122        for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
123            if (!(data[cmptno] = jas_matrix_create(1, width))) {
124                goto done;
125            }
126        }
127
128        for (y = height - 1; y >= 0; --y)
129//        for (y = 0; y < height; ++y)
130        {
131            for (x = 0; x < width; ++x)
132            {
133                for (cmptno = 0; cmptno < numcmpts; ++cmptno)
134                {
135                    /* The sample data is unsigned. */
136                    int c;
137                    if ((c = jas_stream_getc(in)) == EOF) {
138                        return -1;
139                    }
140                    jas_matrix_set(data[cmptno], 0, x, c);
141                }
142            }
143            for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
144                if (jas_image_writecmpt(image, cmptno, 0, y, width, 1,
145                  data[cmptno])) {
146                    goto done;
147                }
148            }
149        }
150
151        jas_stream_flush(in);
152
153        ret = 0;
154
155    done:
156
157        for (cmptno = 0; cmptno < numcmpts; ++cmptno) {
158            if (data[cmptno]) {
159                jas_matrix_destroy(data[cmptno]);
160            }
161        }
162
163        return ret;
164    }
165
166}
167
168class ReaderWriterJP2 : public osgDB::ReaderWriter
169{
170    public:
171
172
173        ReaderWriterJP2()
174        {
175            supportsExtension("jp2","Jpeg2000 image format");
176            supportsExtension("jpc","Jpeg2000 image format");
177
178            jas_init();
179
180            // little dance here to get around warnings created by jas_image_strtofmt use of char* rather than const char*
181            // as a parameted and modern compilers deprecating "jp2" string being treated as char*.
182            char* jp2 = strdup("jp2");
183            _fmt_jp2 = jas_image_strtofmt(jp2);
184            free(jp2);
185        }
186
187        ~ReaderWriterJP2()
188        {
189            jas_cleanup();
190        }
191
192        virtual const char* className() const { return "RGB Image Reader/Writer"; }
193
194        virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
195        {
196            return readImage(file,options);
197        }
198
199        virtual ReadResult readObject(std::istream& fin, const Options* options) const
200        {
201            return readImage(fin,options);
202        }
203
204
205        virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const
206        {
207            std::string ext = osgDB::getFileExtension(file);
208            if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
209
210            std::string fileName = osgDB::findDataFile( file, options );
211            if(fileName.empty())
212            {
213                // note from Robert, Dec03, I find returning a valid image when no
214                // file exists a bit odd...
215                osg::Image *img = new osg::Image;
216                img->setFileName(fileName);
217                return img;
218            }
219
220            jas_stream_t* in = jas_stream_fopen(fileName.c_str(), "rb");
221
222            char* opt = 0;
223            if(options)
224            {
225                opt = new char[options->getOptionString().size() + 1];
226                strcpy(opt, options->getOptionString().c_str());
227            }
228            jas_image_t* jimage = jas_image_decode(in, -1, opt); // last is the option string whatto put there?
229            if(opt) delete[] opt;
230
231            int internalFormat = jimage->numcmpts_;
232
233            int s = jas_image_width(jimage);
234            int t = jas_image_height(jimage);
235            int r = 1;
236
237            unsigned char* data = new unsigned char[internalFormat*s*t];
238
239            jas_stream_t* mem = jas_stream_memopen((char*)data, internalFormat*s*t);
240
241            putdata(mem, jimage, internalFormat);
242
243            jas_image_destroy(jimage);
244            jas_stream_close(in);
245
246            unsigned int pixelFormat =
247                internalFormat == 1 ? GL_LUMINANCE :
248                internalFormat == 2 ? GL_LUMINANCE_ALPHA :
249                internalFormat == 3 ? GL_RGB :
250                internalFormat == 4 ? GL_RGBA : (GLenum)-1;
251
252            unsigned int dataType = GL_UNSIGNED_BYTE;
253
254            Image* image = new Image();
255            image->setFileName(fileName.c_str());
256            image->setImage(s,t,r,
257                internalFormat,
258                pixelFormat,
259                dataType,
260                data,
261//                osg::Image::USE_NEW_DELETE);
262                osg::Image::NO_DELETE);
263
264            OSG_INFO << "image read ok "<<s<<"  "<<t<< std::endl;
265            return image;
266
267        }
268
269        virtual ReadResult readImage(std::istream& fin,const Options* options) const
270        {
271            char c;
272            char * sdata;
273            long ssize;
274            std::vector<char> vdata;
275
276            while(!fin.eof())
277            {
278                fin.read(&c, 1);
279                vdata.push_back(c);
280            }
281            ssize = vdata.size();
282
283            sdata = &vdata[0];
284
285            jas_stream_t* in = jas_stream_memopen((char*)sdata, ssize);
286
287            char* opt = 0;
288            if(options && !options->getOptionString().empty())
289            {
290                opt = new char[options->getOptionString().size() + 1];
291                strcpy(opt, options->getOptionString().c_str());
292            }
293            jas_image_t* jimage = jas_image_decode(in, -1, opt); // last is the option string whatto put there?
294            if(opt) delete[] opt;
295           
296            if (!jimage) return ReadResult::FILE_NOT_HANDLED;
297
298            int internalFormat = jimage->numcmpts_;
299
300            int s = jas_image_width(jimage);
301            int t = jas_image_height(jimage);
302            int r = 1;
303
304            unsigned char* data = new unsigned char[internalFormat*s*t];
305
306            jas_stream_t* mem = jas_stream_memopen((char*)data, internalFormat*s*t);
307
308            putdata(mem, jimage, internalFormat);
309
310            jas_image_destroy(jimage);
311            jas_stream_close(in);
312
313            unsigned int pixelFormat =
314                internalFormat == 1 ? GL_LUMINANCE :
315                internalFormat == 2 ? GL_LUMINANCE_ALPHA :
316                internalFormat == 3 ? GL_RGB :
317                internalFormat == 4 ? GL_RGBA : (GLenum)-1;
318
319            unsigned int dataType = GL_UNSIGNED_BYTE;
320
321            Image* image = new Image();
322//            image->setFileName(fileName.c_str());
323            image->setImage(s,t,r,
324                internalFormat,
325                pixelFormat,
326                dataType,
327                data,
328//                osg::Image::USE_NEW_DELETE);
329                osg::Image::NO_DELETE);
330
331            OSG_INFO << "image read ok "<<s<<"  "<<t<< std::endl;
332            return image;
333        }
334
335        virtual WriteResult writeObject(const osg::Object& object,const std::string& file, const osgDB::ReaderWriter::Options* options) const
336        {
337            const osg::Image* image = dynamic_cast<const osg::Image*>(&object);
338            if (!image) return WriteResult::FILE_NOT_HANDLED;
339
340            return writeImage(*image,file,options);
341        }
342
343        virtual WriteResult writeObject(const osg::Object& object,std::ostream& fout,const Options* options) const
344        {
345            const osg::Image* image = dynamic_cast<const osg::Image*>(&object);
346            if (!image) return WriteResult::FILE_NOT_HANDLED;
347
348            return writeImage(*image,fout,options);
349        }
350
351        virtual WriteResult writeImage(const osg::Image &img,const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
352        {
353            std::string ext = osgDB::getFileExtension(fileName);
354            if (!acceptsExtension(ext)) return WriteResult::FILE_NOT_HANDLED;
355
356            jas_image_cmptparm_t cmptparms[4];
357            jas_image_cmptparm_t *cmptparm;
358
359            int internalFormat = osg::Image::computeNumComponents(img.getPixelFormat());
360
361            jas_stream_t* mem = jas_stream_memopen((char*)img.data(), internalFormat*img.s()*img.t());
362
363            /* Create an image of the correct size. */
364            jas_image_t* jimage;
365            int i;
366            for (i = 0, cmptparm = cmptparms; i < internalFormat; ++i, ++cmptparm) {
367                cmptparm->tlx = 0;
368                cmptparm->tly = 0;
369                cmptparm->hstep = 1;
370                cmptparm->vstep = 1;
371                cmptparm->width = img.s();
372                cmptparm->height = img.t();
373                cmptparm->prec = 8;
374                cmptparm->sgnd = 0;
375            }
376            if (!(jimage = jas_image_create(internalFormat, cmptparms, JAS_CLRSPC_UNKNOWN))) {
377                return WriteResult::ERROR_IN_WRITING_FILE;
378            }
379
380            if(internalFormat == 1)
381            {
382                jas_image_setclrspc(jimage, JAS_CLRSPC_GENGRAY);
383                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y));
384            }
385            else if(internalFormat == 2)
386            {
387                jas_image_setclrspc(jimage, JAS_CLRSPC_GENGRAY);
388                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y));
389                jas_image_setcmpttype(jimage, 1, JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_OPACITY));
390            }
391            else if(internalFormat == 3)
392            {
393                jas_image_setclrspc(jimage, JAS_CLRSPC_SRGB);
394                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R));
395                jas_image_setcmpttype(jimage, 1, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G));
396                jas_image_setcmpttype(jimage, 2, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B));
397            }
398            else if(internalFormat == 4)
399            {
400                jas_image_setclrspc(jimage, JAS_CLRSPC_SRGB);
401                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R));
402                jas_image_setcmpttype(jimage, 1, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G));
403                jas_image_setcmpttype(jimage, 2, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B));
404                jas_image_setcmpttype(jimage, 3, JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_OPACITY));
405            }
406
407            getdata(mem, jimage);
408
409            jas_stream_t* out = jas_stream_fopen(fileName.c_str(), "wb");
410            if (!out)
411                return WriteResult::ERROR_IN_WRITING_FILE;
412
413            char* opt = 0;
414            if(options)
415            {
416                opt = new char[options->getOptionString().size() + 1];
417                strcpy(opt, options->getOptionString().c_str());
418            }
419            jas_image_encode(jimage, out, _fmt_jp2,  opt);
420            if(opt) delete[] opt;
421
422            jas_stream_flush(out);
423
424            jas_stream_close(out);
425            jas_image_destroy(jimage);
426
427            return WriteResult::FILE_SAVED;
428        }
429
430        WriteResult writeImage(const osg::Image& img, std::ostream& fout, const Options* options) const
431        {
432            jas_image_cmptparm_t cmptparms[4];
433            jas_image_cmptparm_t *cmptparm;
434
435            int internalFormat = osg::Image::computeNumComponents(img.getPixelFormat());
436
437            jas_stream_t* mem = jas_stream_memopen((char*)img.data(), internalFormat*img.s()*img.t());
438
439            /* Create an image of the correct size. */
440            jas_image_t* jimage;
441            int i;
442            for (i = 0, cmptparm = cmptparms; i < internalFormat; ++i, ++cmptparm) {
443                cmptparm->tlx = 0;
444                cmptparm->tly = 0;
445                cmptparm->hstep = 1;
446                cmptparm->vstep = 1;
447                cmptparm->width = img.s();
448                cmptparm->height = img.t();
449                cmptparm->prec = 8;
450                cmptparm->sgnd = 0;
451            }
452            if (!(jimage = jas_image_create(internalFormat, cmptparms, JAS_CLRSPC_UNKNOWN))) {
453                return WriteResult::ERROR_IN_WRITING_FILE;
454            }
455
456            if(internalFormat == 1)
457            {
458                jas_image_setclrspc(jimage, JAS_CLRSPC_SGRAY);
459                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y));
460            }
461            else if(internalFormat == 2)
462            {
463                jas_image_setclrspc(jimage, JAS_CLRSPC_SGRAY);
464                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y));
465                jas_image_setcmpttype(jimage, 1, JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_OPACITY));
466            }
467            else if(internalFormat == 3)
468            {
469                jas_image_setclrspc(jimage, JAS_CLRSPC_SRGB);
470                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R));
471                jas_image_setcmpttype(jimage, 1, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G));
472                jas_image_setcmpttype(jimage, 2, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B));
473            }
474            else if(internalFormat == 4)
475            {
476                jas_image_setclrspc(jimage, JAS_CLRSPC_SRGB);
477                jas_image_setcmpttype(jimage, 0, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R));
478                jas_image_setcmpttype(jimage, 1, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G));
479                jas_image_setcmpttype(jimage, 2, JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B));
480                jas_image_setcmpttype(jimage, 3, JAS_IMAGE_CT_COLOR(JAS_IMAGE_CT_OPACITY));
481            }
482
483            getdata(mem, jimage);
484
485            jas_stream_t* out = jas_stream_memopen(0, 0);
486//            jas_stream_t* out = jas_stream_fopen(fileName.c_str(), "wb");
487            if (!out)
488                return WriteResult::ERROR_IN_WRITING_FILE;
489
490            char* opt = 0;
491            if(options)
492            {
493                opt = new char[options->getOptionString().size() + 1];
494                strcpy(opt, options->getOptionString().c_str());
495            }
496
497            jas_image_encode(jimage, out, _fmt_jp2,  opt);
498            if(opt) delete[] opt;
499
500            jas_stream_flush(out);
501
502            // now the encoded jp2 image resides in the out->buf_ member with size out->len_ we now need to stream it to a std::ostream
503            jas_stream_memobj_t* obj = (jas_stream_memobj_t*) out->obj_;
504
505            fout.write((char*)obj->buf_, obj->len_);
506
507            fout << std::flush;
508
509            jas_stream_close(out);
510
511            jas_image_destroy(jimage);
512
513            return WriteResult::FILE_SAVED;
514        }
515
516
517        int _fmt_jp2;
518};
519
520// now register with Registry to instantiate the above
521// reader/writer.
522REGISTER_OSGPLUGIN(jp2, ReaderWriterJP2)
Note: See TracBrowser for help on using the browser.