我正在使用tess-two库,我希望将我图像中除黑色之外的所有颜色转换为白色(黑色将是文本).从而使tess-two更容易阅读文本.我已经尝试了各种方法,但是他们花费了太多时间,因为它们逐像素地转换.有没有办法使用画布或任何能够更快地提供结果的东西来实现这一点.
该算法提出的另一个问题是打印机不能使用与Android中相同的BLACK和White打印.因此算法将整个图像转换为白色.
我目前使用的逐像素方法.
binarizedImage = convertToMutable(cropped);// the bitmap is made mutable
int width = binarizedImage.getWidth();
int height = binarizedImage.getHeight();
int[] pixels = new int[width * height];
binarizedImage.getPixels(pixels, 0, width, 0, 0, width, height);
for(int i=0;i<binarizedImage.getWidth();i++) {
for(int c=0;c<binarizedImage.getHeight();c++) {
int pixel = binarizedImage.getPixel(i, c);
if(!(pixel == Color.BLACK || pixel == Color.WHITE))
{
int index = c * width + i;
pixels[index] = Color.WHITE;
binarizedImage.setPixels(pixels, 0, width, 0, 0, width, height);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有2个应用程序.第二个应用程序通过内容提供商与第一个应用程序交互以获取一些凭据.今天在Playstore上传我的apk时出现错误-SQL注入您的应用程序正在使用包含SQL注入漏洞的内容提供程序.要解决此问题,请按照此Google帮助中心文章中的步骤操作.
现在我执行了文章中提到的所有步骤,但仍然得到相同的错误.具体步骤如下:
如果受影响的ContentProvider需要向其他应用程序公开:
您可以通过使用
带投影映射的严格模式来阻止SQL注入SQLiteDatabase.query .严格模式可防止
恶意选择条款和投影图防止
恶意投影条款.您必须使用这两个功能才能确保查询安全.
您可以通过使用使用'?'的选择子句来阻止SQL注入SQLiteDatabase.update和SQLiteDatabase.delete 作为可替换参数和单独的选择参数数组.您的选择条款不应由不受信任的输入构成.
我的SQLiteQueryBuilder有set strict = true和投影映射.
private static final HashMap<String,String> values;
static {
values = new HashMap<String, String>();
values.put("_id", "_id");
values.put("name", "name");
}
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(TABLE_NAME);
qb.setStrict(true);
switch (uriMatcher.match(uri)) {
case uriCode:
qb.setProjectionMap(values);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
if (sortOrder == null || …
Run Code Online (Sandbox Code Playgroud) 虽然我一直在四处寻找,但找不到正确的答案.在我的导航抽屉标题中,我向用户提供了他的图像和名称,但我也允许用户从应用程序中更改他/她的名字和图像.这些更改存储在会话管理器中.现在我想在导航抽屉标题中反映这些变化.一切都运行正常,因为当我关闭应用程序并再次运行它时,它会显示更改.所以现在我需要的是一种刷新导航抽屉头的方法.
从Profile Fragment中的库中选择图像.
private void onSelectFromGalleryResult(Intent data) {
String selectedImagePath = getPathFromCameraData(data, getActivity());
Bitmap bm;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(selectedImagePath, options);
final int REQUIRED_SIZE = 200;
int scale = 1;
while (options.outWidth / scale / 2 >= REQUIRED_SIZE
&& options.outHeight / scale / 2 >= REQUIRED_SIZE)
scale *= 2;
options.inSampleSize = scale;
options.inJustDecodeBounds = false;
bm = BitmapFactory.decodeFile(selectedImagePath, options);
bitmap = bm;
profilephoto = BitMapToString(bm);
session.setprofilepic(profilephoto);// make changes in session.
profilepic.setImageBitmap(bm);
}
Run Code Online (Sandbox Code Playgroud)
主页活动
@Override
protected void …
Run Code Online (Sandbox Code Playgroud)