如何在Java中的图像上书写文字(安卓) [英] How to write text on an image in Java (Android)

查看:430
本文介绍了如何在Java中的图像上书写文字(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在iPhone上的Objective-C的做到这一点,但现在我正在寻找同等的Andr​​oid的Java code。我也可以做到这一点在普通的Java,但我不知道什么是Android的具体类。我想产生的,有一些文字为中心的形象飞PNG图像。

I can do this in Objective-C on the iPhone, but now I'm looking for the equivalent Android Java code. I can also do it in plain Java, but I don't know what the Android specific classes are. I want to generate a PNG image on the fly that has some text centered in the image.

公共无效的createImage(串词,串outputFilePath){/ *我该怎么办吗? * /}

public void createImage(String word, String outputFilePath){ /* what do I do here? */ }

相关主题:

<一个href="http://stackoverflow.com/questions/6992830/how-to-write-text-on-image-in-objective-c-iphone">How写图​​像在Objective-C iPhone文本?

<一个href="http://stackoverflow.com/questions/6540376/how-can-i-load-an-image-and-write-text-to-it-using-java">How我可以加载图像和使用Java写的文字呢?

推荐答案

什么是这样的:

Bitmap bitmap = ... // Load your bitmap here
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(); 
paint.setColor(Color.BLACK); 
paint.setTextSize(10); 
canvas.drawText("Some Text here", x, y, paint);

这篇关于如何在Java中的图像上书写文字(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆