[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/video graphic.c
From: |
Nehal Mistry |
Subject: |
[Stratagus-CVS] stratagus/src/video graphic.c |
Date: |
Mon, 17 Nov 2003 17:49:35 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Nehal Mistry <address@hidden> 03/11/17 17:49:34
Modified files:
src/video : graphic.c
Log message:
implement ResizeGraphic
Patches:
Index: stratagus/src/video/graphic.c
diff -u stratagus/src/video/graphic.c:1.47 stratagus/src/video/graphic.c:1.48
--- stratagus/src/video/graphic.c:1.47 Mon Nov 17 14:14:46 2003
+++ stratagus/src/video/graphic.c Mon Nov 17 17:49:29 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: graphic.c,v 1.47 2003/11/17 19:14:46 nehalmistry Exp $
+// $Id: graphic.c,v 1.48 2003/11/17 22:49:29 nehalmistry Exp $
//@{
@@ -766,11 +766,10 @@
int x;
#ifdef USE_SDL_SURFACE
- return;
+ SDL_Color pal[256];
- int bps;
-
- bps = g->Surface->format->BytesPerPixel;
+ DebugCheck(g->Surface->format->BytesPerPixel != 1);
+ SDL_LockSurface(g->Surface);
#else
DebugCheck(g->Type != &GraphicImage8Type);
#endif
@@ -788,9 +787,8 @@
for (i = 0; i < h; ++i) {
for (j = 0; j < w; ++j) {
#ifdef USE_SDL_SURFACE
- memcpy(&data[x * g->Surface->format->BytesPerPixel],
- &((char*)g->Surface->pixels)[(i * g->Height / h) * g->Width *
bps
- + bps * j * g->Width / w], bps);
+ data[x] = ((unsigned char*)g->Surface->pixels)[
+ (i * g->Height / h) * g->Surface->pitch + j * g->Width / w];
#else
data[x] = ((unsigned char*)g->Frames)[
(i * g->Height / h) * g->Width + j * g->Width / w];
@@ -800,9 +798,13 @@
}
#ifdef USE_SDL_SURFACE
- // FIXME: todo
+ SDL_UnlockSurface(g->Surface);
+ memcpy(pal, g->Surface->format->palette->colors, sizeof(SDL_Color) * 256);
SDL_FreeSurface(g->Surface);
- g->Surface = SDL_CreateRGBSurfaceFrom(data, w, h, bps, w * bps, 0, 0, 0,
0);
+
+ g->Surface = SDL_CreateRGBSurfaceFrom(data, w, h, 8, w, 0, 0, 0, 0);
+ SDL_SetPalette(g->Surface, SDL_LOGPAL|SDL_PHYSPAL, pal, 0, 256);
+
g->Width = w;
g->Height = h;
#else
- [Stratagus-CVS] stratagus/src/video graphic.c,
Nehal Mistry <=