开发者

Drawing text on a Bitmap (rather than Canvas) [closed]

开发者 https://www.devze.com 2023-01-31 21:36 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a speci开发者_Go百科fic moment in time,or an extraordinarily narrow situation that is not gen
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a speci开发者_Go百科fic moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

I am drawing some text on a Canvas, and on a 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 former case, the text renders as you would expect, while in the latter, it appears very rough and ugly. This becomes even more problematic when using e.g.

canvas.drawBitmapMesh(...);

to apply transformations to the bitmap. Am I doing something wrong, or is the quality simply deteriorated when you pass from Canvas to Bitmap?

On a side note, the reason why I'm drawing text on a Bitmap is to obtain a "magnifier" effect on the text in question (like Apple OSX's dock), since I can then apply arbitrary transformations to it using a bitmap mesh. Is there another, perhaps better, way to do this?

Best,

Michael

Edit: Solved. For those interested, the problem seems to occur when using API versions < 4. When using API versions >= 4, everything works.

0

精彩评论

暂无评论...
验证码 换一张
取 消