[Csp-commits] APPLICATIONS/TerrainToolSet/RAWExtract RAWExtract.dsp,NONE,1.1 RAWExtract.cpp,NONE,1.1
From: <sto...@us...> - 2003-01-01 20:54:41
|
Update of /cvsroot/csp/APPLICATIONS/TerrainToolSet/RAWExtract In directory sc8-pr-cvs1:/tmp/cvs-serv8139 Added Files: RAWExtract.dsp RAWExtract.cpp Log Message: no message --- NEW FILE: RAWExtract.dsp --- # Microsoft Developer Studio Project File - Name="RAWExtract" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** NICHT BEARBEITEN ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=RAWExtract - Win32 Debug !MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl !MESSAGE !MESSAGE NMAKE /f "RAWExtract.mak". !MESSAGE !MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: !MESSAGE !MESSAGE NMAKE /f "RAWExtract.mak" CFG="RAWExtract - Win32 Debug" !MESSAGE !MESSAGE Für die Konfiguration stehen zur Auswahl: !MESSAGE !MESSAGE "RAWExtract - Win32 Release" (basierend auf "Win32 (x86) Console Application") !MESSAGE "RAWExtract - Win32 Debug" (basierend auf "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "RAWExtract - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "RAWExtract - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "RAWExtract - Win32 Release" # Name "RAWExtract - Win32 Debug" # Begin Group "Quellcodedateien" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\RAWExtract.cpp # End Source File # End Group # Begin Group "Header-Dateien" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Ressourcendateien" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project --- NEW FILE: RAWExtract.cpp --- // Combat Simulator Project - RAWExtract - RAW Data Extraction Tool // Copyright (C) 2002 The Combat Simulator Project // http://csp.sourceforge.net // // 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. /** * This tool extracts a block of any size as a file of its * own from a larger RAW file. The resulting file can either be imported * Photoshop or any other image processing program, or converted to text * using RAW2txt. * * @author Martin "Stormbringer" Hoffmann <sto...@gm...> */ #include "stdio.h" #include "stdlib.h" #include "string.h" #include "io.h" #include "fcntl.h" #include "SYS\STAT.H" #include "math.h" short *aiHeightmap, *fract_map; int iWidth, iHeight; char cSourceFileName[256], cDestFileName[256], cPosX[256], cPosY[256], cStringBuffer[256], cSize[256]; long iSourceFileHandle, iDestFileHandle; int LoadTerrain(int iFile, int start_x, int start_y, int dest_width) { int success; long lsize; short *buffer; float fwidth; int iWidth, iHeight; // Load SCN data and save to internal structure lsize = _filelength(iFile); lsize /= 2; // SCN uses 16bit height values, so we have to divide by 2 // to get the real number of height map values fwidth = (float)sqrt((double)lsize); // compute terrain width from size of file iWidth = (int)fwidth; iHeight = (int)fwidth; aiHeightmap = new short[lsize]; buffer = new short[lsize]; fract_map = new short[dest_width*dest_width]; success = _read(iFile, buffer, (lsize*sizeof(short))); for (int y=start_y; y<start_y+dest_width; y++) for (int x=start_x; x<start_x+dest_width; x++) { fract_map[(y-start_y)*dest_width+x-start_x] = (short)buffer[y*iHeight+x]; } delete []buffer; return iWidth; } int SaveTerrain(int iDestFileHandle, int size) { int success; success = _write(iDestFileHandle, fract_map, size); _chmod(cDestFileName, _S_IREAD | _S_IWRITE); _close(iDestFileHandle); return 1; } int main(int argc, char* argv[]) { printf("CSP - RAW Data Extractor\n" "Copyright (C) 2002 The Combat Simulator Project\n" "http://csp.sourceforge.net\n\n"); if(argc < 5) { printf("ERROR: Not enough parameters!\n\n" "Usage: RAWExtract sourcefile destfile XPos YPos Size\n\n"); return -1; } // Source and Destination file names strcpy(cSourceFileName, argv[1]); strcpy(cDestFileName, argv[2]); strcpy(cPosX, argv[3]); strcpy(cPosY, argv[4]); strcpy(cSize, argv[5]); iSourceFileHandle = _open(cSourceFileName, _O_BINARY); if(iSourceFileHandle==-1) { printf("unable to open '%s'!\n", cSourceFileName); char text[100]; gets(text); return -1; } iDestFileHandle = _open(cDestFileName, _O_CREAT | _O_RDWR | _O_BINARY, _S_IREAD | _S_IWRITE); if(iDestFileHandle==-1) { printf("unable to open '%s'!\n", cDestFileName); char text[100]; gets(text); _close(iSourceFileHandle); return -1; } LoadTerrain(iSourceFileHandle, atoi(cPosX), atoi(cPosY), atoi(cSize)); SaveTerrain(iDestFileHandle, sizeof(short)*(atoi(cSize)*atoi(cSize))); _close(iSourceFileHandle); _close(iDestFileHandle); return 0; } |