X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fx11.c;h=196bd8e71c1aee17c67aaf12cf3f2c959715b8f3;hb=a3cfdc216e5de47afb89f30d3c874e6489364076;hp=7d33a62354a09b832d072fe7e38979bdc08d1604;hpb=1100054eec7c45458359fd56072341bd661f4a9c;p=rocksndiamonds.git diff --git a/src/libgame/x11.c b/src/libgame/x11.c index 7d33a623..196bd8e7 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -12,6 +12,7 @@ ***********************************************************/ #include "system.h" +#include "pcx.h" #include "misc.h" @@ -234,4 +235,45 @@ static DrawWindow *X11InitWindow() return new_window; } +Bitmap *X11LoadImage(char *filename) +{ + Bitmap *new_bitmap = CreateBitmapStruct(); + int pcx_err; + +#if defined(PLATFORM_MSDOS) + rest(100); +#endif + + pcx_err = Read_PCX_to_Pixmap(display, window->drawable, window->gc, filename, + &new_bitmap->drawable, &new_bitmap->clip_mask); + switch(pcx_err) + { + case PCX_Success: + break; + case PCX_OpenFailed: + Error(ERR_EXIT, "cannot open PCX file '%s'", filename); + case PCX_ReadFailed: + Error(ERR_EXIT, "cannot read PCX file '%s'", filename); + case PCX_FileInvalid: + Error(ERR_EXIT, "invalid PCX file '%s'", filename); + case PCX_NoMemory: + Error(ERR_EXIT, "not enough memory for PCX file '%s'", filename); + case PCX_ColorFailed: + Error(ERR_EXIT, "cannot get colors for PCX file '%s'", filename); + default: + break; + } + + if (!new_bitmap->drawable) + Error(ERR_EXIT, "cannot get graphics for '%s'", filename); + + if (!new_bitmap->clip_mask) + Error(ERR_EXIT, "cannot get clipmask for '%s'", filename); + + /* set GraphicContext inheritated from Window */ + new_bitmap->gc = window->gc; + + return new_bitmap; +} + #endif /* TARGET_X11 */