SSD1306 OLED Adafruit Libary - drawBitmap() function stretches image


hi there!

so bought myself cheap ssd1306 i2c 128x64 oled display , downloaded appropriate libraries adafruit:
https://github.com/ehubin/adafruit-gfx-library
https://github.com/adafruit/adafruit_ssd1306

the example sketch worked without problem , not stretched.


so decided display own image. created 124x31 pixel bmp converted using img2code java programm form adafruit-gfx-library:



i added code array sample sketch , used display.drawbitmap( 0, 0, code, 124, 31, 1); function, understand has correct input: offset 0,0 width: 124, height: 31

code: [select]


//save image array
const unsigned char progmem logo [] =
{
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xfc,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xc0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,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x0,0xff,0xff,0xff,
0xf8,0x7c,0xff,0xfc,0x7c,0x3e,0x7f,0xfe,0x3f,0xff,0x3f,0xff,0x0,0xff,0xff,0xff,
0xf8,0x7c,0xff,0xfc,0x7c,0x3e,0x7f,0xfe,0x3f,0xff,0x3f,0xff,0x0,0xff,0xff,0xff,
0xff,0xfc,0xff,0xfc,0x7f,0xfe,0x7f,0xfe,0x3f,0xff,0x3f,0xff,0x0,0xff,0xff,0xff,
0xff,0xfc,0xff,0xfc,0x7f,0xfe,0x7f,0xfe,0x3f,0xff,0x3e,0x1f,0x0,0xff,0xff,0xff,
0xff,0xfc,0x3f,0x7c,0x7f,0xfe,0x7c,0x0,0x3e,0x0,0x3e,0x1f,0x0,0xff,0xff,0xff,
0xff,0xfc,0x7e,0x7c,0x7f,0xfe,0x7c,0x0,0x3e,0x0,0x3e,0x1f,0x0,0xff,0xff,0xff
};

[...]


//display image
display.cleardisplay();  
display.drawbitmap( 0, 0, code, 124, 31, 1);
display.display();
delay(40000);



however image around 64 (i assume 62) pixel wide instead of 31, should have:



this how expected output (photoshopped):



any idea did go wrong?
i play around different (incorrect) inputs drawbitmap() function, far no success.

many thanks!

is factor 2 scaling
or
are there empty lines in logo ? (seems so)

to confirm latter can make image 120 x 31 , give try?
it might processing last byte of line algorithm adds 1 line count incorrectly.


Arduino Forum > Using Arduino > Displays > SSD1306 OLED Adafruit Libary - drawBitmap() function stretches image


arduino

Comments