javl / image2cpp

GNU General Public License v3.0
534 stars 158 forks source link

Last Number missing #18

Closed kaoz3000 closed 6 years ago

kaoz3000 commented 6 years ago

I'm trying to convert multiple 8x8 pngs: "plain bytes" and "Arduino code, single bitmap" gives me the correct bytes:

 // '25b', 8x8px
0x24, 0x24, 0x3c, 0x7e, 0xc3, 0xbd, 0x66, 0x24, 
 // '25a', 8x8px
0x42, 0x66, 0x3c, 0x7e, 0xc3, 0xbd, 0x66, 0x42, 

But "Ardunino code" gives me this:

 // '25b', 8x8px
const unsigned char myBitmap1 [] PROGMEM = {
    0x24, 0x24, 0x3c, 0x7e, 0xc3, 0xbd, 0x66, 0x2
};
 // '25a', 8x8px
const unsigned char myBitmap2 [] PROGMEM = {
    0x42, 0x66, 0x3c, 0x7e, 0xc3, 0xbd, 0x66, 0x4
};

the last Numbers are missing/wrong

kaoz3000 commented 6 years ago

this seems to help:

Line 809

// remove last comma and space chars
code = code.substring(0, code.length - 3);

change to

// remove last comma and space chars
code = code.substring(0, code.length - 2);
javl commented 6 years ago

Thanks for reporting + for figuring out what causes the behavior. I'll fix it asap