Skip to content

Commit

Permalink
Added RGB and Brightness Large histograms generation for Color Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Sep 18, 2024
1 parent 10b71e9 commit 553fa6b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1413,4 +1413,5 @@
<string name="collages_info">Hold image to swap, move and zoom to adjust position</string>
<string name="histogram">Histogram</string>
<string name="histogram_sub">RGB or Brightness image histogram to help you make adjustments</string>
<string name="image_for_histogram">This image will be used to generate RGB and Brightness histograms</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,6 @@ sealed class Screen(
typedEntries.flatMap { it.first }.sortedBy { it.id }
}

const val FEATURES_COUNT = 53
const val FEATURES_COUNT = 54
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package ru.tech.imageresizershrinker.color_tools.presentation

import android.net.Uri
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.fadeIn
Expand All @@ -36,6 +37,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.AutoGraph
import androidx.compose.material.icons.rounded.BarChart
import androidx.compose.material.icons.rounded.Blender
import androidx.compose.material.icons.rounded.ContentCopy
Expand Down Expand Up @@ -69,6 +71,8 @@ import com.smarttoolfactory.colordetector.util.ColorUtil.colorToHex
import com.smarttoolfactory.colordetector.util.ColorUtil.colorToHexAlpha
import com.t8rin.dynamic.theme.LocalDynamicThemeState
import com.t8rin.dynamic.theme.rememberAppColorTuple
import com.t8rin.histogram.HistogramType
import com.t8rin.histogram.ImageHistogram
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand All @@ -89,6 +93,7 @@ import ru.tech.imageresizershrinker.core.ui.widget.AdaptiveLayoutScreen
import ru.tech.imageresizershrinker.core.ui.widget.buttons.EnhancedChip
import ru.tech.imageresizershrinker.core.ui.widget.controls.EnhancedSliderItem
import ru.tech.imageresizershrinker.core.ui.widget.controls.selection.BackgroundColorSelector
import ru.tech.imageresizershrinker.core.ui.widget.controls.selection.ImageSelector
import ru.tech.imageresizershrinker.core.ui.widget.modifier.ContainerShapeDefaults
import ru.tech.imageresizershrinker.core.ui.widget.modifier.container
import ru.tech.imageresizershrinker.core.ui.widget.modifier.transparencyChecker
Expand Down Expand Up @@ -202,6 +207,9 @@ fun ColorToolsContent(
)
}
}
var imageUri by rememberSaveable {
mutableStateOf<Uri?>(null)
}
if (isPortrait) {
Spacer(modifier = Modifier.height(20.dp))
}
Expand Down Expand Up @@ -704,6 +712,60 @@ fun ColorToolsContent(
},
initialState = false
)
Spacer(modifier = Modifier.height(8.dp))
ExpandableItem(
visibleContent = {
TitleItem(
text = stringResource(R.string.histogram),
icon = Icons.Rounded.AutoGraph
)
},
expandableContent = {
Column(
modifier = Modifier.padding(
start = 16.dp,
end = 16.dp,
bottom = 8.dp
)
) {
ImageSelector(
value = imageUri,
onValueChange = {
imageUri = it
},
subtitle = stringResource(R.string.image_for_histogram),
shape = RoundedCornerShape(16.dp),
color = MaterialTheme.colorScheme.surface
)
Column(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
ImageHistogram(
imageUri = imageUri,
modifier = Modifier
.padding(top = 16.dp)
.fillMaxWidth()
.height(250.dp),
initialType = HistogramType.RGB,
swapTypesOnTap = false,
linesThickness = 1.dp,
bordersShape = RoundedCornerShape(6.dp)
)
ImageHistogram(
imageUri = imageUri,
modifier = Modifier
.fillMaxWidth()
.height(250.dp),
initialType = HistogramType.Brightness,
swapTypesOnTap = false,
linesThickness = 1.dp,
bordersShape = RoundedCornerShape(6.dp)
)
}
}
},
initialState = false
)
},
buttons = {},
placeImagePreview = false,
Expand Down

0 comments on commit 553fa6b

Please sign in to comment.