summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/rocklib_img.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lua/rocklib_img.c')
-rw-r--r--apps/plugins/lua/rocklib_img.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/apps/plugins/lua/rocklib_img.c b/apps/plugins/lua/rocklib_img.c
index 9d9fb120f8..aaecc4d64c 100644
--- a/apps/plugins/lua/rocklib_img.c
+++ b/apps/plugins/lua/rocklib_img.c
@@ -224,6 +224,12 @@ static void pixel_to_fb(int x, int y, fb_data *oldv, fb_data *newv)
224#endif /* (LCD_DEPTH > 2) no native to pixel mapping needed */ 224#endif /* (LCD_DEPTH > 2) no native to pixel mapping needed */
225 225
226/* Internal worker functions for image data array *****************************/ 226/* Internal worker functions for image data array *****************************/
227static inline fb_data lua_to_fbscalar(lua_State *L, int narg)
228{
229 lua_Integer luaint = lua_tointeger(L, narg);
230 fb_data val = FB_SCALARPACK((unsigned) luaint);
231 return val;
232}
227 233
228static inline void swap_int(bool swap, int *v1, int *v2) 234static inline void swap_int(bool swap, int *v1, int *v2)
229{ 235{
@@ -416,7 +422,7 @@ static int rli_setget(lua_State *L, bool is_get, int narg_clip)
416 lua_pushinteger(L, FB_UNPACK_SCALAR_LCD(data_get(element, x, y))); 422 lua_pushinteger(L, FB_UNPACK_SCALAR_LCD(data_get(element, x, y)));
417 else /* set element */ 423 else /* set element */
418 { 424 {
419 clr = FB_SCALARPACK((unsigned) lua_tointeger(L, 4)); 425 clr = lua_to_fbscalar(L, 4);
420 lua_pushinteger(L, FB_UNPACK_SCALAR_LCD(data_set(element, x, y, &clr))); 426 lua_pushinteger(L, FB_UNPACK_SCALAR_LCD(data_set(element, x, y, &clr)));
421 } 427 }
422 428
@@ -681,7 +687,7 @@ static int rli_line_ellipse(lua_State *L, bool is_ellipse, int narg_clip)
681 int x2 = luaL_optint(L, 4, x1); 687 int x2 = luaL_optint(L, 4, x1);
682 int y2 = luaL_optint(L, 5, y1); 688 int y2 = luaL_optint(L, 5, y1);
683 689
684 fb_data clr = FB_SCALARPACK((unsigned) lua_tointeger(L, 6)); 690 fb_data clr = lua_to_fbscalar(L, 6);
685 691
686 fb_data fillclr; /* fill color is index 7 if is_ellipse */ 692 fb_data fillclr; /* fill color is index 7 if is_ellipse */
687 fb_data *p_fillclr = NULL; 693 fb_data *p_fillclr = NULL;
@@ -698,7 +704,7 @@ static int rli_line_ellipse(lua_State *L, bool is_ellipse, int narg_clip)
698 { 704 {
699 if(lua_type(L, 7) == LUA_TNUMBER) 705 if(lua_type(L, 7) == LUA_TNUMBER)
700 { 706 {
701 fillclr = FB_SCALARPACK((unsigned) lua_tointeger(L, 7)); 707 fillclr = lua_to_fbscalar(L, 7);
702 p_fillclr = &fillclr; 708 p_fillclr = &fillclr;
703 } 709 }
704 710
@@ -751,14 +757,14 @@ static void custom_transform(lua_State *L,
751 if(lua_type(L, -2) == LUA_TNUMBER) 757 if(lua_type(L, -2) == LUA_TNUMBER)
752 { 758 {
753 done = false; 759 done = false;
754 dst = FB_SCALARPACK((unsigned) lua_tointeger(L, -2)); 760 dst = lua_to_fbscalar(L, -2);
755 data_set(ds->elem, ds->x, ds->y, &dst); 761 data_set(ds->elem, ds->x, ds->y, &dst);
756 } 762 }
757 763
758 if(ss && (lua_type(L, -1) == LUA_TNUMBER)) 764 if(ss && (lua_type(L, -1) == LUA_TNUMBER))
759 { 765 {
760 done = false; 766 done = false;
761 src = FB_SCALARPACK((unsigned) lua_tointeger(L, -1)); 767 src = lua_to_fbscalar(L, -1);
762 data_set(ss->elem, ss->x, ss->y, &src); 768 data_set(ss->elem, ss->x, ss->y, &src);
763 } 769 }
764 770
@@ -956,7 +962,7 @@ RLI_LUA rli_raw(lua_State *L)
956 962
957 if(lua_type(L, 3) == LUA_TNUMBER) 963 if(lua_type(L, 3) == LUA_TNUMBER)
958 { 964 {
959 val = FB_SCALARPACK((unsigned) lua_tointeger(L, 3)); 965 val = lua_to_fbscalar(L, 3);
960 a->data[i-1] = val; 966 a->data[i-1] = val;
961 } 967 }
962 968
@@ -1055,7 +1061,7 @@ RLI_LUA rli_marshal(lua_State *L) /* also invert, clear */
1055 1061
1056 if (ltype == LUA_TNUMBER) 1062 if (ltype == LUA_TNUMBER)
1057 { 1063 {
1058 clr = FB_SCALARPACK((unsigned) lua_tointeger(L, 9)); 1064 clr = lua_to_fbscalar(L, 9);
1059 rli_trans = clear_transform; 1065 rli_trans = clear_transform;
1060 } 1066 }
1061 else if(ltype == LUA_TFUNCTION) /* custom function */ 1067 else if(ltype == LUA_TFUNCTION) /* custom function */
@@ -1156,7 +1162,7 @@ RLI_LUA rli_copy(lua_State *L)
1156 else 1162 else
1157 { 1163 {
1158 rli_trans = blit_transform; /* default transformation */ 1164 rli_trans = blit_transform; /* default transformation */
1159 clr = FB_SCALARPACK((unsigned) lua_tointeger(L, 11)); 1165 clr = lua_to_fbscalar(L, 11);
1160 op = lua_tointeger(L, 10); 1166 op = lua_tointeger(L, 10);
1161 } 1167 }
1162 1168