mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-28 12:30:12 +02:00
feat(core/camera_tweaks): black photos
This commit is contained in:
parent
8823093b30
commit
81f626cc3b
@ -434,6 +434,10 @@
|
||||
"name": "Disable Camera",
|
||||
"description": "Prevents Snapchat from using the cameras available on your device"
|
||||
},
|
||||
"black_photos": {
|
||||
"name": "Black Photos",
|
||||
"description": "Replaces captured photos with a black background\nVideos are not affected"
|
||||
},
|
||||
"immersive_camera_preview": {
|
||||
"name": "Immersive Preview",
|
||||
"description": "Prevents Snapchat from Cropping the Camera preview\nThis might cause the camera to flicker on some devices"
|
||||
|
@ -40,6 +40,7 @@ class Camera : ConfigContainer() {
|
||||
|
||||
val disable = boolean("disable_camera")
|
||||
val immersiveCameraPreview = boolean("immersive_camera_preview") { addNotices(FeatureNotice.UNSTABLE) }
|
||||
val blackPhotos = boolean("black_photos")
|
||||
val overridePreviewResolution get() = _overridePreviewResolution
|
||||
val overridePictureResolution get() = _overridePictureResolution
|
||||
val customFrameRate = unique("custom_frame_rate",
|
||||
|
@ -4,9 +4,11 @@ import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ContextWrapper
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Bitmap
|
||||
import android.hardware.camera2.CameraCharacteristics
|
||||
import android.hardware.camera2.CameraCharacteristics.Key
|
||||
import android.hardware.camera2.CameraManager
|
||||
import android.media.Image
|
||||
import android.util.Range
|
||||
import me.rhunk.snapenhance.core.features.Feature
|
||||
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||
@ -15,6 +17,8 @@ import me.rhunk.snapenhance.core.util.hook.hook
|
||||
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
||||
import me.rhunk.snapenhance.core.util.ktx.setObjectField
|
||||
import me.rhunk.snapenhance.core.wrapper.impl.ScSize
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class CameraTweaks : Feature("Camera Tweaks", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
||||
|
||||
@ -71,5 +75,20 @@ class CameraTweaks : Feature("Camera Tweaks", loadParams = FeatureLoadParams.ACT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context.config.camera.blackPhotos.get()) {
|
||||
findClass("android.media.ImageReader\$SurfaceImage").hook("getPlanes", HookStage.AFTER) { param ->
|
||||
val image = param.thisObject() as? Image ?: return@hook
|
||||
val planes = param.getResult() as? Array<*> ?: return@hook
|
||||
val output = ByteArrayOutputStream()
|
||||
Bitmap.createBitmap(image.width, image.height, Bitmap.Config.ARGB_8888).apply {
|
||||
compress(Bitmap.CompressFormat.JPEG, 100, output)
|
||||
recycle()
|
||||
}
|
||||
planes.filterNotNull().forEach { plane ->
|
||||
plane.setObjectField("mBuffer", ByteBuffer.wrap(output.toByteArray()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user