00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00023
00024
00025 TGALoader::TGALoader()
00026 {
00027 }
00028
00029 TGALoader::~TGALoader()
00030 {
00031 }
00032
00033
00034
00035
00036
00037
00038
00039
00040
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
00064
00065
00066
00067
00068
00069
00070
00071 tga->Release();
00072 }
00073
00074
00075
00076
00077