feat: nr off

This commit is contained in:
zhoubinjia committed 2026-01-19 17:36:52 +08:00
1 parent 316582d8c5
commit bf62eb6bd8
12 files changed
+109 -180

No files matched your search

@@ -83,7 +83,7 @@ class Camera2Controller(private val context: Context) {
private var meteringSkipFrames = 0 // Frame skip counter for software metering stabilization
// 软件降噪/锐化设置(true=使用软件算法,false=使用系统算法)
private var useSoftwareProcessing = true
private var nrOff = true
private var useRaw = false
private var cameraThread: HandlerThread? = null
@@ -1133,17 +1133,10 @@ class Camera2Controller(private val context: Context) {
* @param isCapture 是否为拍摄请求(拍摄时使用高质量模式)
*/
private fun applyImageQualitySettings(builder: CaptureRequest.Builder, isCapture: Boolean) {
// Log.d(TAG, "applyImageQualitySettings: ${availableEdgeModes.contentToString()} ${availableNoiseReductionModes.contentToString()}")
try {
if (useSoftwareProcessing) {
// 软件处理模式:关闭系统降噪/锐化,由 LutImageProcessor 软件算法处理
val edgeMode = if (isCapture) {
if (availableEdgeModes.contains(CaptureRequest.EDGE_MODE_OFF)) CaptureRequest.EDGE_MODE_OFF else CaptureRequest.EDGE_MODE_FAST
} else {
CaptureRequest.EDGE_MODE_FAST
}
if (availableEdgeModes.contains(edgeMode)) builder.set(CaptureRequest.EDGE_MODE, edgeMode)
val edgeMode = if (availableEdgeModes.contains(CaptureRequest.EDGE_MODE_OFF)) CaptureRequest.EDGE_MODE_OFF else CaptureRequest.EDGE_MODE_FAST
if (availableEdgeModes.contains(edgeMode)) builder.set(CaptureRequest.EDGE_MODE, edgeMode)
if (nrOff) {
val noiseReductionMode = if (isCapture) {
if (availableNoiseReductionModes.contains(CaptureRequest.NOISE_REDUCTION_MODE_OFF)) CaptureRequest.NOISE_REDUCTION_MODE_OFF else CaptureRequest.NOISE_REDUCTION_MODE_FAST
} else {
@@ -1153,26 +1146,14 @@ class Camera2Controller(private val context: Context) {
CaptureRequest.NOISE_REDUCTION_MODE,
noiseReductionMode
)
if (isCapture) {
PLog.d(TAG, "图像质量设置: 软件处理模式, 锐化=$edgeMode, 降噪=$noiseReductionMode")
}
} else {
// 系统处理模式:使用系统的降噪/锐化算法
val edgeMode =
if (availableEdgeModes.contains(CaptureRequest.EDGE_MODE_ZERO_SHUTTER_LAG)) CaptureRequest.EDGE_MODE_ZERO_SHUTTER_LAG else CaptureRequest.EDGE_MODE_FAST
if (availableEdgeModes.contains(edgeMode)) builder.set(CaptureRequest.EDGE_MODE, edgeMode)
// 系统处理模式:使用系统的降噪算法
val noiseReductionMode =
if (availableNoiseReductionModes.contains(CaptureRequest.NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG)) CaptureRequest.NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG else CaptureRequest.NOISE_REDUCTION_MODE_FAST
if (availableNoiseReductionModes.contains(noiseReductionMode)) builder.set(
CaptureRequest.NOISE_REDUCTION_MODE,
noiseReductionMode
)
if (isCapture) {
PLog.d(TAG, "图像质量设置: 系统处理模式, 锐化=$edgeMode, 降噪=$noiseReductionMode")
}
}
} catch (e: Exception) {
PLog.e(TAG, "Failed to apply image quality settings", e)
@@ -1182,9 +1163,8 @@ class Camera2Controller(private val context: Context) {
/**
* 设置是否使用软件处理(降噪/锐化)
*/
fun setUseSoftwareProcessing(enabled: Boolean) {
useSoftwareProcessing = enabled
PLog.d(TAG, "软件处理模式: $enabled")
fun setNROff(enabled: Boolean) {
nrOff = enabled
}
/**
@@ -30,11 +30,10 @@ data class UserPreferences(
val vibrationEnabled: Boolean = true, // 拍摄震动
val volumeKeyCapture: Boolean = false, // 音量键拍摄
val autoSaveAfterCapture: Boolean = true, // 自动保存
val useSoftwareProcessing: Boolean = false, // 使用软件降噪/锐化(而非系统算法)
val nrOff: Boolean = false, // 禁用系统降噪
val useRaw: Boolean = false, // 使用 RAW 格式拍摄
// 软件处理参数(仅在 useSoftwareProcessing=true 时生效)
val sharpening: Float = 0.3f, // 0.0 ~ 1.0 锐化强度
val noiseReduction: Float = 0.25f, // 0.0 ~ 1.0 降噪强度
val sharpening: Float = 0.2f, // 0.0 ~ 1.0 锐化强度
val noiseReduction: Float = 0f, // 0.0 ~ 1.0 降噪强度
val chromaNoiseReduction: Float = 0.25f, // 0.0 ~ 1.0 减少杂色强度
// 排序顺序
val filterOrder: List<String> = emptyList(), // 滤镜排序(ID列表)
@@ -59,7 +58,7 @@ class UserPreferencesRepository(private val context: Context) {
private val VIBRATION_ENABLED = booleanPreferencesKey("vibration_enabled")
private val VOLUME_KEY_CAPTURE = booleanPreferencesKey("volume_key_capture")
private val AUTO_SAVE_AFTER_CAPTURE = booleanPreferencesKey("auto_save_after_capture")
private val USE_SOFTWARE_PROCESSING = booleanPreferencesKey("use_software_processing")
private val NR_OFF = booleanPreferencesKey("use_software_processing")
private val USE_RAW = booleanPreferencesKey("use_raw")
// 软件处理参数 Keys
@@ -88,11 +87,11 @@ class UserPreferencesRepository(private val context: Context) {
vibrationEnabled = preferences[VIBRATION_ENABLED] ?: true,
volumeKeyCapture = preferences[VOLUME_KEY_CAPTURE] ?: false,
autoSaveAfterCapture = preferences[AUTO_SAVE_AFTER_CAPTURE] ?: true,
useSoftwareProcessing = preferences[USE_SOFTWARE_PROCESSING] ?: false,
nrOff = preferences[NR_OFF] ?: false,
useRaw = preferences[USE_RAW] ?: false,
// 软件处理参数
sharpening = preferences[SHARPENING] ?: 0.3f,
noiseReduction = preferences[NOISE_REDUCTION] ?: 0.25f,
sharpening = preferences[SHARPENING] ?: 0.2f,
noiseReduction = preferences[NOISE_REDUCTION] ?: 0f,
chromaNoiseReduction = preferences[CHROMA_NOISE_REDUCTION] ?: 0.25f,
// 排序
filterOrder = preferences[FILTER_ORDER]?.split(",")?.filter { it.isNotEmpty() } ?: emptyList(),
@@ -201,9 +200,9 @@ class UserPreferencesRepository(private val context: Context) {
/**
* 保存是否使用软件降噪/锐化
*/
suspend fun saveUseSoftwareProcessing(enabled: Boolean) {
suspend fun saveNROff(enabled: Boolean) {
context.dataStore.edit { preferences ->
preferences[USE_SOFTWARE_PROCESSING] = enabled
preferences[NR_OFF] = enabled
}
}
@@ -26,10 +26,9 @@ class PhotoProcessor(
* @param input 输入 Bitmap
* @param metadata 照片元数据(包含编辑配置和拍摄信息)
* @param uri 照片 URI(用于提取 EXIF,仅在 metadata 中没有拍摄信息时使用)
* @param useSoftwareProcessing 是否使用软件降噪/锐化(默认 true)
* @param sharpening 锐化强度(仅 useSoftwareProcessing=true 时生效)
* @param noiseReduction 降噪强度(仅 useSoftwareProcessing=true 时生效)
* @param chromaNoiseReduction 减少杂色强度(仅 useSoftwareProcessing=true 时生效)
* @param sharpening 锐化强度
* @param noiseReduction 降噪强度
* @param chromaNoiseReduction 减少杂色强度
* @return 处理后的 Bitmap
*/
suspend fun process(
@@ -37,9 +36,8 @@ class PhotoProcessor(
input: Bitmap,
metadata: PhotoMetadata,
uri: Uri? = null,
useSoftwareProcessing: Boolean = false,
sharpening: Float = 0.3f,
noiseReduction: Float = 0.25f,
sharpening: Float = 0.2f,
noiseReduction: Float = 0f,
chromaNoiseReduction: Float = 0.25f
): Bitmap = withContext(Dispatchers.Default) {
var result = input
@@ -59,7 +57,6 @@ class PhotoProcessor(
result,
lutConfig,
colorRecipeParams,
useSoftwareProcessing,
finalSharpening,
finalNoiseReduction,
finalChromaNoiseReduction
@@ -165,21 +165,17 @@ class LutImageProcessor {
* @param bitmap 输入图片
* @param lutConfig LUT 配置
* @param colorRecipeParams 色彩配方参数
* @param useSoftwareProcessing 是否使用软件处理模式
* - true: 使用软件降噪/锐化算法
* - false: 不应用软件降噪/锐化(因为系统已处理)
* @param sharpeningValue 锐化强度(仅 useSoftwareProcessing=true 时生效)
* @param noiseReductionValue 降噪强度(仅 useSoftwareProcessing=true 时生效)
* @param chromaNoiseReductionValue 减少杂色强度(仅 useSoftwareProcessing=true 时生效)
* @param sharpeningValue 锐化强度
* @param noiseReductionValue 降噪强度
* @param chromaNoiseReductionValue 减少杂色强度
*/
suspend fun applyLut(
bitmap: Bitmap,
lutConfig: LutConfig?,
colorRecipeParams: ColorRecipeParams?,
useSoftwareProcessing: Boolean = false,
sharpeningValue: Float = 0.3f,
noiseReductionValue: Float = 0.25f,
chromaNoiseReductionValue: Float = 0.25f,
sharpeningValue: Float = 0f,
noiseReductionValue: Float = 0f,
chromaNoiseReductionValue: Float = 0f,
): Bitmap = withContext(glDispatcher) {
if (!isInitialized) {
if (!initialize()) {
@@ -202,23 +198,11 @@ class LutImageProcessor {
val vignette = colorRecipeParams?.vignette ?: 0f
val bleachBypass = colorRecipeParams?.bleachBypass ?: 0f
val intensity = colorRecipeParams?.lutIntensity ?: 1f
// 后期处理参数(仅在软件处理模式下生效)
val sharpening: Float
val noiseReduction: Float
val chromaNoiseReduction: Float
if (useSoftwareProcessing) {
// 软件处理模式:使用传入的参数值
sharpening = sharpeningValue
noiseReduction = noiseReductionValue
chromaNoiseReduction = chromaNoiseReductionValue
} else {
// 系统处理模式:不应用软件降噪/锐化(系统已经处理了)
sharpening = 0f
noiseReduction = 0f
chromaNoiseReduction = 0f
}
val sharpening: Float = sharpeningValue
val noiseReduction: Float = noiseReductionValue
val chromaNoiseReduction: Float = chromaNoiseReductionValue
// 确保上下文激活
EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)
@@ -11,8 +11,7 @@ import com.hinnka.mycamera.gallery.PhotoProcessor
/**
* Coil 图像加载库的 LUT 转换器
* 用于在加载照片时自动应用 LUT 效果
*
* @param useSoftwareProcessing 是否使用软件降噪/锐化(默认 false)
*
* @param sharpening 锐化强度
* @param noiseReduction 降噪强度
* @param chromaNoiseReduction 减少杂色强度
@@ -22,18 +21,17 @@ class PhotoTransformation(
private val uri: Uri,
private val metadata: PhotoMetadata,
private val photoProcessor: PhotoProcessor,
private val useSoftwareProcessing: Boolean = false,
private val sharpening: Float = 0.3f,
private val noiseReduction: Float = 0.25f,
private val sharpening: Float = 0.2f,
private val noiseReduction: Float = 0f,
private val chromaNoiseReduction: Float = 0.25f
) : Transformation {
override val cacheKey: String = "photo_${uri}_${metadata.toJson().hashCode()}_sw${useSoftwareProcessing}_s${sharpening}_n${noiseReduction}_c${chromaNoiseReduction}"
override val cacheKey: String = "photo_${uri}_${metadata.toJson().hashCode()}_s${sharpening}_n${noiseReduction}_c${chromaNoiseReduction}"
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
return photoProcessor.process(
context, input, metadata, uri,
useSoftwareProcessing, sharpening, noiseReduction, chromaNoiseReduction
context, input, metadata, uri,
sharpening, noiseReduction, chromaNoiseReduction
)
}
}
@@ -93,8 +93,6 @@ fun PhotoEditScreen(
val availableFrames = viewModel.availableFrames
val editFrameCustomProperties by viewModel.editFrameCustomProperties.collectAsState()
// 软件处理状态
val useSoftwareProcessing by viewModel.useSoftwareProcessing.collectAsState()
val sharpening by viewModel.editSharpening.collectAsState()
val noiseReduction by viewModel.editNoiseReduction.collectAsState()
val chromaNoiseReduction by viewModel.editChromaNoiseReduction.collectAsState()
@@ -102,12 +100,6 @@ fun PhotoEditScreen(
// 编辑标签页状态
var editTab by remember { mutableIntStateOf(0) } // 0: 滤镜/边框, 1: 细节处理
LaunchedEffect(useSoftwareProcessing) {
if (!useSoftwareProcessing) {
editTab = 0
}
}
LaunchedEffect(
currentPhoto,
editLutId,
@@ -115,7 +107,6 @@ fun PhotoEditScreen(
editLutConfig,
editFrameId,
editFrameCustomProperties,
useSoftwareProcessing,
sharpening,
noiseReduction,
chromaNoiseReduction
@@ -268,22 +259,20 @@ fun PhotoEditScreen(
modifier = Modifier.padding(bottom = 16.dp, start = 16.dp, end = 16.dp)
) {
// 标签页切换
if (useSoftwareProcessing) {
Row(
modifier = Modifier.fillMaxWidth().padding(top = 16.dp),
horizontalArrangement = Arrangement.spacedBy(24.dp)
) {
TabItem(
title = stringResource(R.string.filter) + " & " + stringResource(R.string.frame),
isSelected = editTab == 0,
onClick = { editTab = 0 }
)
TabItem(
title = stringResource(R.string.recipe_tab_post),
isSelected = editTab == 1,
onClick = { editTab = 1 }
)
}
Row(
modifier = Modifier.fillMaxWidth().padding(top = 16.dp),
horizontalArrangement = Arrangement.spacedBy(24.dp)
) {
TabItem(
title = stringResource(R.string.filter) + " & " + stringResource(R.string.frame),
isSelected = editTab == 0,
onClick = { editTab = 0 }
)
TabItem(
title = stringResource(R.string.recipe_tab_post),
isSelected = editTab == 1,
onClick = { editTab = 1 }
)
}
if (editTab == 0) {
@@ -35,7 +35,6 @@ import com.hinnka.mycamera.R
import com.hinnka.mycamera.camera.AspectRatio
import com.hinnka.mycamera.frame.FrameInfo
import com.hinnka.mycamera.ui.camera.autoRotate
import com.hinnka.mycamera.ui.components.CustomSliderThinThumb
import com.hinnka.mycamera.ui.components.SliderSettingItem
import com.hinnka.mycamera.ui.components.LogViewerDialog
import com.hinnka.mycamera.viewmodel.CameraViewModel
@@ -58,11 +57,11 @@ fun SettingsScreen(
val vibrationEnabled by viewModel.vibrationEnabled.collectAsState(initial = true)
val volumeKeyCapture by viewModel.volumeKeyCapture.collectAsState(initial = false)
val autoSaveAfterCapture by viewModel.autoSaveAfterCapture.collectAsState(initial = true)
val useSoftwareProcessing by viewModel.useSoftwareProcessing.collectAsState(initial = false)
val nrOff by viewModel.nrOff.collectAsState(initial = false)
val useRaw by viewModel.useRaw.collectAsState(initial = false)
// 软件处理参数
val sharpening by viewModel.sharpening.collectAsState(initial = 0.3f)
val noiseReduction by viewModel.noiseReduction.collectAsState(initial = 0.25f)
val sharpening by viewModel.sharpening.collectAsState(initial = 0.2f)
val noiseReduction by viewModel.noiseReduction.collectAsState(initial = 0f)
val chromaNoiseReduction by viewModel.chromaNoiseReduction.collectAsState(initial = 0.25f)
val isPurchased by viewModel.isPurchased.collectAsState()
@@ -206,45 +205,42 @@ fun SettingsScreen(
SwitchSettingItem(
title = stringResource(R.string.settings_software_processing),
description = stringResource(R.string.settings_software_processing_description),
checked = useSoftwareProcessing,
onCheckedChange = { viewModel.setUseSoftwareProcessing(it) }
checked = nrOff,
onCheckedChange = { viewModel.setNROff(it) }
)
// 软件处理参数(仅在软件处理模式开启时显示)
if (useSoftwareProcessing) {
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 8.dp)
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 8.dp)
)
SliderSettingItem(
title = stringResource(R.string.settings_sharpening),
description = stringResource(R.string.settings_sharpening_description),
value = sharpening,
valueRange = 0f..1f,
onValueChange = { viewModel.setSharpening(it) }
)
SliderSettingItem(
title = stringResource(R.string.settings_sharpening),
description = stringResource(R.string.settings_sharpening_description),
value = sharpening,
valueRange = 0f..1f,
onValueChange = { viewModel.setSharpening(it) }
)
Spacer(modifier = Modifier.height(12.dp))
Spacer(modifier = Modifier.height(12.dp))
SliderSettingItem(
title = stringResource(R.string.settings_noise_reduction),
description = stringResource(R.string.settings_noise_reduction_description),
value = noiseReduction,
valueRange = 0f..1f,
onValueChange = { viewModel.setNoiseReduction(it) }
)
SliderSettingItem(
title = stringResource(R.string.settings_noise_reduction),
description = stringResource(R.string.settings_noise_reduction_description),
value = noiseReduction,
valueRange = 0f..1f,
onValueChange = { viewModel.setNoiseReduction(it) }
)
Spacer(modifier = Modifier.height(12.dp))
Spacer(modifier = Modifier.height(12.dp))
SliderSettingItem(
title = stringResource(R.string.settings_chroma_noise_reduction),
description = stringResource(R.string.settings_chroma_noise_reduction_description),
value = chromaNoiseReduction,
valueRange = 0f..1f,
onValueChange = { viewModel.setChromaNoiseReduction(it) }
)
}
SliderSettingItem(
title = stringResource(R.string.settings_chroma_noise_reduction),
description = stringResource(R.string.settings_chroma_noise_reduction_description),
value = chromaNoiseReduction,
valueRange = 0f..1f,
onValueChange = { viewModel.setChromaNoiseReduction(it) }
)
}
HorizontalDivider(
@@ -130,8 +130,8 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val vibrationEnabled: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.vibrationEnabled }
val volumeKeyCapture: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.volumeKeyCapture }
val autoSaveAfterCapture: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.autoSaveAfterCapture }
val useSoftwareProcessing: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useSoftwareProcessing }
val nrOff: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.nrOff }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), false)
val useRaw: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useRaw }
@@ -140,10 +140,10 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
// 软件处理参数 Flow
val sharpening: StateFlow<Float> = userPreferencesRepository.userPreferences
.map { it.sharpening }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0.3f)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0.2f)
val noiseReduction: StateFlow<Float> = userPreferencesRepository.userPreferences
.map { it.noiseReduction }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0.25f)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0f)
val chromaNoiseReduction: StateFlow<Float> = userPreferencesRepository.userPreferences
.map { it.chromaNoiseReduction }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0.25f)
@@ -179,7 +179,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
isShutterSoundEnabled = it.shutterSoundEnabled
isVibrationEnabled = it.vibrationEnabled
// 同步软件处理设置到相机控制器
cameraController.setUseSoftwareProcessing(it.useSoftwareProcessing)
cameraController.setNROff(it.nrOff)
// 同步 RAW 设置到相机控制器
cameraController.setUseRaw(it.useRaw)
}
@@ -592,8 +592,8 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val previewBitmap = lutImageProcessor.applyLut(
bitmap = bitmap,
lutConfig = lutConfig,
colorRecipeParams = colorRecipeParams,
useSoftwareProcessing = false // 预览不需要软件处理
colorRecipeParams = colorRecipeParams
// 预览不需要软件处理
)
newPreviews[lutInfo.id] = previewBitmap
}
@@ -793,9 +793,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
/**
* 设置是否使用软件降噪/锐化
*/
fun setUseSoftwareProcessing(enabled: Boolean) {
fun setNROff(enabled: Boolean) {
viewModelScope.launch {
userPreferencesRepository.saveUseSoftwareProcessing(enabled)
userPreferencesRepository.saveNROff(enabled)
}
}
@@ -863,7 +863,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val aspectRatio = state.value.aspectRatio
val frameIdToSave = currentFrameId
val shouldAutoSave = autoSaveAfterCapture.firstOrNull() ?: false
val shouldUseSoftwareProcessing = useSoftwareProcessing.value
val sharpeningValue = sharpening.value
val noiseReductionValue = noiseReduction.value
val chromaNoiseReductionValue = chromaNoiseReduction.value
@@ -955,9 +954,8 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val processedBitmap = withContext(Dispatchers.Default) {
photoProcessor.process(
context = context,
input = bitmap!!,
input = bitmap,
metadata = metadata,
useSoftwareProcessing = shouldUseSoftwareProcessing,
sharpening = sharpeningValue,
noiseReduction = noiseReductionValue,
chromaNoiseReduction = chromaNoiseReductionValue
@@ -58,20 +58,15 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
// 用户偏好设置仓库
private val userPreferencesRepository = UserPreferencesRepository(application)
// 软件处理模式设置
val useSoftwareProcessing: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useSoftwareProcessing }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), false)
// 软件处理参数
val sharpening: StateFlow<Float> = userPreferencesRepository.userPreferences
.map { it.sharpening }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0.3f)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0.2f)
val noiseReduction: StateFlow<Float> = userPreferencesRepository.userPreferences
.map { it.noiseReduction }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0.25f)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0f)
val chromaNoiseReduction: StateFlow<Float> = userPreferencesRepository.userPreferences
.map { it.chromaNoiseReduction }
@@ -165,9 +160,9 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
)
// 细节处理编辑状态 (Sharpening, Noise Reduction, Chroma Noise Reduction)
var editSharpening = MutableStateFlow(0.3f)
var editSharpening = MutableStateFlow(0.2f)
private set
var editNoiseReduction = MutableStateFlow(0.25f)
var editNoiseReduction = MutableStateFlow(0f)
private set
var editChromaNoiseReduction = MutableStateFlow(0.25f)
private set
@@ -428,8 +423,8 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
lutImageProcessor.applyLut(
bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, false),
lutConfig = lutConfig,
colorRecipeParams = colorRecipeParams,
useSoftwareProcessing = false // 预览不需要软件处理
colorRecipeParams = colorRecipeParams
// 预览不需要软件处理
).let { preview ->
previews[lutInfo.id] = preview
}
@@ -925,7 +920,6 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
uri = photo.uri,
metadata = photo.metadata ?: PhotoMetadata(),
photoProcessor = photoProcessor,
useSoftwareProcessing = useSoftwareProcessing.value,
sharpening = sharpening.value,
noiseReduction = noiseReduction.value,
chromaNoiseReduction = chromaNoiseReduction.value
@@ -957,8 +951,8 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
// 预览生成:跟随当前编辑状态
photoProcessor.process(
context, bitmap, metadata, photo.previewUri,
useSoftwareProcessing.value, editSharpening.value, editNoiseReduction.value, editChromaNoiseReduction.value
context, bitmap, metadata, photo.previewUri,
editSharpening.value, editNoiseReduction.value, editChromaNoiseReduction.value
)
} catch (e: Exception) {
PLog.e(TAG, "Failed to create preview", e)
@@ -1084,8 +1078,8 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
// 处理照片:跟随用户设置
val processedBitmap = photoProcessor.process(
context, bitmap, metadata, photo.uri,
useSoftwareProcessing.value, sharpening.value, noiseReduction.value, chromaNoiseReduction.value
context, bitmap, metadata, photo.uri,
sharpening.value, noiseReduction.value, chromaNoiseReduction.value
)
// 保存到缓存目录
@@ -1134,8 +1128,8 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
// 处理照片:跟随用户设置
val processedBitmap = photoProcessor.process(
context, bitmap, metadata, photo.uri,
useSoftwareProcessing.value, sharpening.value, noiseReduction.value, chromaNoiseReduction.value
context, bitmap, metadata, photo.uri,
sharpening.value, noiseReduction.value, chromaNoiseReduction.value
)
// 保存到指定目录
@@ -14,12 +14,6 @@ class LutEditViewModel(application: Application) : AndroidViewModel(application)
private val contentRepository = ContentRepository.getInstance(application)
// 用户偏好设置仓库
private val userPreferencesRepository = UserPreferencesRepository(application)
// 软件处理模式设置
val useSoftwareProcessing: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.useSoftwareProcessing }
suspend fun getColorRecipe(lutId: String) = contentRepository.lutManager.loadColorRecipeParams(lutId)
/**
+2 -2
View File
@@ -109,8 +109,8 @@
<string name="settings_volume_key_description">使用音量键进行拍摄</string>
<string name="settings_auto_save">拍摄后自动保存</string>
<string name="settings_auto_save_description">拍摄后自动保存照片,否则需要手动确认</string>
<string name="settings_software_processing">软件降噪/锐化</string>
<string name="settings_software_processing_description">使用软件算法进行降噪和锐化处理。关闭后将使用系统硬件处理。</string>
<string name="settings_software_processing">禁用系统降噪</string>
<string name="settings_software_processing_description">禁用系统默认的降噪处理以获得更多细节。</string>
<string name="settings_sharpening">锐化</string>
<string name="settings_sharpening_description">增强图像锐度和边缘清晰度</string>
<string name="settings_noise_reduction">降噪</string>
+2 -2
View File
@@ -110,8 +110,8 @@
<string name="settings_volume_key_description">Use volume keys to take photos</string>
<string name="settings_auto_save">Auto Save</string>
<string name="settings_auto_save_description">Automatically save photos after capture</string>
<string name="settings_software_processing">Software Denoising/Sharpening</string>
<string name="settings_software_processing_description">Use software algorithms for noise reduction and sharpening. Disable to use system hardware processing.</string>
<string name="settings_software_processing">Disable System Noise Reduction</string>
<string name="settings_software_processing_description">Disable system default noise reduction and sharpening to preserve more details.</string>
<string name="settings_sharpening">Sharpening</string>
<string name="settings_sharpening_description">Enhance image sharpness and edge definition</string>
<string name="settings_noise_reduction">Noise Reduction</string>