我正在处理Android中的AR应用程序,它使用相机输出.我正在研究一部分代码来保存三个图像文件:原始图片,屏幕叠加和叠加绘制的复合图片(可能是多余的,给定其他两个).我相机的原始图像尺寸为2592x1944.
现在我的保存操作比我想要的时间更长.我正在使用AsyncTask进行图片保存,但实际的保存部分归结为以下内容:
public void onPictureTaken(byte[] data, Camera camera){
Size sz = camera.getParameters().getPictureSize();
TimingLogger tl = new TimingLogger("CodeTiming", "Start Saving");
String fileName = getNameFromTime();
tl.addSplit("Start Pic Save");
// The Picture itself
ImageFile photo = new ImageFile(fileName+"_image.jpg");
photo.write(data);
tl.addSplit("Start Overlay Save");
// The overlay with blank background
Bitmap bmp = Bitmap.createBitmap(sz.width,sz.height,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
DrawStuffOnCanvas(canvas);
ImageFile overlay = new ImageFile(fileName+"_overlay.png");
overlay.write(bitmapToByteArray(bmp,Bitmap.CompressFormat.PNG));
tl.addSplit("Start Overlay Onto Pic Save");
// The picture with the overlay drawn on
Options options = new Options();
options.inDither …Run Code Online (Sandbox Code Playgroud)