Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QtExifDataHandler.java
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3package org.qtproject.qt.android.multimedia;
4
5import android.hardware.camera2.CaptureResult;
6import android.media.ExifInterface;
7import android.os.Build;
8import android.util.Log;
9
10import java.io.IOException;
11
12public class QtExifDataHandler {
13
14 private int mFlashFired = 0;
15 private long mExposureTime = 0L;
16 private float mFocalLength = 0;
17 private static String mModel = Build.MANUFACTURER + " " + Build.MODEL;
18
19 public QtExifDataHandler(CaptureResult r)
20 {
21 Integer flash = r.get(CaptureResult.FLASH_STATE);
22 if (flash != null && flash == CaptureResult.FLASH_STATE_FIRED)
23 mFlashFired = 1;
24
25 Long exposureTime = r.get(CaptureResult.SENSOR_EXPOSURE_TIME);
26 if (exposureTime != null)
27 mExposureTime = exposureTime/1000000000;
28 mFocalLength = r.get(CaptureResult.LENS_FOCAL_LENGTH);
29 }
30
31 public void save(String path)
32 {
33 ExifInterface exif;
34 try {
35 exif = new ExifInterface(path);
36 } catch ( IOException e ) {
37 Log.e("QtExifDataHandler", "Cannot open file: " + path + "\n" + e);
38 return;
39 }
40 exif.setAttribute(ExifInterface.TAG_FLASH, String.valueOf(mFlashFired));
41 exif.setAttribute(ExifInterface.TAG_EXPOSURE_TIME, String.valueOf(mExposureTime));
42 exif.setAttribute(ExifInterface.TAG_FOCAL_LENGTH, String.valueOf(mFocalLength));
43 exif.setAttribute(ExifInterface.TAG_MODEL, mModel);
44
45 try {
46 exif.saveAttributes();
47 } catch ( IOException e ) {
48 Log.e("QtExifDataHandler", "Cannot save file: " + path + "\n" + e);
49 }
50 }
51}
GLboolean r
[2]
GLsizei const GLchar *const * path