2
0
mirror of https://github.com/Genymobile/scrcpy synced 2025-09-02 23:35:19 +00:00

Parse XPM without SDL_image

We encounter some problems with SDL2_image on MSYS2 (Windows), so
implement our own XPM parsing which does not depend on SDL_image.

The input XPM is considered safe (it's in our source repo), so do not
check XPM format errors. This implies that read_xpm() is not safe to
call on any unsafe input.

Although less straightforward, use SDL_CreateRGBSurfaceFrom() instead of
SDL_CreateRGBSurfaceWithFormatFrom() because it is available with SDL
versions older than 2.0.5.
This commit is contained in:
Romain Vimont
2018-02-05 17:29:40 +01:00
parent 920bafce73
commit 71c2bfdd22
5 changed files with 109 additions and 7 deletions

View File

@@ -6,7 +6,6 @@
#include <libavformat/avformat.h>
#include <sys/time.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_net.h>
#include "command.h"
@@ -19,6 +18,7 @@
#include "lockutil.h"
#include "netutil.h"
#include "server.h"
#include "tinyxpm.h"
#include "icon.xpm"
@@ -651,7 +651,7 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size, Uint32 b
goto screen_finally_destroy_renderer;
}
SDL_Surface *icon = IMG_ReadXPMFromArray(icon_xpm);
SDL_Surface *icon = read_xpm(icon_xpm);
if (!icon) {
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not load icon: %s", SDL_GetError());
ret = SDL_FALSE;