This works OK except that the two rightmost columns of pixels always end up filled with a seemingly random, but almost 100% white, pattern, no matter what I try to write into them. Would anyone know what is the matter?
There was no marking on the display as to type (SH1106/SSD1306). I just tried different u8g2 definitions until I got something displayed, and stopped before finding the 100% correct one.
Please post a link to the actual Display that you bought. e.g. Ebay sale page.
Otherwise we can only guess.
0.96 inch are generally SSD1306
1.3 inch are generally SH1106
Some 1.3 inch are SSD1315
1.54 inch are generally SSD1309
2.42 inch are generally SSD1309
Size is not everything !!
We can post a sketch that will behave differently for SH1106, SSD1306, SSD1315, SSD1309
Post a link or photo of the pcb and we can recognise the likely controller.
The colour dithering settings are best chosen by trial and error depending on the image being converted although turning off dithering entirely is often best for images of solid colour blocks!
Perhaps I did not make it clear - the display works perfectly well now that I changed the definition to SH1106.
(I don't have a link for the display, sorry. I have bought a number of these over the last few years, at various places. They all look the same, except sometimes the contacts are labelled GND VCC SCL SDA, and sometimes VCC GND SCL SDA.)