android - Rotate text when drawing it on a bitmap -
i want rotate text 180 degrees when drawing on bitmap. bitmap rotated there nothing else drawn on other text. isn't clear me though should using in code below rotate text: imageview, canvas, paint, bitmap???
imageview ivimage = (imageview)findviewbyid(r.id.ivimage); displaymetrics metrics = getresources().getdisplaymetrics(); int width = metrics.widthpixels; int height = metrics.heightpixels; bitmap.config conf = bitmap.config.argb_8888; bitmap bitmap = bitmap.createbitmap(width, height, conf); canvas canvas = new canvas(bitmap); paint paint = new paint(paint.anti_alias_flag); paint.setcolor(color.red); paint.settextsize((int) (200 * 1)); // draw text canvas center rect bounds = new rect(); paint.settextalign(align.center); string text = "help"; paint.gettextbounds(text, 0, text.length(), bounds); int x = bitmap.getwidth() / 2; // (bitmap.getwidth() - bounds.width())/2; int y = bitmap.getheight() / 2; // (bitmap.getheight() + bounds.height())/2; canvas.drawtext(text, x * 1, y * 1, paint); ivimage.setimagebitmap(bitmap);
i hope help. how did when creating clock
// save canvas in current state canvas.save(); // rotate canvas around center , draw canvas.rotate(degrees, canvaswidth/2, canvasheigth/2); canvas.drawtext(text, x, y, paint) // restore canvas, rotates original canvas.restore();
Comments
Post a Comment