annotate src/xpm_w32.c @ 48:67300faee616 v7-3-618

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