Recovered from microbel
This commit is contained in:
99
common/lib/texture/texturemap.C
Normal file
99
common/lib/texture/texturemap.C
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <iostream.h>
|
||||
#include "texture.H"
|
||||
#include "exception.H"
|
||||
|
||||
CTextureMap::CTextureMap(){
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_data = NULL;
|
||||
}
|
||||
|
||||
CTextureMap::CTextureMap(WORD width, WORD height, BYTE * data){
|
||||
setMap(width,height,data);
|
||||
}
|
||||
|
||||
CTextureMap::~CTextureMap(){
|
||||
if (m_data != NULL) free(m_data);
|
||||
}
|
||||
|
||||
|
||||
WORD CTextureMap::getWidth(){
|
||||
return m_width;
|
||||
}
|
||||
|
||||
WORD CTextureMap::getHeight(){
|
||||
return m_height;
|
||||
}
|
||||
|
||||
BYTE * CTextureMap::getData(){
|
||||
return m_data;
|
||||
}
|
||||
|
||||
void CTextureMap::setMap(WORD width, WORD height, BYTE * data){
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_data = (BYTE*)malloc(m_width*m_height*sizeof(DWORD));
|
||||
memcpy(m_data,data,m_width*m_height*sizeof(DWORD));
|
||||
}
|
||||
|
||||
void CTextureMap::load(char * fileName){
|
||||
char * sufix;
|
||||
|
||||
if (m_data != NULL) free(m_data);
|
||||
m_width = m_height = 0;
|
||||
m_data = NULL;
|
||||
|
||||
sufix = strrchr(fileName,'.');
|
||||
|
||||
if ( (strncmp(sufix,".tif",4)==0) || (strncmp(sufix,".TIF",4)==0) ){
|
||||
loadTIFF(fileName);
|
||||
} else if ( (strcmp(sufix,".rgb")==0) || (strcmp(sufix,".RGB")==0) ){
|
||||
loadRGB(fileName);
|
||||
} else if ( (strcmp(sufix,".tex")==0) || (strcmp(sufix,".TEX")==0) ){
|
||||
loadTEX(fileName);
|
||||
} else {
|
||||
cdebug << "Failed!";
|
||||
throw new CException();
|
||||
}
|
||||
}
|
||||
|
||||
void CTextureMap::save(char * fileName){
|
||||
char * sufix;
|
||||
|
||||
sufix = strrchr(fileName,'.');
|
||||
|
||||
if ( (strncmp(sufix,".tif",4)==0) || (strncmp(sufix,".TIF",4)==0) ){
|
||||
saveTIFF(fileName);
|
||||
} else /* if ( (strcmp(sufix,".rgb")==0) || (strcmp(sufix,".RGB")==0) ){
|
||||
saveRGB(fileName);
|
||||
} else */ if ( (strcmp(sufix,".tex")==0) || (strcmp(sufix,".TEX")==0) ){
|
||||
saveTEX(fileName);
|
||||
} else {
|
||||
cdebug << "Failed!";
|
||||
throw new CException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user