rliimg add flip image example (#FS13745) Try #2

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 2b6029ae8d7aafc7281132f2980c4a0694d38761
Author: William Wilgus <[email protected]>
Date:   Sat Jan 24 01:43:58 2026 -0500

    rliimg add flip image example (#FS13745) Try #2
    
     FS#13745 - Add transpose (like in python pillow module) and smooth resizing in rocklua
    
    most of this is supplied 'require image'
    
    flipping an image is built-in to the image generator function
    
    add image flip example to rliimg
    
    pushed the wrong script
    
    Change-Id: I2c512a70ed26b0457e46f2f2a187d3365783af67

diff --git a/apps/plugins/lua_scripts/rlimg.lua b/apps/plugins/lua_scripts/rlimg.lua
index 22784b3eb4..b3fa72426c 100755
--- a/apps/plugins/lua_scripts/rlimg.lua
+++ b/apps/plugins/lua_scripts/rlimg.lua
@@ -674,38 +674,44 @@ end -- rotate_image
 
 function flip_image(img)
     local blitop = _blit.BOR
-    local i = 1
     local d = 0
-    local ximg
-    local x, y, w, h, xr, yr
+    local x, y, w, h
 
     w = img:width()
     h = img:height()
-
+    x = (_lcd.W - w) / 2
+    y = (_lcd.H - h) / 2
     --make a copy of original screen for restoration
     local screen_img -- = _lcd:duplicate()
     screen_img =_img.new(w, h)
-    screen_img :copy(_LCD, 1, 1, xr, yr, w, h)
-    --_print.f("CW")
+    screen_img :copy(_LCD, 1, 1, x, y, w, h)
 
     --[[--Profiling code
     local timer = _timer.start()]]
 
     while d >= 0 do
         -- copy our flipped image onto the background
-        _lcd:copy(ximg, x, y, w, 1, 1, h, false, blitop)
+        if d == 0 then
+            _lcd:copy(img, x, y, 1, 1, w, h, false, blitop)
+        elseif d == 1 then
+            _lcd:copy(img, x, y, 1, 1, -w, h, false, blitop)
+        elseif d == 2 then
+            _lcd:copy(img, x, y, 1, 1, w, -h, false, blitop)
+        elseif d == 3 then
+            _lcd:copy(img, x, y, 1, 1, -w, -h, false, blitop)
+            d = -1
+        end
         _lcd:update()
         --restore the portion of the background we destroyed
-        _lcd:copy(screen_img, xr, yr, 1, 1)
+        _lcd:copy(screen_img, x, y, 1, 1)
 
         d = d + i
 
-        if rb.get_plugin_action(0) == CANCEL_BUTTON then
+        if rb.get_plugin_action(rb.HZ) == CANCEL_BUTTON then
             break;
         end
     end
 
-    _lcd:copy(ximg, x, y, 1, 1, w, h)
     --[[-- Profiling code
     _print.f("%d", _timer.stop(timer))
     rb.sleep(rb.HZ * 10)]]
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.