OLED.IMAGE 0, 38, a$ (for xbm, is it possible to use bmp)

Feature requested and implemented
Palm Liu
Posts: 40
Joined: Fri Jun 25, 2021 3:50 am
Has thanked: 10 times
Been thanked: 17 times

Re: OLED.IMAGE 0, 38, a$ (for xbm, is it possible to use bmp)

Post by Palm Liu »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Nov 09, 2022 11:37 am Good News!

I find a way to use smaller "xbm" file :D :D :D

1. I create a 2-color (mono) BMP by Microsoft Window Paint --> "test.bmp"

2. Convert it from "test.bmp" to "test.xbm" by "https://convertio.co/zh/bmp-xbm/"

3. Compress "test.xbm" to "test.xbc" (simply cut those content without information), you can find that "test.xbc" is only 1/3 size of "test.xbm"

4. Then upload "test.xbc" to Annex (I'm using ESP-12F)

5. Then run the following code:

I2C.SETUP SDA, SCL
OLED.INIT 1

CONVERT "test"
OLED.IMAGE 0, 0, "/XBM/test.xbm"
wait

'=======================================
SUB CONVERT(f$)
b$ = "#define f_width 126" + CHR$(13)
b$ = b$ + "#define f_height 26" + CHR$(13)
b$ = b$ + "static char f_bits[] = {" + CHR$(13)
FOR j = 1 TO 34
a$ = FILE.READ$("/XBM/" + f$ + ".xbc", j)
FOR i = 1 TO 12
b$ = b$ + "0x" + mid$(a$, i*2 - 1, 2) + ","
NEXT i
b$ = b$ + CHR$(13)
NEXT j
a$ = FILE.READ$("/XBM/" + f$ + ".xbc", 35)
FOR i = 1 TO 8
b$ = b$ + "0x" + mid$(a$, i*2 - 1, 2) + ","
NEXT i
b$ = b$ + "};" + CHR$(13)
IF FILE.EXISTS("/XBM/" + f$ + ".xbm") <> 0 THEN
ret = FILE.DELETE("/XBM/" + f$ + ".xbm")
ENDIF
FILE.APPEND "/XBM/" + f$ + ".xbm", b$
END SUB


'content for test.xbm

#define 1c6467e32efc4b9e87204c7fcf66a2b1AUUM6XlXGesoQY2O_width 126
#define 1c6467e32efc4b9e87204c7fcf66a2b1AUUM6XlXGesoQY2O_height 26
static char 1c6467e32efc4b9e87204c7fcf66a2b1AUUM6XlXGesoQY2O_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0x00, 0xE0, 0x07, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00,
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0xC2, 0x01, 0x1F, 0xF0, 0x01, 0x00, 0x00, 0x7C, 0xC0, 0x07, 0xF0, 0x03,
0x07, 0x38, 0xFC, 0x10, 0xF2, 0x81, 0x3F, 0xF8, 0x01, 0x00, 0x00, 0xFE,
0xE0, 0x07, 0xF0, 0x07, 0x07, 0x3C, 0xFC, 0x11, 0x92, 0x81, 0x70, 0x1C,
0x00, 0x00, 0x00, 0xC2, 0x71, 0x00, 0x30, 0x0E, 0x0F, 0x3C, 0x8C, 0x13,
0x82, 0x01, 0x60, 0x0C, 0x00, 0x00, 0x00, 0x80, 0x31, 0x00, 0x30, 0x0C,
0x0F, 0x3C, 0x0C, 0x13, 0x82, 0x01, 0x60, 0x06, 0x00, 0x03, 0x03, 0x80,
0x19, 0x00, 0x30, 0x0C, 0x0B, 0x36, 0x0C, 0x13, 0x82, 0x01, 0x60, 0xF6,
0x00, 0x86, 0x01, 0x80, 0xD9, 0x03, 0x30, 0x06, 0x1B, 0x36, 0x0C, 0x13,
0x82, 0x01, 0x30, 0xFE, 0x01, 0xCC, 0x00, 0xC0, 0xF8, 0x07, 0xF0, 0x03,
0x1B, 0x33, 0x8C, 0x13, 0x82, 0x01, 0x18, 0x8E, 0x03, 0x68, 0x00, 0x60,
0x38, 0x0E, 0xF0, 0x0F, 0x13, 0x33, 0xFC, 0x11, 0x82, 0x01, 0x0C, 0x06,
0x03, 0x30, 0x00, 0x30, 0x18, 0x0C, 0x30, 0x1C, 0xB3, 0x31, 0xFC, 0x10,
0x82, 0x01, 0x06, 0x06, 0x03, 0x30, 0x00, 0x18, 0x18, 0x0C, 0x30, 0x18,
0xB3, 0x31, 0x0C, 0x10, 0x82, 0x01, 0x03, 0x06, 0x03, 0x58, 0x00, 0x0C,
0x18, 0x0C, 0x30, 0x18, 0xA3, 0x31, 0x0C, 0x10, 0x82, 0x81, 0x01, 0x8C,
0x03, 0xCC, 0x00, 0x06, 0x30, 0x0E, 0x30, 0x1C, 0xE3, 0x30, 0x0C, 0x10,
0xF2, 0xCF, 0x7F, 0xFC, 0x01, 0x86, 0x01, 0xFF, 0xF1, 0x07, 0xF0, 0x0F,
0xE3, 0x30, 0x0C, 0x10, 0xF2, 0xCF, 0x7F, 0xF8, 0x00, 0x03, 0x03, 0xFF,
0xE1, 0x03, 0xF0, 0x07, 0x43, 0x30, 0x0C, 0x10, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x07, 0xC0, 0x7F, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7F, 0x00,
0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };


'content for test.xbc

000000000000000000000000
0000000000F8FFFFFFFFFFFF
FFFFFFFFFFFF0700E0070000
00000000000000000000F800
180000000000000000000000
000000070600000000000000
000000000000000802000000
000000000000000000000010
C2011FF00100007CC007F003
0738FC10F2813FF8010000FE
E007F007073CFC119281701C
000000C27100300E0F3C8C13
8201600C000000803100300C
0F3C0C138201600600030380
1900300C0B360C13820160F6
00860180D90330061B360C13
820130FE01CC00C0F807F003
1B338C138201188E03680060
380EF00F1333FC1182010C06
03300030180C301CB331FC10
8201060603300018180C3018
B3310C10820103060358000C
180C3018A3310C108281018C
03CC0006300E301CE3300C10
F2CF7FFC018601FFF107F00F
E3300C10F2CF7FF8000303FF
E103F00743300C1002000000
000000000000000000000010
040000000000000000000000
000000083800000000000000
0000000000008007C07F0000
000000000000000000807F00
0080FFFFFFFFFFFFFFFFFFFF
FF7F00000000000000000000
0000000000000000
This method works, but speed is low, so is it possible to direct use BMP files (e.g. OLED.BMP x, y, a$)
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: OLED.IMAGE 0, 38, a$ (for xbm, is it possible to use bmp)

Post by cicciocb »

Implemented in the version 1.48.2 for ESP32
Post Reply