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

TGALoader.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 "TGALoader.h" 00013 #include <OpenCAL/Image.h> 00014 using namespace OpenCAL::Utils; 00015 00016 #include "tga.h" 00017 00018 using namespace std; 00019 00020 00021 /****************************** 00022 * Constructors and destructor * 00023 ******************************/ 00024 00025 TGALoader::TGALoader() 00026 { 00027 } 00028 00029 TGALoader::~TGALoader() 00030 { 00031 } 00032 00033 00034 /************************ 00035 * Get and set functions * 00036 ************************/ 00037 00038 00039 /****************** 00040 * Other functions * 00041 ******************/ 00042 00043 void TGALoader::loadImage(Image *image, const string &filename) 00044 { 00045 CTga *tga = new CTga(); 00046 if(tga->ReadFile(filename.c_str()) == 0) 00047 { 00048 cerr << "The file couldn't be read." << endl; 00049 tga->Release(); 00050 return; 00051 } 00052 00053 image->resize(tga->GetSizeX(), tga->GetSizeY(), tga->Bpp() / 8); 00054 unsigned int w = image->getWidth(); 00055 unsigned int h = image->getHeight(); 00056 unsigned int d = image->getDepth(); 00057 unsigned char *data = image->getData(); 00058 00059 00060 memcpy(data, tga->GetPointer(), w * h * d); 00061 00062 /* 00063 //Flip image 00064 for(unsigned int y = 0; y < h; ++y) 00065 { 00066 memcpy(&data[y * w * d], 00067 &(tga->GetPointer()) [(h - y - 1) * w * d], w * d); 00068 } 00069 */ 00070 00071 tga->Release(); 00072 } 00073 00074 00075 /********************** 00076 * Protected functions * 00077 **********************/

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