Add support for cmake to look for libpng and then add the proper files if available.

This commit is contained in:
Pavel Krajcevski 2012-08-26 20:31:41 -04:00
parent 6d39ab49c1
commit afd1e274fd
5 changed files with 33 additions and 4 deletions

View File

@ -8,6 +8,15 @@ SET( HEADERS
ImageFile.h
)
FIND_PACKAGE( PNG )
IF( PNG_FOUND )
INCLUDE_DIRECTORIES( ${PNG_INCLUDE_DIR} )
TARGET_LINK_LIBRARIES( ${PNG_LIBRARY} )
SET( SOURCES ${SOURCES} ImageLoaderPNG.cpp )
SET( HEADERS ${HEADERS} ImageLoaderPNG.h )
ENDIF()
CONFIGURE_FILE(
"ImageLoader.h.in"
"ImageLoader.h"

View File

@ -1,5 +1,9 @@
#include "ImageFile.h"
#include <string.h>
#include "ImageFile.h"
#ifdef PNG_FOUND
# include "ImageLoaderPNG.h"
#endif
ImageFile::ImageFile(const char *filename) :
m_PixelData(0),

View File

@ -43,4 +43,6 @@ class ImageLoader {
unsigned char * GetAlphaPixelData() const { return m_AlphaData; }
};
#cmakedefine PNG_FOUND
#endif // _IMAGE_LOADER_H_

14
IO/ImageLoaderPNG.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "ImageLoaderPNG.h"
#include <png.h>
ImageLoaderPNG::ImageLoaderPNG(const unsigned char *rawData)
: ImageLoader(rawData)
{
}
ImageLoaderPNG::~ImageLoaderPNG() {
}
void ImageLoaderPNG::ReadData() {
}

View File

@ -5,10 +5,10 @@
class ImageLoaderPNG : public ImageLoader {
public:
ImageLoader(const unsigned char *rawData);
virtual ~ImageLoader();
ImageLoaderPNG(const unsigned char *rawData);
virtual ~ImageLoaderPNG();
void ReadData();
virtual void ReadData();
};
#endif // _IMAGE_LOADER_H_