diff options
| author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-06-15 13:30:03 +0000 |
|---|---|---|
| committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-06-15 13:30:03 +0000 |
| commit | e55bdff3509fa978f4a8c9b7a62c662bba401d33 (patch) | |
| tree | 8e9875b46c7d6631cc4aa080e7c2e0e791a49755 /apps/plugins/helloworld.lua | |
| parent | 33c87e08e5617c75e164fc18316264af2f94d64d (diff) | |
| download | rockbox-e55bdff3509fa978f4a8c9b7a62c662bba401d33.zip rockbox-e55bdff3509fa978f4a8c9b7a62c662bba401d33.tar.gz rockbox-e55bdff3509fa978f4a8c9b7a62c662bba401d33.tar.bz2 rockbox-e55bdff3509fa978f4a8c9b7a62c662bba401d33.tar.xz | |
Fix helloworld.lua on grayscale targets
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21290 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/helloworld.lua')
| -rw-r--r-- | apps/plugins/helloworld.lua | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/plugins/helloworld.lua b/apps/plugins/helloworld.lua index fcdd4de..047e31a 100644 --- a/apps/plugins/helloworld.lua +++ b/apps/plugins/helloworld.lua @@ -32,7 +32,12 @@ end -- Helper function which draws a transparent image at the center of the screen function draw_image(img) local x, y = (rb.LCD_WIDTH - img:width()) / 2, (rb.LCD_HEIGHT - img:height()) / 2 - rb.lcd_bitmap_transparent_part(img, 0, 0, img:width(), x, y, img:width(), img:height()) + + local func = rb.lcd_bitmap_transparent_part + if(func == nil) then + func = rb.lcd_bitmap_part -- Fallback version for mono targets + end + func(img, 0, 0, img:width(), x, y, img:width(), img:height()) rb.lcd_update() end @@ -99,18 +104,23 @@ rb.lcd_clear_display() rb.lcd_drawline(0, 0, rb.LCD_WIDTH, rb.LCD_HEIGHT) rb.lcd_drawline(rb.LCD_WIDTH, 0, 0, rb.LCD_HEIGHT) -local rectangle = rb.new_image(10, 15) -- Create a new image with width 10 and height 15 -for i=1, 10 do - for j=1, 15 do - rectangle:set(i, j, rb.lcd_rgbpack(200, i*20, j*20)) -- Set the pixel at position i, j to the specified color +if(rb.lcd_rgbpack ~= nil) then -- Only do this when we're on a color target, i.e. when LCD_RGBPACK is available + local rectangle = rb.new_image(10, 15) -- Create a new image with width 10 and height 15 + for i=1, 10 do + for j=1, 15 do + rectangle:set(i, j, rb.lcd_rgbpack(200, i*20, j*20)) -- Set the pixel at position i, j to the specified color + end end -end --- rb.lcd_bitmap_part(src, src_x, src_y, stride, x, y, width, height) -rb.lcd_bitmap_part(rectangle, 0, 0, 10, rb.LCD_WIDTH/2-5, rb.LCD_HEIGHT/10-1, 10, 10) -- Draws our rectangle at the top-center of the screen + -- rb.lcd_bitmap_part(src, src_x, src_y, stride, x, y, width, height) + rb.lcd_bitmap_part(rectangle, 0, 0, 10, rb.LCD_WIDTH/2-5, rb.LCD_HEIGHT/10-1, 10, 10) -- Draws our rectangle at the top-center of the screen +end -- Load a BMP file in the variable backdrop local backdrop = rb.read_bmp_file("/.rockbox/icons/tango_small_viewers.bmp") -- This image should always be present? +if(backdrop == nil) then + backdrop = rb.read_bmp_file("/.rockbox/icons/tango_small_viewers_mono.bmp") -- Try using the mono version +end -- Draws the image using our own draw_image() function; see up draw_image(backdrop) |