I wanted to convert string of EditText to Bitmap. have a string like this
String str=edtext.getText().toString();
How can i convert that string to bitmap?
I wanted to convert string of EditText to Bitmap. have a string like this
String str=edtext.getText().toString();
How can i convert that string to bitmap?
I dont know about how to make image of that string
but here is code to make Bitmap
from and EditText
So you will get Bitmap image of the whole EditText not only String with this,
mEditText.setCursorVisible(false);
mEditText.buildDrawingCache();
Bitmap bmp = Bitmap.createBitmap(mEditText.getDrawingCache());
I have used the following solution to solve my problem,and this worked for me.
Bitmap bmp = Bitmap.createBitmap(edtext.getDrawingCache());
System.out.println("ashish"+edtext.getText().toString());
Bitmap bm = BitmapFactory.decodeResource(r, R.drawable.balloon_overlay_focused);
Bitmap bmw=combineImages( bm,bmp);
CompositeImageViewText.setImageBitmap(bmw);
//code for combineimages()
public Bitmap combineImages(Bitmap c, Bitmap s) { // can add a 3rd parameter 'String loc' if you want to save the new image - left some code to do that at the bottom
Bitmap cs = null;
int width, height = 0;
if(c.getWidth() > s.getWidth()) {
width = c.getWidth();
height = s.getHeight()+30 ;
} else {
width = s.getWidth();
height = s.getHeight()+30 ;
}
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(c, 0f, 0f, null);
comboImage.drawBitmap(s, 0f, 0f, null);
// this is an extra bit I added, just incase you want to save the new image somewhere and then return the location
/*String tmpImg = String.valueOf(System.currentTimeMillis()) + ".png";
OutputStream os = null;
try {
os = new FileOutputStream(loc + tmpImg);
cs.compress(CompressFormat.PNG, 100, os);
} catch(IOException e) {
Log.e("combineImages", "problem combining images", e);
}*/
return cs;
}
Hope it helps other !
A "bitmap" is the set of pixels that make up an image.
A "string" is a set of characters that make up a word.
The best you can do is read a bitmap, based on the bitmap's file name. That's what Ankit Awasthi illustrated above.
Hopefully that's what you're looking for...