2

I'm having a strange problem with CommonsWare's cwac-camera library. Images taken by the front camera are always mirrored (i.e. mirror of what I see in the preview) despite setting:

builder.mirrorFFC(true);

I have confirmed that this setting is applied correctly by logging in the ImageCleanupTask as follows:

if (applyMatrix) {
  if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
    if (xact.host.getDeviceProfile().portraitFFCFlipped()
        && (xact.displayOrientation == 90 || xact.displayOrientation == 270)) {
      matrix=flip(new Matrix());
    }
    else if (xact.mirrorFFC()) {
      Log.d("myapp", "matrixFFC is true");
      matrix=mirror(new Matrix());
    }
  }

The strangest thing is photos are always mirrored, whether I set mirrorFFC(true) or not. I haven't made any other changes to the Cwac library.

A quick and dirty hack solving the problem is to modify ImageCleanupTask as follows:

if (matrix != null) {
    Bitmap original=
        BitmapFactory.decodeByteArray(data, 0, data.length);

    cleaned=
        Bitmap.createBitmap(original, 0, 0, original.getWidth(),
                            original.getHeight(), matrix, true);
    original.recycle();

    //below my added code:
    Matrix myMatrix = new Matrix(); 
    myMatrix.preScale(-1.0f, 1.0f);
    cleaned = Bitmap.createBitmap(cleaned, 0, 0, cleaned.getWidth(), cleaned.getHeight(), myMatrix, false);
  }

Now the question is - is it simply my device (Samsung SGS i9000, running ICS) that causes problems or something else?

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Do you see the same effect in an unmodified copy of the demo app, using an unmodified copy of the library? – CommonsWare Mar 24 '14 at 23:20
  • yup, I cloned the repo again, run CameraDemo and in DisplayActivity I still see a mirrored photo – user3453544 Mar 25 '14 at 00:04
  • It must be unique to your phone, then, as none of the devices I normally test exhibit this behavior. Just to confirm, your device is a [Samsung Galaxy S i9000](http://www.gsmarena.com/samsung_i9000_galaxy_s-3115.php)? And is there a letter after that model number? (i9000M, i9000T, i9000S)? – CommonsWare Mar 25 '14 at 00:08
  • Perhaps the devices needs the portraitFFCFlipped setting in the device info? Even then, if it does have that setting, the mirrorFFC() wouldn't be checked. – lilbyrdie Apr 30 '14 at 22:26
  • @CommonsWare the same issue happen on my Samsung Note 2 GT-N7100, Android 4.3 even with the CameraDemo, notice this is one of the Tested Device – Steven Low May 16 '14 at 13:56
  • @StevenLow: I cannot reproduce your findings on the GT-N7100, though mine is running 4.1.2, as "Software Update" says that it has the latest stuff and Samsung Kies is a bug-riddled piece of fecal material. :-( – CommonsWare Jul 02 '14 at 19:48

0 Answers0