텍스트가있는 비트 맵을 만들었습니다. 이미지 뷰에서 볼 수 있지만 비트 맵을 저장할 때 검정색 이미지 만 나타납니다. 나는 비슷한 질문을 보면서 3 시간을 보냈지 만 나를 위해 일한 것은 하나도 없다. 여기에 코드가 있습니다. 도움 주셔서 감사합니다.저장된 비트 맵이 검정색입니다
public void createBitmap(){
Bitmap LabelBitmap;
FileOutputStream fos = null;
//create Text Bitmap
LabelBitmap = textAsBitmap(this,"BRO D 0813","fonts/arialbd.ttf", 4, Color.BLACK);
//load bitmap in to Imageview
ImageView myImageView = (ImageView) findViewById(R.id.imageView);
myImageView.setImageBitmap(LabelBitmap);
// save bitmap
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/myfolder");
myDir.mkdirs();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
LabelBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
if (!myDir.exists()) {
myDir.mkdir();
}
File myDirFile = new File(root +"/myfolder/mybitmap.jpg");
try {
if(myDirFile.exists()){
myDirFile.delete();
}
myDirFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
try {
fos = new FileOutputStream(myDirFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
fos.write(bytes.toByteArray());
fos.flush();
fos.close();
Toast.makeText(this, "Image saved", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}
이 봐,이 말 http://stackoverflow.com/questions/8799290에 캔버스와 같은 결과를 사용하고/convert-string-text-to-bitmap – Yurets