Fix alpha channel for icons.
Tweak the convert-icon script to include the alpha channel value as well as RGB. Fix i_video and the setup code to set the icon including the alpha channel. While we're at it, replace the current PNG icons with 128x128 high quality versions so that they look nice on retina display Macs.
This commit is contained in:
parent
10b75388bc
commit
076c8400e6
10 changed files with 5495 additions and 595 deletions
|
|
@ -29,7 +29,7 @@ except ImportError:
|
|||
|
||||
def convert_image(filename, output_filename):
|
||||
|
||||
im = Image.open(filename).convert("RGB")
|
||||
im = Image.open(filename)
|
||||
|
||||
outfile = open(output_filename, "w")
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ def convert_image(filename, output_filename):
|
|||
outfile.write("static int %s_h = %i;\n" % (struct_name, size[1]))
|
||||
|
||||
outfile.write("\n")
|
||||
outfile.write("static unsigned char %s_data[] = {\n" % (struct_name))
|
||||
outfile.write("static const unsigned int %s_data[] = {\n" % (struct_name))
|
||||
|
||||
elements_on_line = 0
|
||||
|
||||
|
|
@ -52,10 +52,10 @@ def convert_image(filename, output_filename):
|
|||
for y in range(size[1]):
|
||||
for x in range(size[0]):
|
||||
val = im.getpixel((x, y))
|
||||
outfile.write("0x%02x,0x%02x,0x%02x, " % val)
|
||||
outfile.write("0x%02x%02x%02x%02x, " % val)
|
||||
elements_on_line += 1
|
||||
|
||||
if elements_on_line >= 4:
|
||||
if elements_on_line >= 6:
|
||||
elements_on_line = 0
|
||||
outfile.write("\n")
|
||||
outfile.write(" ")
|
||||
|
|
|
|||
BIN
data/doom.png
BIN
data/doom.png
Binary file not shown.
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 22 KiB |
BIN
data/setup.png
BIN
data/setup.png
Binary file not shown.
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 24 KiB |
|
|
@ -251,7 +251,7 @@ CLEANFILES = $(execgames_SCRIPTS) $(app_DATA) $(screensaver_DATA)
|
|||
|
||||
if HAVE_PYTHON
|
||||
|
||||
icon.c : $(top_builddir)/data/doom8.ico
|
||||
icon.c : $(top_builddir)/data/doom.png
|
||||
$(top_builddir)/data/convert-icon $< $@
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1217,38 +1217,14 @@ void I_InitWindowTitle(void)
|
|||
void I_InitWindowIcon(void)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
Uint8 *mask;
|
||||
int i;
|
||||
|
||||
// Generate the mask
|
||||
surface = SDL_CreateRGBSurfaceFrom((void *) icon_data, icon_w, icon_h,
|
||||
32, icon_w * 4,
|
||||
0xff << 24, 0xff << 16,
|
||||
0xff << 8, 0xff << 0);
|
||||
|
||||
mask = malloc(icon_w * icon_h / 8);
|
||||
memset(mask, 0, icon_w * icon_h / 8);
|
||||
|
||||
for (i=0; i<icon_w * icon_h; ++i)
|
||||
{
|
||||
if (icon_data[i * 3] != 0x00
|
||||
|| icon_data[i * 3 + 1] != 0x00
|
||||
|| icon_data[i * 3 + 2] != 0x00)
|
||||
{
|
||||
mask[i / 8] |= 1 << (7 - i % 8);
|
||||
}
|
||||
}
|
||||
|
||||
surface = SDL_CreateRGBSurfaceFrom(icon_data,
|
||||
icon_w,
|
||||
icon_h,
|
||||
24,
|
||||
icon_w * 3,
|
||||
0xff << 0,
|
||||
0xff << 8,
|
||||
0xff << 16,
|
||||
0);
|
||||
|
||||
// SDL2-TODO: icon mask
|
||||
SDL_SetWindowIcon(screen, surface);
|
||||
SDL_FreeSurface(surface);
|
||||
free(mask);
|
||||
}
|
||||
|
||||
// Pick the modes list to use:
|
||||
|
|
|
|||
2994
src/icon.c
2994
src/icon.c
File diff suppressed because it is too large
Load diff
|
|
@ -38,7 +38,7 @@ CLEANFILES = $(app_DATA)
|
|||
|
||||
if HAVE_PYTHON
|
||||
|
||||
setup_icon.c : $(top_builddir)/data/setup8.ico
|
||||
setup_icon.c : $(top_builddir)/data/setup.png
|
||||
$(top_builddir)/data/convert-icon $^ $@
|
||||
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -278,42 +278,16 @@ static void InitConfig(void)
|
|||
|
||||
static void SetIcon(void)
|
||||
{
|
||||
// SDL2-TODO:
|
||||
#if 0
|
||||
extern SDL_Window *TXT_SDLWindow;
|
||||
SDL_Surface *surface;
|
||||
Uint8 *mask;
|
||||
int i;
|
||||
|
||||
// Generate the mask
|
||||
surface = SDL_CreateRGBSurfaceFrom((void *) setup_icon_data, setup_icon_w,
|
||||
setup_icon_h, 32, setup_icon_w * 4,
|
||||
0xff << 24, 0xff << 16,
|
||||
0xff << 8, 0xff << 0);
|
||||
|
||||
mask = malloc(setup_icon_w * setup_icon_h / 8);
|
||||
memset(mask, 0, setup_icon_w * setup_icon_h / 8);
|
||||
|
||||
for (i=0; i<setup_icon_w * setup_icon_h; ++i)
|
||||
{
|
||||
if (setup_icon_data[i * 3] != 0x00
|
||||
|| setup_icon_data[i * 3 + 1] != 0x00
|
||||
|| setup_icon_data[i * 3 + 2] != 0x00)
|
||||
{
|
||||
mask[i / 8] |= 1 << (7 - i % 8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
surface = SDL_CreateRGBSurfaceFrom(setup_icon_data,
|
||||
setup_icon_w,
|
||||
setup_icon_h,
|
||||
24,
|
||||
setup_icon_w * 3,
|
||||
0xff << 0,
|
||||
0xff << 8,
|
||||
0xff << 16,
|
||||
0);
|
||||
|
||||
SDL_WM_SetIcon(surface, mask);
|
||||
SDL_SetWindowIcon(TXT_SDLWindow, surface);
|
||||
SDL_FreeSurface(surface);
|
||||
free(mask);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SetWindowTitle(void)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -48,7 +48,7 @@ typedef struct
|
|||
|
||||
#define BLINK_PERIOD 250
|
||||
|
||||
static SDL_Window *screen;
|
||||
SDL_Window *TXT_SDLWindow;
|
||||
static SDL_Surface *screenbuffer;
|
||||
static unsigned char *screendata;
|
||||
static int key_mapping = 1;
|
||||
|
|
@ -245,12 +245,13 @@ int TXT_Init(void)
|
|||
// Always create the screen at the native screen depth (bpp=0);
|
||||
// some systems nowadays don't seem to support true 8-bit palettized
|
||||
// screen modes very well and we end up with screwed up colors.
|
||||
screen = SDL_CreateWindow("libtextscreen",
|
||||
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
TXT_SCREEN_W * font->w, TXT_SCREEN_H * font->h,
|
||||
0);//SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
TXT_SDLWindow =
|
||||
SDL_CreateWindow("libtextscreen",
|
||||
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
TXT_SCREEN_W * font->w, TXT_SCREEN_H * font->h,
|
||||
0);
|
||||
|
||||
if (screen == NULL)
|
||||
if (TXT_SDLWindow == NULL)
|
||||
return 0;
|
||||
|
||||
// Instead, we draw everything into an intermediate 8-bit surface
|
||||
|
|
@ -407,8 +408,9 @@ void TXT_UpdateScreenArea(int x, int y, int w, int h)
|
|||
|
||||
SDL_UnlockSurface(screenbuffer);
|
||||
|
||||
SDL_BlitSurface(screenbuffer, &rect, SDL_GetWindowSurface(screen), &rect);
|
||||
SDL_UpdateWindowSurfaceRects(screen, &rect, 1);
|
||||
SDL_BlitSurface(screenbuffer, &rect,
|
||||
SDL_GetWindowSurface(TXT_SDLWindow), &rect);
|
||||
SDL_UpdateWindowSurfaceRects(TXT_SDLWindow, &rect, 1);
|
||||
}
|
||||
|
||||
void TXT_UpdateScreen(void)
|
||||
|
|
@ -863,7 +865,7 @@ void TXT_EnableKeyMapping(int enable)
|
|||
|
||||
void TXT_SetWindowTitle(char *title)
|
||||
{
|
||||
SDL_SetWindowTitle(screen, title);
|
||||
SDL_SetWindowTitle(TXT_SDLWindow, title);
|
||||
}
|
||||
|
||||
void TXT_SDL_SetEventCallback(TxtSDLEventCallbackFunc callback, void *user_data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue