You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Camera API in Android is hard. Having 2 different API for new and old Camera does not make things any easier. But fret not, that is your lucky day! After several years of working with Camera, we came up with Fotoapparat.
9
8
10
9
What it provides:
10
+
11
11
- Camera API which does not allow you to shoot yourself in the foot.
12
12
- Simple yet powerful parameters customization.
13
13
- Standalone custom `CameraView` which can be integrated into any `Activity`.
14
14
- Fixes and workarounds for device-specific problems.
15
15
- Both Kotlin and Java friendly configurations.
16
-
- Last, but not least, non 0% test coverage.
17
-
16
+
- Last, but not least, non 0% test coverage.
18
17
19
18
Taking picture becomes as simple as:
20
19
@@ -23,9 +22,9 @@ val fotoapparat = Fotoapparat(
23
22
context =this,
24
23
view = cameraView
25
24
)
26
-
25
+
27
26
fotoapparat.start()
28
-
27
+
29
28
fotoapparat
30
29
.takePicture()
31
30
.saveToFile(someFile)
@@ -48,7 +47,7 @@ Add `CameraView` to your layout
48
47
49
48
Configure `Fotoapparat` instance.
50
49
51
-
```kotlin
50
+
```kotlin
52
51
Fotoapparat(
53
52
context =this,
54
53
view = cameraView, // view which will draw the camera preview
Check the [wiki for the `configuration` options e.g. change iso](https://github.com/Fotoapparat/Fotoapparat/wiki/Configuration-Kotlin)
66
66
67
67
Are you using Java only? See our [wiki for the java-friendly configuration](https://github.com/Fotoapparat/Fotoapparat/wiki/Configuration-Java).
68
68
69
-
70
69
### Step Three
71
70
72
71
Call `start()` and `stop()`. No rocket science here.
@@ -76,7 +75,7 @@ override fun onStart() {
76
75
super.onStart()
77
76
fotoapparat.start()
78
77
}
79
-
78
+
80
79
overridefunonStop() {
81
80
super.onStop()
82
81
fotoapparat.stop()
@@ -89,30 +88,30 @@ Finally, we are ready to take a picture. You have various options.
89
88
90
89
```kotlin
91
90
val photoResult = fotoapparat.takePicture()
92
-
91
+
93
92
// Asynchronously saves photo to file
94
93
photoResult.saveToFile(someFile)
95
-
94
+
96
95
// Asynchronously converts photo to bitmap and returns the result on the main thread
97
96
photoResult
98
97
.toBitmap()
99
98
.whenAvailable { bitmapPhoto ->
100
99
val imageView = (ImageView) findViewById(R.id.result)
// all the parameters available in CameraConfiguration
127
+
// all the parameters available in CameraConfiguration
129
128
)
130
129
)
131
130
```
132
131
133
-
Or alternatively, you may provide updates on an existing full configuration.
132
+
Or alternatively, you may provide updates on an existing full configuration.
134
133
135
134
```kotlin
136
135
val configuration =CameraConfiguration(
137
136
// A full configuration
138
137
// ...
139
138
)
140
-
139
+
141
140
fotoapparat.updateConfiguration(
142
141
configuration.copy(
143
142
flashMode =if (isChecked) torch() else off()
144
-
// all the parameters available in CameraConfiguration
143
+
// all the parameters available in CameraConfiguration
145
144
)
146
145
)
147
146
```
@@ -162,7 +161,7 @@ fotoapparat.switchTo(
162
161
Add dependency to your `build.gradle`
163
162
164
163
```groovy
165
-
implementation 'io.fotoapparat:fotoapparat:2.6.0'
164
+
implementation 'io.fotoapparat:fotoapparat:2.6.1'
166
165
```
167
166
168
167
Camera permission will be automatically added to your `AndroidManifest.xml`. Do not forget to request this permission on Marshmallow and higher.
@@ -171,14 +170,12 @@ Camera permission will be automatically added to your `AndroidManifest.xml`. Do
171
170
172
171
Optionally, you can check out our other library which adds face detection capabilities - [FaceDetector](https://github.com/Fotoapparat/FaceDetector).
173
172
174
-
175
173
## Credits
176
174
177
175
We want to say thanks to [Mark Murphy](https://github.com/commonsguy) for the awesome job he did with [CWAC-Camera](https://github.com/commonsguy/cwac-camera). We were using his library for a couple of years and now we feel that Fotoapparat is a next step in the right direction.
178
176
179
177
We also want to say many thanks to [Leander Lenzing](http://leanderlenzing.com/) for the amazing icon. Don't forget to follow his work in [dribbble](https://dribbble.com/leanderlenzing).
0 commit comments