我在 ImageView
上放置了 EditText
和 ImageView
。我希望 EditText
上的书面文字是 ImageView
的一部分,作为单个图像(位图),因为它在写入时显示。我尝试过使用 canvas.drawText(...)
,但在撰写时却看不清楚。
更新:: 已解决...以下答案
答案 0 :(得分:2)
以下是我解决这个问题的方法。如果我想要的图像是:
然后解决方案将是:
/**
* Merging Two Images into One Image.
* @param baseImage Bitmap as Lower Image , Image to be appeared underneath.
* @param headerImage Bitmap as Upper Image, Image to be appeared upon the lower image.
* @return finalImage Bitmap as bytes having both images merged.
*/
public static byte[] mergeImages(Bitmap baseImage, Bitmap headerImage, Bitmap footerImage ) {
Bitmap finalImage = Bitmap.createBitmap(baseImage.getWidth(), baseImage.getHeight(), baseImage.getConfig());
Canvas canvas = new Canvas(finalImage);
canvas.drawBitmap(baseImage, new Matrix(), null);
if(headerImage != null){
canvas.drawBitmap(headerImage, new Matrix(), null);
}
if(footerImage != null){
Matrix matrix = new Matrix();
matrix.setTranslate(0, baseImage.getHeight() - footerImage.getHeight());
canvas.drawBitmap(footerImage, matrix, null);
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
finalImage.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] bytes = stream.toByteArray();
return bytes;
}
答案 1 :(得分:0)
一旦我做了类似的东西,你就是在努力。我使用Textview来做到这一点。我分别设置了它的背景资源和文本。
dat <- data.frame(one="\r\n Something", two="\n\n\n another one"