chdk bootup logo mod - page 2 - General Discussion and Assistance - CHDK Forum

chdk bootup logo mod

  • 13 Replies
  • 10752 Views
Re: chdk bootup logo mod
« Reply #10 on: 12 / August / 2008, 17:10:27 »
Advertisements
ok a quick test shows:
- logo as it is: 3150 x 32 bit
- logo as 3bit/pixel: 1182 x 32 bit
- logo as rle: 827 x 32 bit

*

Offline DataGhost

  • ****
  • 314
  • EOS 40D, S5IS
    • DataGhost.com
Re: chdk bootup logo mod
« Reply #11 on: 13 / August / 2008, 03:24:44 »
You could use a lookup table to map the used colors into 2 or 3 bits, maybe add a little bit of logic to handle long pieces of the same color (lines) and maybe you can even compress it afterwards... or let the compression handle the last two parts. Keep in mind, though, any decompression algorithm also requires code.

As I see it, it's white, black, red and grey (except for the grey-ish inner ring)? That'll fit into 2 bits, which is also a lot easier to process than 3 bits.
« Last Edit: 13 / August / 2008, 03:26:35 by DataGhost »

Re: chdk bootup logo mod
« Reply #12 on: 13 / August / 2008, 14:58:10 »
Hi!

Ok i did the modifications for RLE encoding the picture :)

I included my quickndirty perl program that converts the image from gimp to the
RLE compressed image as c header. Requirements for converting any logo to this:
- input image in header file format (gimp)
- 8 colors  (palette values needs to be entered in perl script)
- 150px wide (could be changed in gui.c)
-> convert it into header with the perl file in the attached tgz

Here is the new gui.c code (also in tgz):
Code: (diff) [Select]
Index: core/gui.c
===================================================================
--- core/gui.c  (revision 469)
+++ core/gui.c  (working copy)
@@ -29,6 +29,7 @@
 #include "script.h"
 #include "motion_detector.h"
 #include "raw.h"
+#include "gui_logo.h"

 //-------------------------------------------------------------------

@@ -2179,11 +2180,35 @@
     }
     w=w*FONT_WIDTH+10;

-    x = (screen_width-w)>>1; y = (screen_height-h)>>1;
+    x = (screen_width-w)>>1; y = ((screen_height-h)>>1) + 20;
     draw_filled_round_rect(x, y, x+w, y+h, cl);
     for (i=0; i<sizeof(text)/sizeof(text[0]); ++i) {
         draw_string(x+((w-strlen(text[i])*FONT_WIDTH)>>1), y+i*FONT_HEIGHT+4, text[i], cl);
     }
+
+    int pos;
+    int mx=0;
+    int my=0;
+    int offset_x = (screen_width-150)>>1;
+    int offset_y = ((screen_height-84)>>1) - 42;
+    const color color_lookup[8] = {0xFF, 0x2E, 0x22, 0x3D, 0x1F,  0x21, 0x00, 0x11};
+
+    for(pos=0; pos<HEADER_DATA_LEN; pos++){
+        char data = header_data[pos];
+        color c = color_lookup[(data>>5) & 0x07];
+        for(i=0; i<(data&0x1F)+1; i++){
+            if (c!=0x00){
+                draw_pixel(offset_x+mx,offset_y+my,c);
+            }
+            if (mx==149){
+                mx=0;
+                my++;
+            }else{
+                mx++;
+            }
+
+        }
+    }
 }

 //-------------------------------------------------------------------


This way i could shrink the image from 12600 bytes (it was completely unoptimized)
down to 2457Bytes (=only 615 x 32 bit !)

The code to decode it is also very small (could be optimized for runtime i guess but not necessary)

Btw saving the image uncompressed as 8 colors/px would result in 4725Bytes :)

I think RLE is the best solution for the image. And wasting 615 words (32 bit each) should be no problem ;)

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: chdk bootup logo mod
« Reply #13 on: 13 / August / 2008, 20:41:30 »
added your patch to the branch. decreased binary size like you predicted. now if use an image from the filesystem it of course would reduce size again, but then again i wouldnt know how to do that ;)

 

Related Topics


SimplePortal © 2008-2014, SimplePortal