I do some tests on drawing text on path. I made a background picture by setting bitmap to canvas. Then, I draw text on path to canvas, rotated by matrix. I have to shorten the code, I will only post the important part, because it is too long.This images shown below are cropped with gimp, so don´t be irritated by the different sizes. My Rect,Path and Matrix objects:
RectF drawTextOval;
Path drawTextPath;
Matrix mDrawnMatrix;
Now, this is what I am doin to draw text on circle path:
drawTextOval.set(drawTextPosX - drawTextArc, drawTextPosY
- drawTextArc, drawTextPosX + drawTextArc, drawTextPosY
+ drawTextArc);
drawTextPath.addArc(drawTextOval, 0, 360);
drawTextPath.computeBounds(drawTextOval, true);
mDrawnMatrix.postRotate(drawTextArcStart,
(drawTextOval.right + drawTextOval.left) / 2,
(drawTextOval.bottom + drawTextOval.top) / 2);
drawTextPath.transform(mDrawnMatrix);
patternCanvas.drawTextOnPath(drawText, drawTextPath, 0, 0,
mFixedTextPaint);
Until this point, everything looks fine:
But after saving the whole screen, the rotated text looks warped at the saved .png image. All the other components looking good. I made some other drawings with text, linear or angular, all this works. Even some .png bitmaps drawing to canvas and the background image...all is looking normally. But the on circle path drawn text looks like this:
I don´t do any scaling on the bitmap, just saving the canvas image with:
FileOutputStream fos = new FileOutputStream(saveFile);
this.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
Bitmap bitmap = this.getDrawingCache();
bitmap.compress(CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
Why does the text look warped? Does anyone see my mistake? Thanks in advance....
EDIT
I tried some stuff and find out that setting anyDensity to false or disable hardware acceleration in Manifest will show the effect at runtime before saving. That suggests to me, that when saving bitmap with getDrawingCache(), the scaling is disabled at this time. But why?
The last thing I found out, that the lower the curvature the lower is the text scaling. If the text is just a little bit curved, it seems good.
I would try setting the
before drawing to screen, since lower quality might imply a simpler transformation of the text. This is just guessing of course. Currently your only setting the high quality before writing to disk. Or simply remove it from the write to disk method to check if it affect the way the text is drawn.