-
• #2
drawString
usesgraphicsFillRect
because bitmap fonts can be 'scaled' - you can have a bitmap font scaled up by 4x in which case each 'pixel' is a 4x4 rect.For drawing pixel by pixel,
setPixel
is the way to go.However what device are you using InlineC on? For instance on Bangle.js it can make a lot of sense to have an offscreen buffer and to use Inline C to write direct into that buffer, and then use
g.drawImage
to draw that to the screen (drawImage has a special fast path for blits)There's an example of that at https://github.com/espruino/BangleApps/bĀlob/master/apps/geissclk/clock.js
I want to draw bitmap (buffer) data directly with inlineC and noticed that the method Graphics.drawImage() used the setPixel(...) to draw the bitmap (buffer) data at last in jswrap_graphics.c, but the method Graphics.drawString() is called
graphicsFillRect()
andgraphicsFillRectDevice
to draw and returnedreturn gfx->fillRect(gfx, (int)x1, (int)y1, (int)x2, (int)y2, col)
, Why this way? What's the difference between the two and which one is more efficient to draw bitmap data?