1package com.android.rs.refocus; 2 3import android.content.Context; 4import android.graphics.Bitmap; 5import android.graphics.BitmapFactory; 6import android.net.Uri; 7 8 9import android.os.AsyncTask; 10import android.support.v8.renderscript.Allocation; 11import android.support.v8.renderscript.RenderScript; 12 13import java.io.IOException; 14import java.io.InputStream; 15 16/** 17 * Created by hoford on 5/15/15. 18 */ 19public class DepthImage { 20 private final String mFormat; 21 private final double mFar; 22 private final double mNear; 23 private final Bitmap mDepthBitmap; 24 private final double mBlurAtInfinity; 25 private final double mFocalDistance; 26 private final double mDepthOfFiled; 27 private final double mFocalPointX; 28 private final double mFocalPointY; 29 private final DepthTransform mDepthTransform; 30 public DepthImage(Context context, Uri data) throws IOException { 31 InputStream input = context.getContentResolver().openInputStream(data); 32 XmpDepthDecode decode = new XmpDepthDecode(input); 33 mFormat = decode.getFormat(); 34 mFar = decode.getFar(); 35 mNear = decode.getNear(); 36 mDepthBitmap = decode.getDepthBitmap(); 37 mBlurAtInfinity = decode.getBlurAtInfinity(); 38 mFocalDistance = decode.getFocalDistance(); 39 mDepthOfFiled = decode.getDepthOfField(); 40 mFocalPointX = decode.getFocalPointX(); 41 mFocalPointY = decode.getFocalPointY(); 42 input = context.getContentResolver().openInputStream(data); 43 mDepthTransform = decode.getDepthTransform(); 44 } 45 46 public Bitmap getDepthBitmap() { 47 return mDepthBitmap; 48 } 49 50 public DepthTransform getDepthTransform() { return mDepthTransform; } 51 52 public String getFormat() { 53 return mFormat; 54 } 55 56 public double getFar() { 57 return mFar; 58 } 59 60 public double getNear() { 61 return mNear; 62 } 63 64 public double getBlurAtInfinity() { 65 return mBlurAtInfinity; 66 } 67 68 public double getFocalDistance() { 69 return mFocalDistance; 70 } 71 72 public double getDepthOfField() {return mDepthOfFiled; } 73 74 public double getFocalPointX() { 75 return mFocalPointX; 76 } 77 78 public double getFocalPointY() { 79 return mFocalPointY; 80 } 81} 82 83