Wed Apr 17 01:05:42 PDT 2002
[netwalk.git] / image.e
blobaa56b21f3a65949270b5c70a6d2f66f5bde96ebc
1 class IMAGE
2 creation make
3 feature
4 make is
5 do
6 end
8 width : INTEGER is
9 require
10 is_connected
12 Result := get_img_width(ptr)
13 end
15 height : INTEGER is
16 require
17 is_connected
19 Result := get_img_height(ptr)
20 end
22 is_connected : BOOLEAN
24 load(filename : STRING) is
26 ptr := load_image(filename.to_external)
27 if ptr.is_not_null then
28 is_connected := True
29 end
30 end
32 free is
33 require
34 is_connected
36 if ptr.is_not_null then
37 ptr := free_img(ptr)
38 is_connected := False
39 end
40 end
42 partial_blit(rx, ry, rw, rh, x, y : INTEGER) is
43 require
44 is_connected
46 partial_blit_img(ptr, rx, ry, rw, rh, x, y)
47 end
49 blit(x, y : INTEGER) is
50 require
51 is_connected
53 blit_img(ptr, x, y)
54 end
56 render_string(s : STRING; font : TTF_FONT; c : COLOR) is
57 require
58 not is_connected --otherwise it's a memory leak
59 font.is_connected
60 s /= Void
61 s.count > 0
63 ptr := ext_render_text(s.to_external, font.to_external, c.to_external)
64 if ptr.is_not_null then
65 is_connected := True
66 convert_display_format
67 else
68 io.put_string("render_string " + s.count.to_string + " failed!%N")
69 end
70 ensure
71 is_connected
72 end
74 set_alpha(a : INTEGER) is
75 require
76 is_connected
78 img_set_alpha(ptr, a)
79 end
81 convert_display_format_alpha is
82 require
83 is_connected
85 ptr := ext_display_format_alpha(ptr)
86 end
88 convert_display_format is
89 require
90 is_connected
92 ptr := ext_display_format(ptr)
93 end
95 feature {NONE}
96 ptr : POINTER
98 load_image(filename : POINTER) : POINTER is
99 external "C"
102 free_img(i : POINTER) : POINTER is
103 external "C"
106 ext_render_text(string : POINTER; font : POINTER; c : POINTER) : POINTER is
107 external "C"
110 get_img_width(i : POINTER) : INTEGER is
111 external "C"
114 get_img_height(i : POINTER) : INTEGER is
115 external "C"
118 img_set_alpha(i : POINTER; a : INTEGER) is
119 external "C"
122 partial_blit_img(i : POINTER; rx, ry, rw, rh, x, y : INTEGER) is
123 external "C"
126 blit_img(i : POINTER; x, y : INTEGER) is
127 external "C"
130 ext_display_format_alpha(p : POINTER) : POINTER is
131 external "C"
134 ext_display_format(p : POINTER) : POINTER is
135 external "C"