Skip to content

Commit d36e316

Browse files
author
Cook21
committed
solve the blurry problem in gallery
1 parent ce96eed commit d36e316

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class CameraFragment : Fragment() {
287287
Log.d(TAG, "Screen metrics: ${metrics.width()} x ${metrics.height()}")
288288

289289
val screenAspectRatio = aspectRatio(metrics.width(), metrics.height())
290-
Log.d(TAG, "Preview aspect ratio: $screenAspectRatio")
290+
Log.d(TAG, "Preview aspect ratio: $screenAspectRatio")
291291

292292
val rotation = viewFinder.display.rotation
293293

@@ -597,6 +597,7 @@ class CameraFragment : Fragment() {
597597
private val targetResolution = Size(2448, 3264)
598598

599599

600+
600601
/** Helper function used to create a timestamped file */
601602
private fun createFile(baseFolder: File, format: String, extension: String) =
602603
File(

CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/PhotoFragment.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.android.example.cameraxbasic.fragments
1818

1919
import android.annotation.SuppressLint
20+
import android.graphics.Bitmap
21+
import android.graphics.BitmapFactory
2022
import android.os.Bundle
2123
import android.view.LayoutInflater
2224
import android.view.ScaleGestureDetector
@@ -43,8 +45,14 @@ class PhotoFragment internal constructor() : Fragment() {
4345
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
4446
super.onViewCreated(view, savedInstanceState)
4547
val args = arguments ?: return
46-
val resource = args.getString(FILE_NAME_KEY)?.let { File(it) } ?: R.drawable.ic_photo
47-
Glide.with(view).load(resource).into(view as PhotoView)
48+
//val resource = args.getString(FILE_NAME_KEY)?.let { File(it) } ?: R.drawable.ic_photo
49+
//Glide.with(view).load(resource).into(view as PhotoView)
50+
if(args.getString(FILE_NAME_KEY) != null){
51+
val imageBitmap = BitmapFactory.decodeFile(args.getString(FILE_NAME_KEY))
52+
(view as PhotoView).setImageBitmap(imageBitmap)
53+
} else{
54+
(view as PhotoView).setImageResource(R.drawable.ic_photo)
55+
}
4856

4957
}
5058

0 commit comments

Comments
 (0)