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

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

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

Post by Palm Liu »

OLED.IMAGE 0, 38, a$ work fine for xbm file

Is it possible to use bmp? because it will save much flash space.

Thanks!
User avatar
cicciocb
Site Admin
Posts: 1989
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 426 times
Been thanked: 1329 times
Contact:

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

Post by cicciocb »

I suppose the request is for the esp8266 ....?
Palm Liu
Posts: 47
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 »

Yes, I am working on ESP-12F
User avatar
cicciocb
Site Admin
Posts: 1989
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 426 times
Been thanked: 1329 times
Contact:

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

Post by cicciocb »

I have a question. What is the tool that you should use for the bitmap?
As I know the BMP are always with colors, don't know if there is a tool that exports the bmp with only 2 colors
BeanieBots
Posts: 344
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 180 times
Been thanked: 112 times

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

Post by BeanieBots »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Nov 09, 2022 9:00 am I have a question. What is the tool that you should use for the bitmap?
As I know the BMP are always with colors, don't know if there is a tool that exports the bmp with only 2 colors
I use GIMP for just about everything graphics related. It can export any colour depth in just about any format.
It's free and open source.
Unfortunately, it's not very intuitive and takes a lot of learning but there is online help and a large support group if you get stuck.
Inkscape is another very flexible graphics package. Also free.
Palm Liu
Posts: 47
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 9:00 am I have a question. What is the tool that you should use for the bitmap?
As I know the BMP are always with colors, don't know if there is a tool that exports the bmp with only 2 colors
I use microsoft window "paint" to generate 2 color (or say mono) BMP. Just
"File"
"Save As"
"BMP"
then choose mono color

Attached please find a sample file I created.

To convert BMP to XMB, I use:
https://convertio.co/zh/bmp-xbm/
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 1989
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 426 times
Been thanked: 1329 times
Contact:

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

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Nov 09, 2022 9:21 am
[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Nov 09, 2022 9:00 am I have a question. What is the tool that you should use for the bitmap?
As I know the BMP are always with colors, don't know if there is a tool that exports the bmp with only 2 colors
I use GIMP for just about everything graphics related. It can export any colour depth in just about any format.
It's free and open source.
Unfortunately, it's not very intuitive and takes a lot of learning but there is online help and a large support group if you get stuck.
Inkscape is another very flexible graphics package. Also free.
GIMP do not seems to export in 2 colors
BeanieBots
Posts: 344
Joined: Tue Jun 21, 2022 2:17 pm
Location: South coast UK
Has thanked: 180 times
Been thanked: 112 times

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

Post by BeanieBots »

GIMP do not seems to export in 2 colors
Sorry, it's not part of the export selection. You need to convert within GIMP, then export.
Image/mode/indexed. Then select how many colours you want. eg 2
Then save/export as required.
User avatar
cicciocb
Site Admin
Posts: 1989
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 426 times
Been thanked: 1329 times
Contact:

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

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed Nov 09, 2022 11:15 am
GIMP do not seems to export in 2 colors
Sorry, it's not part of the export selection. You need to convert within GIMP, then export.
Image/mode/indexed. Then select how many colours you want. eg 2
Then save/export as required.
Thanks, I'll test
Palm Liu
Posts: 47
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 »

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
You do not have the required permissions to view the files attached to this post.
Post Reply