zoukankan      html  css  js  c++  java
  • Android 画文字图

    画图

    private Bitmap getbitmap(String content) {
    Bitmap bitmap = Bitmap.createBitmap(400, 400, Bitmap.Config.ARGB_8888);//创建一个宽度和高度都是400、32位ARGB图
    Canvas canvas = new Canvas(bitmap);//初始化画布绘制的图像到icon上
    canvas.drawColor(Color.WHITE);
    /* Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);//创建画笔
    paint.setTextSize(50.0f);//设置文字的大小
    paint.setTypeface(Typeface.DEFAULT_BOLD);//文字的样式(加粗)
    paint.setColor(Color.GRAY);//文字的颜色
    canvas.drawText(content, 10, 200, paint);//将文字写入。这里面的(120,130)代表着文字在图层上的初始位置
    canvas.save(canvas.ALL_SAVE_FLAG);//保存所有图层
    canvas.restore();*/

    TextPaint textPaint = new TextPaint();
    textPaint.setColor(Color.GRAY);
    textPaint.setTextSize(50.0F);
    StaticLayout layout = new StaticLayout(content,textPaint,400, Layout.Alignment.ALIGN_NORMAL,1.0F,0.0F,true);
    canvas.save();
    canvas.translate(10, 150);
    layout.draw(canvas);
    canvas.restore();

    return bitmap;
    }
  • 相关阅读:
    CF763C Timofey and Remoduling
    CF762E Radio Stations
    CF762D Maximum Path
    CF763B Timofey and Rectangles
    URAL1696 Salary for Robots
    uva10884 Persephone
    LA4273 Post Offices
    SCU3037 Painting the Balls
    poj3375 Network Connection
    Golang zip压缩文件读写操作
  • 原文地址:https://www.cnblogs.com/guoke-jsp/p/5114119.html
Copyright © 2011-2022 走看看