diff --git a/modules/Gpx/surface.c b/modules/Gpx/surface.c index a8d4e79..1dbde3d 100644 --- a/modules/Gpx/surface.c +++ b/modules/Gpx/surface.c @@ -11,11 +11,9 @@ static surface_t *create(int width, int height, bool has_pixel, bool has_alpha) { surface_t *s = calloc(1, sizeof(surface_t)); - s->width = width; s->height = height; - s->depth = 24; - + if (has_pixel) { s->sdl_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_RGB888); } diff --git a/modules/lib/graph_blend_amap.c b/modules/lib/graph_blend_amap.c index 9f20be8..261fbc8 100644 --- a/modules/lib/graph_blend_amap.c +++ b/modules/lib/graph_blend_amap.c @@ -13,7 +13,7 @@ static void gre_BlendUseAMap(surface_t *dst, int dx, int dy, surface_t *src, int uint8_t *dp = GETOFFSET_PIXEL(dst, dx, dy); uint8_t *ap = GETOFFSET_ALPHA(src, sx, sy); - switch(dst->depth) { + switch (dst->sdl_surface->format->BitsPerPixel) { case 16: for (int y = 0; y < height; y++) { uint16_t *yls = (uint16_t *)(sp + y * src->sdl_surface->pitch); diff --git a/src/ags.h b/src/ags.h index 81a97d8..3d58eef 100644 --- a/src/ags.h +++ b/src/ags.h @@ -61,12 +61,11 @@ typedef enum { } ALPHA_DIB_COPY_TYPE; struct agsurface { - int width; /* width of surface */ - int height; /* height of surface */ - int depth; /* depth of surface, 8/16/24/32 is available */ + int width; + int height; - SDL_Surface *sdl_surface; /* pixel data (can be NULL) */ - uint8_t *alpha; /* alpha pixel data (can be NULL) */ + SDL_Surface *sdl_surface; // pixel data (can be NULL) + uint8_t *alpha; // alpha data (can be NULL) }; typedef struct agsurface surface_t; diff --git a/src/sdl_image.c b/src/sdl_image.c index 2d5f122..cef1882 100644 --- a/src/sdl_image.c +++ b/src/sdl_image.c @@ -110,7 +110,7 @@ void sdl_drawImage16(cgdata *cg, surface_t *sf, int dx, int dy, int brightness, *dst++ = rgb565_to_rgb888(*p_src++) | *a_src++ << 24; } } - } else if (sf->depth > 16) { + } else if (sf->sdl_surface->format->BitsPerPixel > 16) { // Convert to RGB888 by ourselves. SDL blit functions use a slightly // different mapping, so the color expanded by SDL may not match the // color key specified in the CX command. diff --git a/src/sdl_video.c b/src/sdl_video.c index fc7c502..bd12b38 100644 --- a/src/sdl_video.c +++ b/src/sdl_video.c @@ -191,13 +191,12 @@ static void makeDIB(int width, int height, int depth) { } sdl_dibinfo = calloc(1, sizeof(surface_t)); - sdl_dibinfo->depth = main_surface->format->BitsPerPixel; sdl_dibinfo->width = width; sdl_dibinfo->height = height; sdl_dibinfo->alpha = NULL; sdl_dibinfo->sdl_surface = main_surface; - image_setdepth(sdl_dibinfo->depth); + image_setdepth(main_surface->format->BitsPerPixel); } /* offscreen の設定 */