我想在图像上绘制文本(用于保存带有文本的图像)。我有图像视图我将位图设置为该图像我想绘制图像上的文本(用户输入的文本)。我在保存前尝试这个.....如何在图片上绘制文字?
void saveImage() {
File myDir=new File("/sdcard/saved_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-"+ n +".jpg";
File file = new File (myDir, fname);
if (file.exists()) file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
originalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
XML代码..
<FrameLayout
android:id="@+id/framelayout"
android:layout_marginTop="30dip"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<ImageView
android:id="@+id/ImageView01"
android:layout_alignParentTop="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
<TextView android:id="@+id/text_view2"
android:layout_marginTop="20dip"
android:layout_width="wrap_content"
android:text="SampleText"
android:textSize="12pt"
android:layout_alignTop="@+id/ImageView01"
android:layout_height="wrap_content"/>
</FrameLayout>
到底什么是你的问题?您是否无法绘制文字或无法使用文字保存图像? – blessenm
我的问题是我想在图像上添加文字。 –