8 * image function methods
11 // convenience function, which fits image to its size
13 limage_fn_fit (lua_State
* L
)
17 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
20 evas_object_geometry_get (obj
->data
, NULL
, NULL
, &w
, &h
);
22 evas_object_image_fill_set (obj
->data
, 0, 0, w
, h
);
27 limage_fn_reload (lua_State
* L
)
31 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
32 evas_object_image_reload (obj
->data
);
37 limage_fn_save (lua_State
* L
)
40 * 2: table {file,key,flags}
42 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
43 lua_rawgeti (L
, 2, 1);
44 lua_rawgeti (L
, 2, 2);
45 lua_rawgeti (L
, 2, 3);
46 evas_object_image_save (obj
->data
,
47 luaL_checkstring (L
, -3),
48 luaL_checkstring (L
, -2), luaL_checkstring (L
, -1));
57 limage_get_file (lua_State
* L
)
61 const char *file
, *key
;
62 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
63 evas_object_image_file_get (obj
->data
, &file
, &key
);
65 lua_pushstring (L
, key
);
70 limage_get_border (lua_State
* L
)
75 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
76 evas_object_image_border_get (obj
->data
, &l
, &r
, &t
, &b
);
79 lua_pushnumber (L
, l
);
80 lua_rawseti (L
, -2, 1);
81 lua_pushnumber (L
, r
);
82 lua_rawseti (L
, -2, 2);
83 lua_pushnumber (L
, t
);
84 lua_rawseti (L
, -2, 3);
85 lua_pushnumber (L
, b
);
86 lua_rawseti (L
, -2, 4);
91 limage_get_border_center_fill (lua_State
* L
)
95 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
97 (int) evas_object_image_border_center_fill_get (obj
->
103 limage_get_fill (lua_State
* L
)
108 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
109 evas_object_image_fill_get (obj
->data
, &x
, &y
, &w
, &h
);
111 lua_pushnumber (L
, x
);
112 lua_rawseti (L
, -2, 1);
113 lua_pushnumber (L
, y
);
114 lua_rawseti (L
, -2, 2);
115 lua_pushnumber (L
, w
);
116 lua_rawseti (L
, -2, 3);
117 lua_pushnumber (L
, h
);
118 lua_rawseti (L
, -2, 4);
123 limage_get_fill_spread (lua_State
* L
)
128 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
130 evas_object_image_fill_spread_get (obj
->data
));
135 limage_get_size (lua_State
* L
)
140 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
141 evas_object_image_size_get (obj
->data
, &w
, &h
);
143 lua_pushnumber (L
, w
);
144 lua_rawseti (L
, -2, 1);
145 lua_pushnumber (L
, h
);
146 lua_rawseti (L
, -2, 2);
151 limage_get_stride (lua_State
* L
)
156 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
158 evas_object_image_stride_get (obj
->data
));
163 limage_get_load_error (lua_State
* L
)
167 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
168 lua_pushnumber (L
, evas_object_image_load_error_get (obj
->data
));
173 limage_get_alpha (lua_State
* L
)
177 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
178 lua_pushboolean (L
, (int) evas_object_image_alpha_get (obj
->data
));
183 limage_get_smooth_scale (lua_State
* L
)
187 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
188 lua_pushboolean (L
, (int) evas_object_image_smooth_scale_get (obj
->data
));
193 limage_get_pixels_dirty (lua_State
* L
)
197 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
198 lua_pushboolean (L
, (int) evas_object_image_pixels_dirty_get (obj
->data
));
203 limage_get_load_dpi (lua_State
* L
)
207 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
208 lua_pushnumber (L
, (int) evas_object_image_load_dpi_get (obj
->data
));
213 limage_get_load_size (lua_State
* L
)
218 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
219 evas_object_image_load_size_get (obj
->data
, &w
, &h
);
221 lua_pushnumber (L
, w
);
222 lua_rawseti (L
, -2, 1);
223 lua_pushnumber (L
, h
);
224 lua_rawseti (L
, -2, 2);
229 limage_get_load_scale_down (lua_State
* L
)
233 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
235 (int) evas_object_image_load_scale_down_get (obj
->data
));
240 limage_get_colorspace (lua_State
* L
)
244 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
245 lua_pushboolean (L
, (int) evas_object_image_colorspace_get (obj
->data
));
250 limage_get_data (lua_State
* L
)
254 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
256 int *pixels
= evas_object_image_data_get (obj
->data
, 0);
257 evas_object_image_size_get (obj
->data
, &w
, &h
);
259 for (x
= 0; x
< w
; x
++)
262 for (y
= 0; y
< h
; y
++)
264 lua_pushnumber (L
, pixels
[x
*w
+ y
]);
265 lua_rawseti (L
, -2, y
+ 1);
267 lua_rawseti (L
, -2, x
+ 1);
273 limage_get_fill_transform (lua_State
* L
)
275 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
276 Evas_Transform
*trans
= NULL
;
277 evas_object_image_fill_transform_get (obj
->data
, trans
);
288 limage_set_file (lua_State
* L
)
293 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
294 int key
= luaL_checknumber (L
, 2);
296 sprintf (buf
, "images/%i", key
);
297 lua_getfield (L
, LUA_REGISTRYINDEX
, "ego_file");
298 char *file
= luaL_checkstring (L
, -1);
299 evas_object_image_file_set (obj
->data
, file
, buf
);
304 limage_set_border (lua_State
* L
)
309 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
310 lua_rawgeti (L
, 2, 1);
311 lua_rawgeti (L
, 2, 2);
312 lua_rawgeti (L
, 2, 3);
313 lua_rawgeti (L
, 2, 4);
314 evas_object_image_border_set (obj
->data
,
315 (int) luaL_checknumber (L
, -4),
316 (int) luaL_checknumber (L
, -3),
317 (int) luaL_checknumber (L
, -2),
318 (int) luaL_checknumber (L
, -1));
323 limage_set_border_center_fill (lua_State
* L
)
326 * 2: border_center_fill
328 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
329 evas_object_image_border_center_fill_set (obj
->data
,
330 (int) lua_toboolean (L
, 2));
335 limage_set_fill (lua_State
* L
)
340 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
341 lua_rawgeti (L
, 2, 1);
342 lua_rawgeti (L
, 2, 2);
343 lua_rawgeti (L
, 2, 3);
344 lua_rawgeti (L
, 2, 4);
345 evas_object_image_fill_set (obj
->data
,
346 (int) luaL_checknumber (L
, -4),
347 (int) luaL_checknumber (L
, -3),
348 (int) luaL_checknumber (L
, -2),
349 (int) luaL_checknumber (L
, -1));
354 limage_set_fill_spread (lua_State
* L
)
359 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
360 evas_object_image_fill_spread_set (obj
->data
,
361 (int) luaL_checknumber (L
, 2));
366 limage_set_size (lua_State
* L
)
371 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
372 lua_rawgeti (L
, 2, 1);
373 lua_rawgeti (L
, 2, 2);
374 evas_object_image_size_set (obj
->data
,
375 (int) luaL_checknumber (L
, -2),
376 (int) luaL_checknumber (L
, -1));
381 limage_set_alpha (lua_State
* L
)
386 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
387 evas_object_image_alpha_set (obj
->data
, (int) lua_toboolean (L
, 2));
392 limage_set_smooth_scale (lua_State
* L
)
397 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
398 evas_object_image_smooth_scale_set (obj
->data
, (int) lua_toboolean (L
, 2));
403 limage_set_pixels_dirty (lua_State
* L
)
408 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
409 evas_object_image_pixels_dirty_set (obj
->data
, (int) lua_toboolean (L
, 2));
414 limage_set_load_dpi (lua_State
* L
)
419 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
420 evas_object_image_load_dpi_set (obj
->data
, luaL_checknumber (L
, 2));
425 limage_set_load_size (lua_State
* L
)
430 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
431 lua_rawgeti (L
, 2, 1);
432 lua_rawgeti (L
, 2, 2);
433 evas_object_image_load_size_set (obj
->data
,
434 (int) luaL_checknumber (L
, -2),
435 (int) luaL_checknumber (L
, -1));
440 limage_set_load_scale_down (lua_State
* L
)
445 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
446 evas_object_image_load_scale_down_set (obj
->data
,
447 luaL_checkint (L
, 2));
452 limage_set_colorspace (lua_State
* L
)
457 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
458 evas_object_image_colorspace_set (obj
->data
, (int) lua_toboolean (L
, 2));
463 limage_set_data (lua_State
* L
)
468 luaobj_Object
*obj
= (luaobj_Object
*) lua_touserdata (L
, 1);
471 evas_object_image_data_copy_set (obj
->data
, data
);
475 SET_OBJ (limage_set_fill_transform
, evas_object_image_fill_transform_set
);
478 * image function definitions
481 const luaL_Reg lImage_fn
[] = {
482 {"fit", limage_fn_fit
},
483 {"reload", limage_fn_reload
},
484 {"save", limage_fn_save
},
485 {NULL
, NULL
} // sentinel
489 * image get definitions
492 const struct luaL_Reg lImage_get
[] = {
493 {"file", limage_get_file
},
494 {"border", limage_get_border
},
495 {"border_center_fill", limage_get_border_center_fill
},
496 {"fill", limage_get_fill
},
497 {"fill_spread", limage_get_fill_spread
},
498 {"size", limage_get_size
},
499 {"stride", limage_get_stride
},
500 {"load_error", limage_get_load_error
},
501 {"alpha", limage_get_alpha
},
502 {"smooth_scale", limage_get_smooth_scale
},
503 {"pixels_dirty", limage_get_pixels_dirty
},
504 {"load_dpi", limage_get_load_dpi
},
505 {"load_size", limage_get_load_size
},
506 {"load_scale_down", limage_get_load_scale_down
},
507 {"colorspace", limage_get_colorspace
},
508 {"data", limage_get_data
},
509 {"fill_transform", limage_get_fill_transform
},
510 {NULL
, NULL
} // sentinel
514 * image set definitions
517 const struct luaL_Reg lImage_set
[] = {
518 {"file", limage_set_file
},
519 {"border", limage_set_border
},
520 {"border_center_fill", limage_set_border_center_fill
},
521 {"fill", limage_set_fill
},
522 {"fill_spread", limage_set_fill_spread
},
523 {"fill_transform", limage_set_fill_transform
},
524 {"size", limage_set_size
},
525 {"alpha", limage_set_alpha
},
526 {"smooth_scale", limage_set_smooth_scale
},
527 {"pixels_dirty", limage_set_pixels_dirty
},
528 {"load_dpi", limage_set_load_dpi
},
529 {"load_size", limage_set_load_size
},
530 {"load_scale_down", limage_set_load_scale_down
},
531 {"colorspace", limage_set_colorspace
},
532 {"data", limage_set_data
},
533 {"data_copy", limage_set_data
},
534 {NULL
, NULL
} // sentinel
541 const luaL_Reg lImage_nil
[] = {
542 {NULL
, NULL
} // sentinel
545 const luaobj_Reg mImage
= {
552 const luaobj_Reg
*cImage
[] = {