Remove PPM support
This commit is contained in:
parent
f22cf2a05e
commit
0856204b80
@ -105,7 +105,6 @@ source/Irrlicht/CColorConverter.cpp
|
||||
source/Irrlicht/CMeshCache.cpp
|
||||
source/Irrlicht/CIrrDeviceFB.cpp
|
||||
source/Irrlicht/CMemoryFile.cpp
|
||||
source/Irrlicht/CImageWriterPPM.cpp
|
||||
source/Irrlicht/CMountPointReader.cpp
|
||||
source/Irrlicht/CBillboardSceneNode.cpp
|
||||
source/Irrlicht/CGUIImageList.cpp
|
||||
@ -137,7 +136,6 @@ source/Irrlicht/COpenGLExtensionHandler.cpp
|
||||
source/Irrlicht/CImageLoaderWAL.cpp
|
||||
source/Irrlicht/CXMLWriter.cpp
|
||||
source/Irrlicht/CSceneNodeAnimatorCameraFPS.cpp
|
||||
source/Irrlicht/CImageLoaderPPM.cpp
|
||||
source/Irrlicht/CGUIColorSelectDialog.cpp
|
||||
source/Irrlicht/CSceneManager.cpp
|
||||
source/Irrlicht/Irrlicht.cpp
|
||||
@ -174,7 +172,6 @@ source/Irrlicht/CIrrDeviceLinux.h
|
||||
source/Irrlicht/CMeshCache.h
|
||||
source/Irrlicht/CAttributes.h
|
||||
source/Irrlicht/CParticleMeshEmitter.h
|
||||
source/Irrlicht/CImageWriterPPM.h
|
||||
source/Irrlicht/CParticlePointEmitter.h
|
||||
source/Irrlicht/CParticleRotationAffector.h
|
||||
source/Irrlicht/CMountPointReader.h
|
||||
@ -269,7 +266,6 @@ source/Irrlicht/CTriangleSelector.h
|
||||
source/Irrlicht/CParticleGravityAffector.h
|
||||
source/Irrlicht/CGUIModalScreen.h
|
||||
source/Irrlicht/CDefaultSceneNodeFactory.h
|
||||
source/Irrlicht/CImageLoaderPPM.h
|
||||
source/Irrlicht/CXMLReaderImpl.h
|
||||
source/Irrlicht/COpenGLMaterialRenderer.h
|
||||
source/Irrlicht/CVideoModeList.h
|
||||
|
@ -289,11 +289,6 @@ B3D, MS3D or X meshes */
|
||||
#ifdef NO_IRR_COMPILE_WITH_PNG_LOADER_
|
||||
#undef _IRR_COMPILE_WITH_PNG_LOADER_
|
||||
#endif
|
||||
//! Define _IRR_COMPILE_WITH_PPM_LOADER_ if you want to load .ppm/.pgm/.pbm files
|
||||
//#define _IRR_COMPILE_WITH_PPM_LOADER_
|
||||
#ifdef NO_IRR_COMPILE_WITH_PPM_LOADER_
|
||||
#undef _IRR_COMPILE_WITH_PPM_LOADER_
|
||||
#endif
|
||||
//! Define _IRR_COMPILE_WITH_PSD_LOADER_ if you want to load .psd files
|
||||
//#define _IRR_COMPILE_WITH_PSD_LOADER_
|
||||
#ifdef NO_IRR_COMPILE_WITH_PSD_LOADER_
|
||||
@ -350,11 +345,6 @@ B3D, MS3D or X meshes */
|
||||
#ifdef NO_IRR_COMPILE_WITH_PNG_WRITER_
|
||||
#undef _IRR_COMPILE_WITH_PNG_WRITER_
|
||||
#endif
|
||||
//! Define _IRR_COMPILE_WITH_PPM_WRITER_ if you want to write .ppm files
|
||||
//#define _IRR_COMPILE_WITH_PPM_WRITER_
|
||||
#ifdef NO_IRR_COMPILE_WITH_PPM_WRITER_
|
||||
#undef _IRR_COMPILE_WITH_PPM_WRITER_
|
||||
#endif
|
||||
//! Define _IRR_COMPILE_WITH_PSD_WRITER_ if you want to write .psd files
|
||||
//#define _IRR_COMPILE_WITH_PSD_WRITER_
|
||||
#ifdef NO_IRR_COMPILE_WITH_PSD_WRITER_
|
||||
|
@ -1,277 +0,0 @@
|
||||
// Copyright (C) 2007-2012 Christian Stehno
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CImageLoaderPPM.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_PPM_LOADER_
|
||||
|
||||
#include "IReadFile.h"
|
||||
#include "CColorConverter.h"
|
||||
#include "CImage.h"
|
||||
#include "os.h"
|
||||
#include "fast_atof.h"
|
||||
#include "coreutil.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
|
||||
//! constructor
|
||||
CImageLoaderPPM::CImageLoaderPPM()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CImageLoaderPPM");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (e.g. ".tga")
|
||||
bool CImageLoaderPPM::isALoadableFileExtension(const io::path& filename) const
|
||||
{
|
||||
return core::hasFileExtension ( filename, "ppm", "pgm", "pbm" );
|
||||
}
|
||||
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
bool CImageLoaderPPM::isALoadableFileFormat(io::IReadFile* file) const
|
||||
{
|
||||
c8 id[2]={0};
|
||||
file->read(&id, 2);
|
||||
return (id[0]=='P' && id[1]>'0' && id[1]<'7');
|
||||
}
|
||||
|
||||
|
||||
//! creates a surface from the file
|
||||
IImage* CImageLoaderPPM::loadImage(io::IReadFile* file) const
|
||||
{
|
||||
IImage* image;
|
||||
|
||||
if (file->getSize() < 12)
|
||||
return 0;
|
||||
|
||||
c8 id[2];
|
||||
file->read(&id, 2);
|
||||
|
||||
if (id[0]!='P' || id[1]<'1' || id[1]>'6')
|
||||
return 0;
|
||||
|
||||
const u8 format = id[1] - '0';
|
||||
const bool binary = format>3;
|
||||
|
||||
core::stringc token;
|
||||
getNextToken(file, token);
|
||||
const u32 width = core::strtoul10(token.c_str());
|
||||
|
||||
getNextToken(file, token);
|
||||
const u32 height = core::strtoul10(token.c_str());
|
||||
|
||||
u8* data = 0;
|
||||
const u32 size = width*height;
|
||||
if (format==1 || format==4)
|
||||
{
|
||||
skipToNextToken(file); // go to start of data
|
||||
|
||||
const u32 bytesize = size/8+(size & 3)?1:0;
|
||||
if (binary)
|
||||
{
|
||||
if (file->getSize()-file->getPos() < (long)bytesize)
|
||||
return 0;
|
||||
data = new u8[bytesize];
|
||||
file->read(data, bytesize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file->getSize()-file->getPos() < (long)(2*size)) // optimistic test
|
||||
return 0;
|
||||
data = new u8[bytesize];
|
||||
memset(data, 0, bytesize);
|
||||
u32 shift=0;
|
||||
for (u32 i=0; i<size; ++i)
|
||||
{
|
||||
getNextToken(file, token);
|
||||
if (token == "1")
|
||||
data[i/8] |= (0x01 << shift);
|
||||
if (++shift == 8)
|
||||
shift=0;
|
||||
}
|
||||
}
|
||||
image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(width, height));
|
||||
if (image)
|
||||
CColorConverter::convert1BitTo16Bit(data, (s16*)image->lock(), width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
getNextToken(file, token);
|
||||
const u32 maxDepth = core::strtoul10(token.c_str());
|
||||
if (maxDepth > 255) // no double bytes yet
|
||||
return 0;
|
||||
|
||||
skipToNextToken(file); // go to start of data
|
||||
|
||||
if (format==2 || format==5)
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
if (file->getSize()-file->getPos() < (long)size)
|
||||
return 0;
|
||||
data = new u8[size];
|
||||
file->read(data, size);
|
||||
image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height));
|
||||
if (image)
|
||||
{
|
||||
u8* ptr = (u8*)image->lock();
|
||||
for (u32 i=0; i<size; ++i)
|
||||
{
|
||||
*ptr++ = data[i];
|
||||
*ptr++ = data[i];
|
||||
*ptr++ = data[i];
|
||||
*ptr++ = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file->getSize()-file->getPos() < (long)(2*size)) // optimistic test
|
||||
return 0;
|
||||
image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height));
|
||||
if (image)
|
||||
{
|
||||
u8* ptr = (u8*)image->lock();
|
||||
for (u32 i=0; i<size; ++i)
|
||||
{
|
||||
getNextToken(file, token);
|
||||
const u8 num = (u8)core::strtoul10(token.c_str());
|
||||
*ptr++ = num;
|
||||
*ptr++ = num;
|
||||
*ptr++ = num;
|
||||
*ptr++ = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const u32 bytesize = 3*size;
|
||||
if (binary)
|
||||
{
|
||||
if (file->getSize()-file->getPos() < (long)bytesize)
|
||||
return 0;
|
||||
data = new u8[bytesize];
|
||||
file->read(data, bytesize);
|
||||
image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height));
|
||||
if (image)
|
||||
{
|
||||
u8* ptr = (u8*)image->lock();
|
||||
for (u32 i=0; i<size; ++i)
|
||||
{
|
||||
*ptr++ = data[3*i];
|
||||
*ptr++ = data[3*i+1];
|
||||
*ptr++ = data[3*i+2];
|
||||
*ptr++ = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (file->getSize()-file->getPos() < (long)(2*bytesize)) // optimistic test
|
||||
return 0;
|
||||
image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height));
|
||||
if (image)
|
||||
{
|
||||
u8* ptr = (u8*)image->lock();
|
||||
for (u32 i=0; i<size; ++i)
|
||||
{
|
||||
getNextToken(file, token);
|
||||
*ptr++ = (u8)core::strtoul10(token.c_str());
|
||||
getNextToken(file, token);
|
||||
*ptr++ = (u8)core::strtoul10(token.c_str());
|
||||
getNextToken(file, token);
|
||||
*ptr++ = (u8)core::strtoul10(token.c_str());
|
||||
*ptr++ = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (image)
|
||||
image->unlock();
|
||||
|
||||
delete [] data;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
//! read the next token from file
|
||||
void CImageLoaderPPM::getNextToken(io::IReadFile* file, core::stringc& token) const
|
||||
{
|
||||
token = "";
|
||||
c8 c;
|
||||
while(file->getPos()<file->getSize())
|
||||
{
|
||||
file->read(&c, 1);
|
||||
if (c=='#')
|
||||
{
|
||||
while (c!='\n' && c!='\r' && (file->getPos()<file->getSize()))
|
||||
file->read(&c, 1);
|
||||
}
|
||||
else if (!core::isspace(c))
|
||||
{
|
||||
token.append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(file->getPos()<file->getSize())
|
||||
{
|
||||
file->read(&c, 1);
|
||||
if (c=='#')
|
||||
{
|
||||
while (c!='\n' && c!='\r' && (file->getPos()<file->getSize()))
|
||||
file->read(&c, 1);
|
||||
}
|
||||
else if (!core::isspace(c))
|
||||
token.append(c);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! skip to next token (skip whitespace)
|
||||
void CImageLoaderPPM::skipToNextToken(io::IReadFile* file) const
|
||||
{
|
||||
c8 c;
|
||||
while(file->getPos()<file->getSize())
|
||||
{
|
||||
file->read(&c, 1);
|
||||
if (c=='#')
|
||||
{
|
||||
while (c!='\n' && c!='\r' && (file->getPos()<file->getSize()))
|
||||
file->read(&c, 1);
|
||||
}
|
||||
else if (!core::isspace(c))
|
||||
{
|
||||
file->seek(-1, true); // put back
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! creates a loader which is able to load windows bitmaps
|
||||
IImageLoader* createImageLoaderPPM()
|
||||
{
|
||||
return new CImageLoaderPPM;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -1,55 +0,0 @@
|
||||
// Copyright (C) 2007-2012 Christian Stehno
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __C_IMAGE_LOADER_PPM_H_INCLUDED__
|
||||
#define __C_IMAGE_LOADER_PPM_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_PPM_LOADER_
|
||||
|
||||
#include "IImageLoader.h"
|
||||
#include "irrString.h"
|
||||
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
Surface Loader for SUN Pixmaps
|
||||
*/
|
||||
class CImageLoaderPPM : public IImageLoader
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
CImageLoaderPPM();
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
//! based on the file extension (e.g. ".tga")
|
||||
virtual bool isALoadableFileExtension(const io::path& filename) const;
|
||||
|
||||
//! returns true if the file maybe is able to be loaded by this class
|
||||
virtual bool isALoadableFileFormat(io::IReadFile* file) const;
|
||||
|
||||
//! creates a surface from the file
|
||||
virtual IImage* loadImage(io::IReadFile* file) const;
|
||||
|
||||
private:
|
||||
//! read the next token from file
|
||||
void getNextToken(io::IReadFile* file, core::stringc& token) const;
|
||||
//! skip to next token (skip whitespace)
|
||||
void skipToNextToken(io::IReadFile* file) const;
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,105 +0,0 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "CImageWriterPPM.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_PPM_WRITER_
|
||||
|
||||
#include "IWriteFile.h"
|
||||
#include "IImage.h"
|
||||
#include "dimension2d.h"
|
||||
#include "irrString.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
|
||||
IImageWriter* createImageWriterPPM()
|
||||
{
|
||||
return new CImageWriterPPM;
|
||||
}
|
||||
|
||||
|
||||
CImageWriterPPM::CImageWriterPPM()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CImageWriterPPM");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool CImageWriterPPM::isAWriteableFileExtension(const io::path& filename) const
|
||||
{
|
||||
return core::hasFileExtension ( filename, "ppm" );
|
||||
}
|
||||
|
||||
|
||||
bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image, u32 param) const
|
||||
{
|
||||
char cache[70];
|
||||
int size;
|
||||
|
||||
const core::dimension2d<u32>& imageSize = image->getDimension();
|
||||
|
||||
const bool binary = false;
|
||||
|
||||
if (binary)
|
||||
size = snprintf(cache, 70, "P6\n");
|
||||
else
|
||||
size = snprintf(cache, 70, "P3\n");
|
||||
|
||||
if (file->write(cache, size) != size)
|
||||
return false;
|
||||
|
||||
size = snprintf(cache, 70, "%d %d\n", imageSize.Width, imageSize.Height);
|
||||
if (file->write(cache, size) != size)
|
||||
return false;
|
||||
|
||||
size = snprintf(cache, 70, "255\n");
|
||||
if (file->write(cache, size) != size)
|
||||
return false;
|
||||
|
||||
if (binary)
|
||||
{
|
||||
for (u32 h = 0; h < imageSize.Height; ++h)
|
||||
{
|
||||
for (u32 c = 0; c < imageSize.Width; ++c)
|
||||
{
|
||||
const video::SColor& pixel = image->getPixel(c, h);
|
||||
const u8 r = (u8)(pixel.getRed() & 0xff);
|
||||
const u8 g = (u8)(pixel.getGreen() & 0xff);
|
||||
const u8 b = (u8)(pixel.getBlue() & 0xff);
|
||||
file->write(&r, 1);
|
||||
file->write(&g, 1);
|
||||
file->write(&b, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s32 n = 0;
|
||||
|
||||
for (u32 h = 0; h < imageSize.Height; ++h)
|
||||
{
|
||||
for (u32 c = 0; c < imageSize.Width; ++c, ++n)
|
||||
{
|
||||
const video::SColor& pixel = image->getPixel(c, h);
|
||||
size = snprintf(cache, 70, "%.3u %.3u %.3u%s", pixel.getRed(), pixel.getGreen(), pixel.getBlue(), n % 5 == 4 ? "\n" : " ");
|
||||
if (file->write(cache, size) != size)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace video
|
||||
} // namespace irr
|
||||
|
||||
#endif
|
||||
|
@ -1,37 +0,0 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef _C_IMAGE_WRITER_PPM_H_INCLUDED__
|
||||
#define _C_IMAGE_WRITER_PPM_H_INCLUDED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_PPM_WRITER_
|
||||
|
||||
#include "IImageWriter.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace video
|
||||
{
|
||||
|
||||
class CImageWriterPPM : public IImageWriter
|
||||
{
|
||||
public:
|
||||
//! constructor
|
||||
CImageWriterPPM();
|
||||
|
||||
//! return true if this writer can write a file with the given extension
|
||||
virtual bool isAWriteableFileExtension(const io::path& filename) const;
|
||||
|
||||
//! write image to file
|
||||
virtual bool writeImage(io::IWriteFile *file, IImage *image, u32 param) const;
|
||||
};
|
||||
|
||||
} // namespace video
|
||||
} // namespace irr
|
||||
|
||||
#endif // _C_IMAGE_WRITER_PPM_H_INCLUDED__
|
||||
#endif
|
||||
|
@ -130,9 +130,6 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
|
||||
#ifdef _IRR_COMPILE_WITH_LMP_LOADER_
|
||||
SurfaceLoader.push_back(video::createImageLoaderLMP());
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_PPM_LOADER_
|
||||
SurfaceLoader.push_back(video::createImageLoaderPPM());
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_RGB_LOADER_
|
||||
SurfaceLoader.push_back(video::createImageLoaderRGB());
|
||||
#endif
|
||||
@ -157,11 +154,6 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
|
||||
#ifdef _IRR_COMPILE_WITH_BMP_LOADER_
|
||||
SurfaceLoader.push_back(video::createImageLoaderBMP());
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_PPM_WRITER_
|
||||
SurfaceWriter.push_back(video::createImageWriterPPM());
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_PCX_WRITER_
|
||||
SurfaceWriter.push_back(video::createImageWriterPCX());
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user