Drawing text in a bitmap (not canvas)

I draw some text on the canvas and on the bitmap, respectively:

protected void onDraw(Canvas canvas) {
    canvas.drawText("Canvas text", 10, 10, mPaint);
    Canvas singleUseCanvas = new Canvas();
    singleUseCanvas.setBitmap(mBitmap);
    singleUseCanvas.drawText("Bitmap text", 10, 30, mPaint);
}

In the first case, the text is displayed as you expected, while in the latter it looks very rude and ugly. This becomes even more problematic when used, for example,

canvas.drawBitmapMesh(...);

apply transformations to a bitmap. Am I doing something wrong, or is the quality just getting worse when you switch from Canvas to Bitmap?

On the other hand, the reason I draw text in a bitmap is to get a magnifying effect for the text in question (for example, the Apple OSX dock), since I can apply arbitrary transformations to it, using a raster grid. Is there any other, possibly better way to do this?

Best

Michael

: . , , API < 4. API >= 4 .

+3

Source: https://habr.com/ru/post/1781154/


All Articles