[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sample] [Camera2] - Implementation of "UltraHDR Image Capture" #56

Merged
merged 8 commits into from
Jul 11, 2023
Prev Previous commit
Update image in UltraHDR Sample to image taken from device
  • Loading branch information
madebymozart committed Jul 11, 2023
commit 19f877ef786f85e3b4eec9d214ab57213414a648
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import android.view.ViewGroup
import android.widget.RadioButton
import androidx.annotation.RequiresApi
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import com.example.platform.graphics.ultrahdr.databinding.DisplayingUltrahdrBinding
import com.google.android.catalog.framework.annotations.Sample
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

@Sample(
name = "Displaying UltraHDR",
Expand Down Expand Up @@ -77,9 +80,8 @@ class DisplayingUltraHDR : Fragment() {
/**
* Updated the currently displayed UltraHDR image.
*/
private fun updateDisplayedImage(index: Int) {
private fun updateDisplayedImage(index: Int) = lifecycleScope.launch(Dispatchers.IO) {
ultraHDRImages[index]?.let {
binding.imageContainer.setImageResource(0)
val stream = context?.assets?.open(it)
val bitmap = BitmapFactory.decodeStream(stream)
binding.imageContainer.setImageBitmap(bitmap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ class VisualizingAnUltraHDRGainmap : Fragment() {
* the gainmap as well as the result of the both of them displayed together.
*/
private fun updateDisplayedImage(type: Type) = lifecycleScope.launch(Dispatchers.Main) {
// Clear previous bitmap source.
val imageview = binding.imageContainer
imageview.setImageResource(0)

// Decode ultra hdr image into bitmap data.
val imageBitmap = getBitmapFromFile()

Expand All @@ -115,7 +111,7 @@ class VisualizingAnUltraHDRGainmap : Fragment() {
}

// Based on the type, setting the appropriate bitmap.
imageview.setImageBitmap(
binding.imageContainer.setImageBitmap(
when (type) {
// Intentionally drop the gainmap in order to display 8-bit jpeg sdr image. This
// demonstrates that even if the activity is in HDR mode, SDR images will
Expand Down Expand Up @@ -185,7 +181,7 @@ class VisualizingAnUltraHDRGainmap : Fragment() {
/**
* Default UltraHDR image path
*/
private const val ULTRA_HDR_IMAGE_FOUNTAIN = "gainmaps/fountain_night.jpg"
private const val ULTRA_HDR_IMAGE_FOUNTAIN = "gainmaps/office.jpg"

/**
* Location argument for if this fragment is pass with a bundle that contains the location
Expand Down