I would like to draw a bitmap, manually specifying colour of every point of it (in other words, the task is to save a 2D array of RGB values to a PNG (or some other lossless true-colour bitmap format) file).
It would be also nice to have a function to print some text (with a given font of a given size) pieces on top of the image at given coordinates.
How to implement this?
You can use the Java standard library
ImageIOclass. It offers a staticwritemethod that can, for example, encode and write aRenderedImageto an output stream in PNG format. For theRenderedImage, you can easily use theBufferedImageclass. It offers asetRGBmethod for directly manipulating the colors of individual pixels. Alternatively, you can also callBufferedImage.getGraphics(), which returns an instance ofGraphicsthat you can draw any kind of shape or text on, or even whole GUI components, just like with any AWT component.This is regular Java stuff. Scala does not offer any special wrappers for that, and I also doubt it would be worth the effort.