annotate src/xpm_w32.c @ 1017:0d31f8a78ab3 v7.0.143

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