1/* 2 * Load XPM image. 3 * 4 * This function is placed in separate file because Xpm headers conflict with 5 * Vim ones :( 6 * 7 * Written by Sergey Khorev. 8 * http://iamphet.nm.ru/vim/index.html 9 */ 10 11#ifndef WIN32_LEAN_AND_MEAN 12# define WIN32_LEAN_AND_MEAN 13#endif 14#include <windows.h> 15 16/* reduced def from Vim.h */ 17#ifndef __ARGS 18# if defined(__STDC__) || defined(__GNUC__) || defined(WIN3264) 19# define __ARGS(x) x 20# else 21# define __ARGS(x) () 22# endif 23#endif 24 25#include "xpm_w32.h" 26 27/* Engage Windows support in libXpm */ 28#define FOR_MSW 29 30#include "xpm.h" 31 32/* 33 * Tries to load Xpm image from file 'filename'. 34 * If fails return -1. 35 * success - 0 and image and mask BITMAPS 36 */ 37 int 38LoadXpmImage(filename, hImage, hShape) 39 char *filename; 40 HBITMAP *hImage; 41 HBITMAP *hShape; 42{ 43 XImage *img; /* loaded image */ 44 XImage *shp; /* shapeimage */ 45 XpmAttributes attr; 46 int res; 47 HDC hdc = CreateCompatibleDC(NULL); 48 49 attr.valuemask = 0; 50 res = XpmReadFileToImage(&hdc, filename, &img, &shp, &attr); 51 DeleteDC(hdc); 52 if (res < 0) 53 return -1; 54 else 55 { 56 *hImage = img->bitmap; 57 *hShape = shp->bitmap; 58 return 0; 59 } 60} 61