我编写了一个示例应用程序,它允许 Android 用户拍照并将视图中的文本内容作为图像的叠加层并保存到图库相册中:
我想要的是在加入两个图像之前转换文本位图。具体来说,我想使文本曲线在两侧向上(模拟环绕圆柱体),并使其顶部比底部大(模拟自上而下的透视),如下所示:
无需解释相机图像即可确定曲率或透视变化量。问题是如何操作位图以便可以进行两个转换。
这是我用来将未转换的文本放入相机图像和图库的代码:
private void combinePictureWithText(String fileName) {
Log.v(TAG, "combinePictureWithText");
int targetW = getWindowManager().getDefaultDisplay().getWidth();
int targetH = getWindowManager().getDefaultDisplay().getHeight();
/* Get the size of the image */
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(fileName, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
/* Figure out which way needs to be reduced less */
int scaleFactor = 1;
if ((targetW > 0) || (targetH > 0)) {
scaleFactor = Math.min(photoW/targetW, photoH/targetH);
}
Log.v(TAG, "Scale Factor: " …Run Code Online (Sandbox Code Playgroud)