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