我试图通过将位图转换为字节数组然后将字节数组转换为String来设置OCR功能..这就是我尝试过的方法
{
mBitmap = Bitmap.createBitmap (mContent.getWidth(), mContent.getHeight(), Bitmap.Config.RGB_565);
img.setImageBitmap(mBitmap);
}
Canvas canvas = new Canvas(mBitmap);
try
{
FileOutputStream mFileOutStream = new FileOutputStream(mypath);
img.setImageBitmap(mBitmap);
v.draw(canvas);
mBitmap.compress(Bitmap.CompressFormat.PNG, 90, mFileOutStream);
ByteArrayOutputStream boas = new ByteArrayOutputStream();
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, boas);
byte[] b = boas.toByteArray();
String str3=b.toString();
Log.i("string ", "***** "+str3);
String str = Base64.encodeToString(b, Base64.DEFAULT);
txt.setText("STR "+str);
Log.i("string ", "****str***** "+str);
String str2 = new String(b,"UTF-8");
Log.i("string ", "****str***** "+str2);
mFileOutStream.flush();
mFileOutStream.close();
String url = Images.Media.insertImage(getContentResolver(), mBitmap, "title", null);
Log.v("log_tag","url: " + url);
}
但我得到的结果是非常相关