-void LoadGfx(int pos, struct PictureFileInfo *pic)
-{
- char basefilename[256];
- char filename[256];
-
-#if defined(TARGET_SDL)
- SDL_Surface *sdl_image_tmp;
-#else
- int pcx_err;
-#endif
- char *picture_ext = ".pcx";
-
- /* Grafik laden */
- if (pic->picture_filename)
- {
- sprintf(basefilename, "%s%s", pic->picture_filename, picture_ext);
- DrawInitText(basefilename, 150, FC_YELLOW);
- sprintf(filename, "%s/%s/%s",
- options.ro_base_directory, GRAPHICS_DIRECTORY, basefilename);
-
-#if defined(PLATFORM_MSDOS)
- rest(100);
-#endif
-
- pix[pos] = CreateBitmapStruct();
-
-#if defined(TARGET_SDL)
- /* load image to temporary surface */
- if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
- Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError());
-
- /* create native non-transparent surface for current image */
- if ((pix[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
-
- /* create native transparent surface for current image */
- SDL_SetColorKey(sdl_image_tmp, SDL_SRCCOLORKEY,
- SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
- if ((pix_masked[pos] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
-
- /* free temporary surface */
- SDL_FreeSurface(sdl_image_tmp);
-
-#else /* !TARGET_SDL */
-
- pcx_err = Read_PCX_to_Pixmap(display, window->drawable, window->gc,
- filename,
- &pix[pos]->drawable, &pix[pos]->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 (!pix[pos]->drawable)
- Error(ERR_EXIT, "cannot get graphics for '%s'", pic->picture_filename);
-
-#if 0
- /* setting pix_masked[] to pix[] allows BlitBitmapMasked() to always
- use pix_masked[], although they are the same when not using SDL */
- pix_masked[pos] = pix[pos];
-#endif
-
-#endif /* !TARGET_SDL */
- }
-
-#if defined(TARGET_X11)
- /* check if clip mask was correctly created */
- if (pic->picture_with_mask && !pix[pos]->clip_mask)
- Error(ERR_EXIT, "cannot get clipmask for '%s'", pic->picture_filename);
-#endif
-}
-