SSD1306 OLED Adafruit Libary - drawBitmap() function stretches image

Hi there!

So I bought myself a cheap SSD1306 I2C 128x64 OLED display and downloaded the appropriate libraries from Adafruit:

The example sketch worked without a problem and is not stretched.

So I decided to display a own image. I created a 124x31 pixel bmp which I converted using the Img2Code Java programm form the Adafruit-GFX-Library:

I added the code as an array to the sample sketch and used the display.drawBitmap( 0, 0, code, 124, 31, 1); function, which to my understand has the correct input: offset 0,0 width: 124, height: 31

//save the image as 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,0x0,0x0,0x0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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 the image
display.clearDisplay();  
display.drawBitmap( 0, 0, code, 124, 31, 1);
display.display();
delay(40000);

However what I get is that the image is around 64 (I assume 62) pixel wide instead of the 31, which it should have:

This is how I expected the output to be (photoshopped):

Any idea where I did go wrong?
I already play around with different (incorrect) inputs for the drawBitmap() function, but so far no success.

Many thanks!

is it a factor 2 scaling
OR
are there empty lines in the logo ? (seems so)

To confirm the latter can you make the image 120 x 31 and give it a try?
it might be that by processing the last byte of a line the algorithm adds 1 to the line count incorrectly.

Good to hear you solved it !