Esempio n. 1
0
    @Override
    public synchronized void saveRequest() {
      if (mData == null) {
        Log.w(TAG, "[saveRequest]mData is null,return!");
        return;
      }
      int orientation = Exif.getOrientation(mData);
      // M: ConShots
      mGroupId = Exif.getGroupId(mData);
      mGroupIndex = Exif.getGroupIndex(mData);
      mFocusValueHigh = Exif.getFocusValueHigh(mData);
      mFocusValueLow = Exif.getFocusValueLow(mData);
      mOrientation = orientation;
      mDataSize = mData.length;

      if (null != mFileName) {
        mTitle = mFileName.substring(0, mFileName.indexOf('.'));
      } else {
        mTitle = createName(mFileType, mDateTaken, mGroupIndex);
        mFileName = Storage.generateFileName(mTitle, mTempPictureType);
        Log.i(TAG, "[saveRequest]PhotoOperator,mFileName = " + mFileName);
      }
      mFilePath = Storage.generateFilepath(mFileName);
      mTempFilePath = mFilePath + TEMP_SUFFIX;
      saveImageToSDCard(mTempFilePath, mFilePath, mData);
      // camera decouple
      mMimeType = Storage.generateMimetype(mTitle, mTempPictureType);
      checkDataProperty();
      saveImageToDatabase(this);
    }
Esempio n. 2
0
 @Override
 public void prepareRequest() {
   Log.i(TAG, "[prepareRequest]PanoOperator,mFileName = " + mFileName);
   mFileType = Storage.FILE_TYPE_PANO;
   mDateTaken = System.currentTimeMillis();
   Location loc = mContext.getLocationManager().getCurrentLocation();
   if (loc != null) {
     mLocation = new Location(loc);
   }
   mTitle = createName(mFileType, mDateTaken, 0);
   mFileName = Storage.generateFileName(mTitle, mTempPictureType);
   mFilePath = Storage.generateFilepath(mFileName);
   mTempFilePath = mFilePath + TEMP_SUFFIX;
 }
Esempio n. 3
0
    @Override
    public void saveRequest() {
      // title, file path, temp file path is ready
      FileOutputStream out = null;
      try {
        // Write to a temporary file and rename it to the final name.
        // This
        // avoids other apps reading incomplete data.
        out = new FileOutputStream(mTempFilePath);
        out.write(mData);
        out.close();
        new File(mTempFilePath).renameTo(new File(mFilePath));
      } catch (IOException e) {
        Log.e(TAG, "[saveRequest]PanoOperator,Failed to write image", e);
      } finally {
        if (out != null) {
          try {
            out.close();
          } catch (IOException e) {
            Log.e(TAG, "[saveRequest]PanoOperator,exception:", e);
          }
        }
      }
      mDataSize = new File(mFilePath).length();
      try {
        ExifInterface exif = new ExifInterface(mFilePath);
        int orientation = Util.getExifOrientation(exif);
        int width = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0);
        int height = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0);
        mWidth = width;
        mHeight = height;
        mOrientation = orientation;
      } catch (IOException ex) {
        Log.e(TAG, "[saveRequest]PanoOperator,cannot read exif:", ex);
      }
      if (null == mFileName) {
        mTitle = createName(mFileType, mDateTaken, mGroupIndex);
        mFileName = Storage.generateFileName(mTitle, mTempPictureType);
        Log.i(TAG, "[saveRequest]PhotoOperator,mFileName = " + mFileName);
      }
      mMimeType = Storage.generateMimetype(mTitle, mTempPictureType);

      saveImageToDatabase(this);
    }