Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ImageLoader.cpp

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 // Includes 00012 #include "ImageLoader.h" 00013 #include <OpenCAL/Image.h> 00014 #include <OpenCAL/TGALoader.h> 00015 #include <OpenCAL/RAWLoader.h> 00016 using namespace OpenCAL::Utils; 00017 00018 using namespace std; 00019 00020 00021 /****************************** 00022 * Constructors and destructor * 00023 ******************************/ 00024 00025 ImageLoader::ImageLoader() 00026 { 00027 } 00028 00029 ImageLoader::~ImageLoader() 00030 { 00031 } 00032 00033 00034 /************************ 00035 * Get and set functions * 00036 ************************/ 00037 00038 00039 /****************** 00040 * Other functions * 00041 ******************/ 00042 00043 void ImageLoader::loadImage(Image *image, const string &filename) 00044 { 00045 int dotpos = filename.rfind("."); 00046 string ext = filename.substr(dotpos + 1); 00047 for(string::iterator it = ext.begin(); it != ext.end(); ++it) 00048 *it = tolower(*it); 00049 cout << "Filename extension: " << ext << endl; 00050 00051 if(ext == "tga") 00052 { 00053 cout << "Let's parse this TGA file (" << filename << ")" << endl; 00054 TGALoader::loadImage(image, filename); 00055 } 00056 else if(ext == "raw") 00057 { 00058 cout << "Let's parse this RAW file (" << filename << ")" << endl; 00059 RAWLoader::loadImage(image, filename); 00060 } 00061 else 00062 cerr << "I don't recognise the type of your image filename. I'm sorry..." << endl; 00063 00064 cout << "Done loading image (width " << image->getWidth(); 00065 cout << ", height " << image->getHeight() << ", depth " << image->getDepth() << ")" << endl; 00066 } 00067 00068 00069 /********************** 00070 * Protected functions * 00071 **********************/ 00072 00073 void ImageLoader::setImageWidth(Image *image, unsigned int width) 00074 { 00075 image->m_width = width; 00076 } 00077 00078 void ImageLoader::setImageHeight(Image *image, unsigned int height) 00079 { 00080 image->m_height = height; 00081 } 00082 00083 void ImageLoader::setImageDepth(Image *image, unsigned int depth) 00084 { 00085 image->m_depth = depth; 00086 } 00087 00088 void ImageLoader::setImageData(Image *image, unsigned char *data) 00089 { 00090 image->m_data = data; 00091 }

Generated on Sun Aug 15 19:19:22 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8