如何编辑图像例如这成为机器人的图像部分的图像上永久添加文字? [英] How to edit image for e.g. permanently adding text on the image which becomes the part of that image in android?
问题描述
我有以下要求 我曾在我的Android手机中的图像。 现在我想编辑这个形象在这样一种方式,它成为我的形象的一部分 对于例如,说我想如日期在图像上书写文字时,编辑和图像,我会给写一个名字。 现在保存的图像,现在,如果我打开该影像再次,我已经写了也将被显示,因为现在它变成我的形象的一部分的文本。(这有点像我们做什么,它在Photoshop) 我希望我的要求是很清楚的。 我搜索上的计算器,但没有得到任何适当的工作方式做。 我只找到文本覆盖在编辑这不是实际的图像的图像。 谢谢大家谁将会试图解决我的查询。
I have following requirement i have a image in my android phone. now i want to edit this image in such a way that it becomes the part of my image for e.g., say i want to write text on the image like date when it is edited and write a name on the image which i will give. now save that image and now if i open that image again the text which i have written will also be shown because now it becomes the part of my image.(This something like what we do it in photoshop) i hope my requirement is very clear. i searched on the stackoverflow but didnt get any proper working way to do. i only found the image with text overlayed on that not actual image edited. thank you all who will try to solve my query.
推荐答案
您应该打开图像作为位图
并用画布上编辑
然后只需将它保存到SD卡。
You should open the image as a Bitmap
and edit it with a canvas
then just save it to the SDcard.
in = new FileInputStream("/sdcard/test2.png");
buf = new BufferedInputStream(in);
Bitmap bMap = BitmapFactory.decodeStream(buf);
然后将其分配到画布上:
Then assign it to a canvas:
Canvas myCanvas = new Canvas(bMap);
编辑!显然,你必须改变之前,使位图的副本:看这个问题的详细信息:的加载资源,以一个可变的位图
要画你需要一个油漆在画布上的文字或其他任何东西。
To draw text or anything else on a canvas you need a paint.
Paint myPaint = new Paint();
myPaint.setColor(Color.Black);
myPaint.setTextSize(25);
myCanvas.drawText("Your text", positionX, positionY, myPaint); //Set the position where you like
然后保存您的图片
Then you save your image
try {
FileOutputStream out = new FileOutputStream("Your filename");
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
参考文献:
- http://developer.android.com/reference/android/graphics/Canvas.html
- Android : Bitmap save to location
这篇关于如何编辑图像例如这成为机器人的图像部分的图像上永久添加文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!