1

I have a background bitmap if you will and I'm drawing another bitmap with font into the background bitmap. When just drawn on top of each other and zoomed in the level I'm needing they appear perfectly without artifacting and exactly how I want it. But for my purpose I'm needing to merge the font bitmap into the background bitmap so it essentially becomes one item. I obviously need it to be done at run-time and the solution I'm using is this....

canvas2 = new Canvas(backgroundBitmap);
canvas2.drawBitmap(fontBitmap.getBitmap(), null, rects.get(backgroundRectIndex), null);
invalidate();

Now when I zoom into the level I'm needing the font has artifacting. I'm fairly new to graphics and have read several articles and questions about similar issues and I've tried playing with the dithering in the paint and using it in canvas2.drawBitmap instead of null, but nothing seems to be helping. I came across this...

This does not apply for the case that an application creates an in-memory bitmap internally and draws something on it, for later display on the screen. The platform auto-scales such bitmaps on the fly, at draw time. Other side effects of such a case might be that fonts drawn in such a bitmap will be scaled at the bitmap level, when the off-screen bitmap is finally rendered to the display, resulting in scaling artifacts.

link text

Which sounds like it might be my issue, but how do I resolve that? Any help would be much appreciated.

skaffman
  • 398,947
  • 96
  • 818
  • 769
honeal
  • 1,700
  • 2
  • 13
  • 15
  • After playing around a bit more with the background image, I found that increasing it's dimensions removed the majority of the artifacts. I'm not completely certain as to why this would help because I would essentially be removing the same number of pixels when down-scaling the font image alone, yet it appears fine when enlarged again. I don't know, but this will currently be my work around. – honeal Jan 23 '11 at 16:44

1 Answers1

1

If you're scaling the bitmap, make sure to set the filterBitmap flag off.

On the paint it should be:

paint.setFilterBitmap(false);
Kleptine
  • 5,089
  • 16
  • 58
  • 81
  • Should it be off for both the background image and font image or just the background or just the font? When applied to both it actually gives me a worse result. – honeal Jan 23 '11 at 04:33
  • I would try it on the paint you're using to draw the font. Looking at your code above, it's being passed as null. – Kleptine Jan 23 '11 at 05:42
  • It's just a guess, though. How are you zooming in? Are you transforming the surface's Canvas? – Kleptine Jan 23 '11 at 05:44
  • Same result as before, unfortunately. I'm zooming using source and destination Rects. – honeal Jan 23 '11 at 06:02
  • If you're drawing to a bitmap and then scaling the background bitmap, you're going to have artifacts. I'm not quite sure though, I'd have to know more about the specific rendering process you're using. – Kleptine Jan 24 '11 at 04:55