3
A
回答
4
使用BitmapFactory.decodeByteArray()
獲得Bitmap
,然後使用該位圖上創建一個Canvas
,並繪製文本那裏。最後,通過使用Bitmap.compress()
保存:
Bitmap bmp = BitmapFactory.decodeByteArray(myArray, 0, myArray.length).copy(Bitmap.Config.RGBA_8888, true); //myArray is the byteArray containing the image. Use copy() to create a mutable bitmap. Feel free to change the config-type. Consider doing this in two steps so you can recycle() the immutable bitmap.
Canvas canvas = new Canvas(bmp);
canvas.drawText("Hello Image", xposition, yposition, textpaint); //x/yposition is where the text will be drawn. textpaint is the Paint object to draw with.
OutputStream os = new FileOutputStream(dstfile); //dstfile is a File-object that you want to save to. You probably need to add some exception-handling here.
bmp.compress(CompressFormat.JPG, 100, os); //Output as JPG with maximum quality.
os.flush();
os.close();//Don't forget to close the stream.
2
- 使用BitmapFactory
- 創建Canvas
- 上繪製text解碼字節數組
- Save你的位圖SD storage
希望這有助於。
+2
我喜歡看到人們如何-1這個答案。我猜這是同一種...... emm ......開發者......誰更喜歡Ctrl-C Ctrl-V答案:) – EvilDuck 2014-06-20 19:50:20
相關問題
- 1. 在繪製位圖上繪製文本
- 2. 如何在圖像上下文中繪製圖像和文本?
- 3. 在Android上繪製多個圖像
- 4. 在圖像庫上繪圖文本
- 5. 在android中繪製圖像
- 6. 在繪圖區域上繪製圖像
- 7. Java - 在圖像中心繪製文本
- 8. 在圖像右上角繪製文字
- 9. 在圖像上繪製
- 10. 在圖像上繪製點
- 11. 在android上繪製圖形
- 12. 如何使用ImageMagick將鏡像文本繪製到圖像上?
- 13. python PIL在圖像上繪製多行文本
- 14. 在UIView或UIImageView上繪製文本和圖像?
- 15. 帆布文本不繪製的圖像
- 16. 在SurfaceView上繪製文本
- 17. 在android中的位圖上繪製文本
- 18. 在DrawingContext上繪圖時在圖像上繪製陰影
- 19. startActivity打開圖庫應用程序但不繪製jpg圖像(Android 4.0)?
- 20. 如何繪製圖像上的文字
- 21. 用Matlab在圖上繪製圖像
- 22. 腳本繪製圖像
- 23. Android:繪製很多文本視圖
- 24. 在MFC中繪製JPG
- 25. 從圖像上延伸出的圖像上的文字繪製
- 26. Android將文字繪製到位圖上
- 27. 是否可以在圖像上繪製/繪製並在Android中擦除它?
- 28. 上繪製圖像的OpenCV
- 29. 在Android上的畫布上繪製多個圖像
- 30. android:代表文本中的可繪製圖像發送
檢查我這裏http://stackoverflow.com/questions/6159186/how-do-i-write-text-over-a-picture-in-android-and回答-save-it – MKJParekh 2012-04-24 12:49:22