This source file includes following definitions.
- haiku_can_use_native_image_api
- haiku_load_image
- syms_of_haikuimage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "lisp.h"
22 #include "dispextern.h"
23 #include "haikuterm.h"
24 #include "coding.h"
25
26 #include "haiku_support.h"
27
28 bool
29 haiku_can_use_native_image_api (Lisp_Object type)
30 {
31 const char *mime_type = NULL;
32
33 if (EQ (type, Qnative_image))
34 return 1;
35
36 #ifdef HAVE_RSVG
37 if (EQ (type, Qsvg))
38 return 0;
39 #endif
40
41 if (EQ (type, Qjpeg))
42 mime_type = "image/jpeg";
43 else if (EQ (type, Qpng))
44 mime_type = "image/png";
45 #ifndef HAVE_GIF
46 else if (EQ (type, Qgif))
47 mime_type = "image/gif";
48 #endif
49 else if (EQ (type, Qtiff))
50 mime_type = "image/tiff";
51 else if (EQ (type, Qbmp))
52 mime_type = "image/bmp";
53 else if (EQ (type, Qsvg))
54 mime_type = "image/svg";
55 else if (EQ (type, Qpbm))
56 mime_type = "image/pbm";
57
58
59 #ifndef HAVE_WEBP
60 else if (EQ (type, Qwebp))
61 mime_type = "image/webp";
62 #endif
63
64 if (!mime_type)
65 return 0;
66
67 return be_can_translate_type_to_bitmap_p (mime_type);
68 }
69
70 extern int
71 haiku_load_image (struct frame *f, struct image *img,
72 Lisp_Object spec_file, Lisp_Object spec_data)
73 {
74 eassert (valid_image_p (img->spec));
75
76 void *pixmap = NULL;
77
78 if (STRINGP (spec_file))
79 {
80 pixmap = be_translate_bitmap_from_file_name
81 (SSDATA (ENCODE_UTF_8 (spec_file)));
82 }
83 else if (STRINGP (spec_data))
84 {
85 pixmap = be_translate_bitmap_from_memory
86 (SSDATA (spec_data), SBYTES (spec_data));
87 }
88
89 void *conv = NULL;
90
91 if (!pixmap || !BBitmap_convert (pixmap, &conv))
92 {
93 add_to_log ("Unable to load image %s", img->spec);
94 return 0;
95 }
96
97 if (conv)
98 {
99 BBitmap_free (pixmap);
100 pixmap = conv;
101 }
102
103 int left, top, right, bottom, stride, mono_p;
104 BBitmap_dimensions (pixmap, &left, &top, &right, &bottom, &stride, &mono_p);
105
106 img->width = (1 + right - left);
107 img->height = (1 + bottom - top);
108 img->pixmap = pixmap;
109
110 return 1;
111 }
112
113 void
114 syms_of_haikuimage (void)
115 {
116 }