Browse Source

fix: correct BGR to RGB color channel ordering in long screenshots

- Added COLOR_BGR2RGB conversion before creating bitmap for long screenshots
- Fixes red/blue channel swap issue in saved PNG files
- Ensures screenshots have correct color representation
- Added proper cleanup for intermediate rgbMat

This matches the color correction approach used in the main YOLO processing
pipeline and ensures long screenshots have accurate colors.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
feature/pgh-30-long-screenshot-capture
Dan 5 months ago
parent
commit
3ed31a0d81
  1. 9
      app/src/main/java/com/quillstudios/pokegoalshelper/ScreenCaptureService.kt

9
app/src/main/java/com/quillstudios/pokegoalshelper/ScreenCaptureService.kt

@ -1324,9 +1324,13 @@ class ScreenCaptureService : Service() {
val mat = convertImageToMat(image) val mat = convertImageToMat(image)
if (mat != null) { if (mat != null) {
// Convert BGR Mat to RGB for proper color channels
val rgbMat = Mat()
Imgproc.cvtColor(mat, rgbMat, Imgproc.COLOR_BGR2RGB)
// Convert Mat to Bitmap // Convert Mat to Bitmap
val bitmap = Bitmap.createBitmap(mat.cols(), mat.rows(), Bitmap.Config.ARGB_8888) val bitmap = Bitmap.createBitmap(rgbMat.cols(), rgbMat.rows(), Bitmap.Config.ARGB_8888)
Utils.matToBitmap(mat, bitmap) Utils.matToBitmap(rgbMat, bitmap)
// Create a copy of the bitmap for long screenshot processing // Create a copy of the bitmap for long screenshot processing
val bitmapCopy = bitmap.copy(bitmap.config ?: Bitmap.Config.ARGB_8888, false) val bitmapCopy = bitmap.copy(bitmap.config ?: Bitmap.Config.ARGB_8888, false)
@ -1342,6 +1346,7 @@ class ScreenCaptureService : Service() {
// Clean up original resources // Clean up original resources
bitmap.recycle() bitmap.recycle()
mat.release() mat.release()
rgbMat.release()
} else { } else {
PGHLog.w(TAG, "⚠️ Failed to convert image to Mat for long screenshot") PGHLog.w(TAG, "⚠️ Failed to convert image to Mat for long screenshot")
} }

Loading…
Cancel
Save