From: <shu...@us...> - 2006-08-06 18:13:36
|
Revision: 83 Author: shutdownrunner Date: 2006-08-06 11:13:26 -0700 (Sun, 06 Aug 2006) ViewCVS: http://svn.sourceforge.net/dunelegacy/?rev=83&view=rev Log Message: ----------- - Set palette for cpsfiles Modified Paths: -------------- branches/dunks/src/pakfile/Cpsfile.cpp Modified: branches/dunks/src/pakfile/Cpsfile.cpp =================================================================== --- branches/dunks/src/pakfile/Cpsfile.cpp 2006-08-06 11:27:50 UTC (rev 82) +++ branches/dunks/src/pakfile/Cpsfile.cpp 2006-08-06 18:13:26 UTC (rev 83) @@ -1,4 +1,5 @@ #include "pakfile/Cpsfile.h" +#include "Application.h" #include <SDL_endian.h> #include <stdlib.h> #include <string.h> @@ -47,8 +48,11 @@ if((pic = SDL_CreateRGBSurface(SDL_SWSURFACE,SIZE_X,SIZE_Y,8,0,0,0,0))== NULL) { return NULL; } - - //SDL_SetColors(pic, palette->colors, 0, palette->ncolors); + + + SDL_Palette* palette = Application::Instance()->Screen()->format->palette; + SDL_SetColors(pic, palette->colors, 0, palette->ncolors); + SDL_LockSurface(pic); //Now we can copy line by line This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-04-25 22:20:21
|
Revision: 158 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=158&view=rev Author: dvalin Date: 2008-04-25 15:20:03 -0700 (Fri, 25 Apr 2008) Log Message: ----------- grf, be sure to free ImageOut (previously commented out and commited by accident) Modified Paths: -------------- branches/dunks/src/pakfile/Cpsfile.cpp Modified: branches/dunks/src/pakfile/Cpsfile.cpp =================================================================== --- branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-25 22:18:04 UTC (rev 157) +++ branches/dunks/src/pakfile/Cpsfile.cpp 2008-04-25 22:20:03 UTC (rev 158) @@ -62,9 +62,9 @@ SDL_UnlockSurface(pic); + free(ImageOut); + Image * img = new Image(pic); - -// free(ImageOut); return img; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-05-04 03:16:11
|
Revision: 262 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=262&view=rev Author: dvalin Date: 2008-05-03 20:16:07 -0700 (Sat, 03 May 2008) Log Message: ----------- fix handling of pictures with embedded palette (ie. VIRGIN.CPS) Modified Paths: -------------- branches/dunks/src/pakfile/Cpsfile.cpp Modified: branches/dunks/src/pakfile/Cpsfile.cpp =================================================================== --- branches/dunks/src/pakfile/Cpsfile.cpp 2008-05-03 23:28:32 UTC (rev 261) +++ branches/dunks/src/pakfile/Cpsfile.cpp 2008-05-04 03:16:07 UTC (rev 262) @@ -1,8 +1,8 @@ #include "pakfile/Cpsfile.h" #include <SDL_endian.h> #include "DataCache.h" -#include <stdlib.h> -#include <string.h> +#include <iostream> +#include <string> #define SIZE_X 320 #define SIZE_Y 240 @@ -11,10 +11,25 @@ { Filedata = bufFiledata; CpsFilesize = bufsize; - if (palette == NULL) - m_palette = DataCache::Instance()->getPalette(IBM_PAL); - else - m_palette = palette; + if(*(unsigned char *)(bufFiledata + 10 + 9) != 3){ + std::cout << "CPS has embedded palette, loading..." << std::endl; + m_palette = new SDL_Palette; + m_palette->ncolors = bufsize / 3; + m_palette->colors = new SDL_Color[m_palette->ncolors]; + + bufFiledata += 10; + for (int i = 0; i < m_palette->ncolors; i++){ + m_palette->colors[i].r = *bufFiledata++ <<2; + m_palette->colors[i].g = *bufFiledata++ <<2; + m_palette->colors[i].b = *bufFiledata++ <<2; + m_palette->colors[i].unused = 0; + } + }else{ + if (palette == NULL) + m_palette = DataCache::Instance()->getPalette(IBM_PAL); + else + m_palette = palette; + } } Cpsfile::~Cpsfile() @@ -43,15 +58,21 @@ } if(decode80(Filedata + 10 + PaletteSize,ImageOut,0) == -2) { - fprintf(stderr,"Error: Cannot decode Cps-File\n"); + std::cerr << "Error: Cannot decode Cps-File" << std::endl; } // create new picture surface if((pic = SDL_CreateRGBSurface(SDL_SWSURFACE,SIZE_X,SIZE_Y,8,0,0,0,0))== NULL) { return NULL; } - - + +/* for (int i = 0; i < 256; i++){ + m_palette->colors[i].r = *Filedata++ << 2; + m_palette->colors[i].g = *Filedata++ << 2; + m_palette->colors[i].b = *Filedata++ << 2; + m_palette->colors[i].reserved = 0; + } +*/ SDL_SetColors(pic, m_palette->colors, 0, m_palette->ncolors); SDL_LockSurface(pic); @@ -85,7 +106,7 @@ // create new picture surface if((returnPic = SDL_CreateRGBSurface(SDL_HWSURFACE,width,height,8,0,0,0,0))== NULL) { - fprintf(stderr,"GetSubPicture: Cannot create new Picture!\n"); + std::cerr << "GetSubPicture: Cannot create new Picture!" << std::endl; exit(EXIT_FAILURE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dv...@us...> - 2008-05-04 03:17:28
|
Revision: 263 http://dunelegacy.svn.sourceforge.net/dunelegacy/?rev=263&view=rev Author: dvalin Date: 2008-05-03 20:17:23 -0700 (Sat, 03 May 2008) Log Message: ----------- remove commented out test code Modified Paths: -------------- branches/dunks/src/pakfile/Cpsfile.cpp Modified: branches/dunks/src/pakfile/Cpsfile.cpp =================================================================== --- branches/dunks/src/pakfile/Cpsfile.cpp 2008-05-04 03:16:07 UTC (rev 262) +++ branches/dunks/src/pakfile/Cpsfile.cpp 2008-05-04 03:17:23 UTC (rev 263) @@ -66,13 +66,6 @@ return NULL; } -/* for (int i = 0; i < 256; i++){ - m_palette->colors[i].r = *Filedata++ << 2; - m_palette->colors[i].g = *Filedata++ << 2; - m_palette->colors[i].b = *Filedata++ << 2; - m_palette->colors[i].reserved = 0; - } -*/ SDL_SetColors(pic, m_palette->colors, 0, m_palette->ncolors); SDL_LockSurface(pic); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |