[Plib-cvs] plib/src/ssg pcx.h,NONE,1.1 ssgLoadPCX.cxx,NONE,1.1 Makefile.am,1.42,1.43 ssg.cxx,1.64,1.
Brought to you by:
sjbaker
From: Wolfram K. <wol...@us...> - 2003-12-12 17:23:54
|
Update of /cvsroot/plib/plib/src/ssg In directory sc8-pr-cvs1:/tmp/cvs-serv1075 Modified Files: Makefile.am ssg.cxx Added Files: pcx.h ssgLoadPCX.cxx Log Message: Loading of PCX textures --- NEW FILE: pcx.h --- // Loading of the PCX texture file format // // This file is used for both PLIB and for BoB. // // Written by Wolfram Kuss in december 2003 // // This file is published as public domain struct pcxHeaderType { char manufacturer; // always 10 char version; // usually 5 char encoding; // 1 = RLE char bitsPerPixel; // number of bits to represent a pixel short x, y; // upper left coordinates short xmax, ymax; short hDPI, vDPI; // DPI char egaPalette[48]; // obsolete char reserved; // unused, always 0 char nColorPlanes; // number of color planes. not implemented yet? short bytesPerLine; // bytes per scan line. not implemented yet? todo kludge short paletteInfo; // colored or grey scale. not implemented yet? short hScreenSize, cScreenSize; char padding[54]; // reserved, always 0 }; #define READ_BYTE (buffer[0]); buffer++; #define READ_SHORT ((((unsigned long)buffer[0])<<8) + buffer[1]); buffer += 2; #define READ_LONG ((((unsigned long)buffer[0])<<24) + (((unsigned long)buffer[1])<<16) + (((unsigned long)buffer[2])<<8) + buffer[3]); buffer += 4; // It is bad style to have a function inside a header file, but this way there is only one file // I need to "synchronise" between PLIB and BoB. static int ReadPCXBody(UByte*& buffer, pcxHeaderType *ppcxHeader, UByte * pBody) // returns TRUE on success. // reads from buffer (which will normally just hold the file contents, but in memory, // writes to pBody, which must have been allocated { unsigned short x,y; if ((ppcxHeader->bitsPerPixel != 8) // unsupported pcx || (ppcxHeader->encoding>1) // invalid PCX // || (pcxHeader.nColorPlanes != 1) // unsupported pcx || (ppcxHeader->manufacturer != 10)) // invalid pcx return (FALSE); unsigned short width = ppcxHeader->xmax-ppcxHeader->x+1; x=0; y=0; // upper left coordinates for(;;) { UByte color = READ_BYTE; if ((color &0xC0) != 0xC0) // uncompressed? { if (x >= width) { x=0; y++; // next line if(y > ppcxHeader->ymax-ppcxHeader->y) break; } *pBody++ = color; x++; } else { UByte counter, length = color & 0x3F; // number of times next byte repeated color = READ_BYTE; for (counter=0; counter<length; counter++) { if (x >= width) { x=0; y++; // next line if(y > ppcxHeader->ymax-ppcxHeader->y) break; } x++; *pBody++ = color; } if(y > ppcxHeader->ymax-ppcxHeader->y) break; } } return TRUE; } --- NEW FILE: ssgLoadPCX.cxx --- /* PLIB - A Suite of Portable Game Libraries Copyright (C) 2001 Steve Baker This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For further information visit http://plib.sourceforge.net [...90 lines suppressed...] texels[c++] = buffer[b*3 + 2]; texels[c++] = 255; //(b<index)?0:255; } } delete [] pBodyorig; delete [] bufferorig; return ssgMakeMipMaps ( texels, width, height, 4 ) ; } #else bool ssgLoadPCX ( const char *fname, ssgTextureInfo* info ) { ulSetError ( UL_WARNING, "ssgLoadTexture: '%s' - PCX texture support not configured", fname ) ; return false ; } #endif Index: Makefile.am =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/Makefile.am,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- Makefile.am 2 Aug 2003 18:36:55 -0000 1.42 +++ Makefile.am 12 Dec 2003 17:23:48 -0000 1.43 @@ -2,7 +2,7 @@ lib_LIBRARIES = libplibssg.a -include_HEADERS = ssg.h ssgconf.h ssgMSFSPalette.h ssgKeyFlier.h +include_HEADERS = ssg.h ssgconf.h ssgMSFSPalette.h ssgKeyFlier.h pcx.h libplibssg_a_SOURCES = ssg.cxx ssgAnimation.cxx ssgBase.cxx \ ssgBaseTransform.cxx ssgBranch.cxx ssgContext.cxx ssgCutout.cxx \ @@ -14,7 +14,7 @@ ssgTexTrans.cxx ssgTexture.cxx ssgTransform.cxx \ ssgStateSelector.cxx ssgRangeSelector.cxx ssgLoadTexture.cxx \ ssgLoadBMP.cxx ssgLoadSGI.cxx ssgLoadPNG.cxx ssgLoadTGA.cxx \ - ssgInvisible.cxx ssgLoadSSG.cxx ssgVTable.cxx \ + ssgLoadPCX.cxx ssgInvisible.cxx ssgLoadSSG.cxx ssgVTable.cxx \ ssgSimpleList.cxx ssgVtxTable.cxx ssgIO.cxx ssgLoad3ds.cxx \ ssgSaveASE.cxx ssgLoadASE.cxx ssgParser.cxx ssgParser.h \ ssgLoadDXF.cxx ssgSaveDXF.cxx ssgLoadTRI.cxx ssgSaveTRI.cxx \ Index: ssg.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssg.cxx,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- ssg.cxx 26 Jul 2003 09:50:41 -0000 1.64 +++ ssg.cxx 12 Dec 2003 17:23:51 -0000 1.65 @@ -163,6 +163,10 @@ ssgAddTextureFormat ( ".png" , ssgLoadPNG ) ; #endif +#ifdef SSG_LOAD_PCX_SUPPORTED + ssgAddTextureFormat ( ".pcx" , ssgLoadPCX ) ; +#endif + #ifdef SSG_LOAD_SGI_SUPPORTED ssgAddTextureFormat ( ".rgb" , ssgLoadSGI ) ; ssgAddTextureFormat ( ".rgba" , ssgLoadSGI ) ; |