title: Rotate fingerprint using Morpho SDK
body: <p>I am using MOrpho sdk to capture the finger print but i have an issue where some of the devices are capturing the fingerprint in reverse layout (meaning the capture image should be from left and right but it is capturing in right to left), so what i did so far is i converted received byte[] to bitmap and than rotated it. However it didn't work because the content of byte[] after converting back from bitmap is somewhat changed.</p>
  <p>I just want to know to easily change the layout using morpho sdk methods.</p>
  <p>Here below is the function where i am capturing.</p>
  <pre><code> public FTPImage fpCapture(int timeoutInSeconds) {
          Logger.d(&quot;fpCapture ():::&quot;);
          if (context == null) {
              Logger.e(&quot;fpCapture()::Context is null&quot;);
              return null;
          }
          TemplateList templateList = new TemplateList();
          templateList.setActivateFullImageRetrieving(true);
          try {
              Logger.d(&quot;Device is not null:&quot;);
              MorphoImage morphoImage = new MorphoImage();
              int detectModeChoice = DetectionMode.MORPHO_ENROLL_DETECT_MODE.getValue() | DetectionMode.MORPHO_FORCE_FINGER_ON_TOP_DETECT_MODE.getValue();
              int detectModeChoice1= DetectionMode.MORPHO_ENROLL_DETECT_MODE.getValue() | DetectionMode.MORPHO_DEFAULT_DETECT_MODE.getValue();
              int detectModeChoice2= DetectionMode.MORPHO_VERIF_DETECT_MODE.getValue() | DetectionMode.MORPHO_DEFAULT_DETECT_MODE.getValue();
              int detectModeChoice3= DetectionMode.MORPHO_DEFAULT_DETECT_MODE.getValue();
  
  
              int acquisitionThreshold = 0;
              int compressionRate = 0;
              int callbackCmd = 0;
              int ret = morphoDevice.getImage(timeoutInSeconds, acquisitionThreshold, CompressionAlgorithm.MORPHO_NO_COMPRESS, compressionRate, detectModeChoice2, LatentDetection.LATENT_DETECT_ENABLE, morphoImage, callbackCmd, null);
  
              if (ret == 0) {
  
                  Logger.d(&quot;MorphoPlugin::--------- &quot;+&quot;d=&quot;+detectModeChoice+&quot;-d1&quot;+detectModeChoice1+&quot;d2=&quot;+detectModeChoice2+&quot;d3&quot;+detectModeChoice3);
  
  
                 /* Logger.d(&quot;MorphoPlugin::--bytearray &quot;+new String(morphoImage.getImage().toString()));
                  Logger.d(&quot;MorphoPlugin::--bytearray-- &quot;+Arrays.toString(morphoImage.getImage()).toString());
  
                  String s = new String(morphoImage.getImage(), &quot;UTF-8&quot;);
  
                  Logger.d(&quot;MorphoPlugin::--sttinh image bytearay-- &quot;+s.getBytes(&quot;UTF-8&quot;));
                  //fpCaptureAndConvert(20);
  
                  String s1 = new String(morphoImage.getImage(), &quot;UTF-8&quot;);
  
                  Logger.d(&quot;MorphoPlugin::--template image bytearay-- &quot;+s1.getBytes(&quot;UTF-8&quot;));
  */
                 /* Bitmap bitmap = BitmapFactory.decodeByteArray(morphoImage.getImage() , 0, morphoImage.getImage().length);
  
                  YuvImage yuvimage=new YuvImage(morphoImage.getImage(), ImageFormat.NV21, 100, 100, null);
                  ByteArrayOutputStream baos = new ByteArrayOutputStream();
                  yuvimage.compressToJpeg(new Rect(0, 0, 100, 100), 80, baos);
                  byte[] jdata = baos.toByteArray();
  
                  // Convert to Bitmap
                  Bitmap bmp = BitmapFactory.decodeByteArray(jdata, 0, jdata.length);
                  System.out.println(&quot;Bitmap Name 3&quot; + bmp);
  
                  if (bmp!=null)
                  {
                      Logger.d(&quot;MorphoPlugin::--bitmap not null&quot;+bmp.toString());
                      Logger.d(&quot;MorphoPlugin::--bitmap not null-a1-&quot;+morphoImage.getImage().toString());
                      byte[] b1=getByteArray(bmp);
                      Logger.d(&quot;MorphoPlugin::--bitmap not null-bytearr-&quot;+b1.toString());
                  }else{
                      Logger.d(&quot;MorphoPlugin::--bitmap  null&quot;);
                  }*/
  
               //   Logger.d(&quot;MorphoPlugin:: &quot;+&quot;normal bytearray&quot;+fpCaptureAndConvert(5));
  
                  Logger.d(&quot;MorphoPlugin::--------- &quot;+&quot;actual bytearray[]&quot;+Arrays.toString(morphoImage.getImage()).toString());
  
                /*  byte[] bytearray1 =  getByteArray(bmp);
  
                  Logger.d(&quot;MorphoPlugin:: &quot;+&quot;reversed bytearray1&quot;+Arrays.toString(bytearray1).toString());
  */
                  //byte[] rotatedbyte=rotateByteArray(morphoImage.getImage());
  
                  //byte[] rotatedbyte1=rotateByteArray(rotatedbyte);
  
                  int imageRowNumber = morphoImage.getMorphoImageHeader()
                          .getNbRow();
                  int imageColumnNumber = morphoImage.getMorphoImageHeader()
                          .getNbColumn();
  
                //  byte[] rotated=rotateYUV420Degree90(morphoImage.getImage(),imageColumnNumber,imageRowNumber);
  
  
                /*  //For decoding
                  String str=getStringImage(bitmp);
                  byte convertedBytearray[]= android.util.Base64.decode(str, android.util.Base64.DEFAULT);
                  Bitmap bmp=getBitmapFromRawImage(convertedBytearray);
  
  //                Logger.d(&quot;MorphoPlugin::--------- &quot;+&quot;converted bytearray[]&quot;+new String(convertedBytearray));
  //                Logger.d(&quot;MorphoPlugin:: &quot;+&quot;converted bitmap&quot;+bmp);
  
  //
                  Bitmap rotatetedBitmp= rotateImage(180,bmp);
  
                  String rotatedstr=getStringImage(rotatetedBitmp);
                  byte rotatedBytearray[]= android.util.Base64.decode(rotatedstr, android.util.Base64.DEFAULT);
  */
                  Bitmap rotatetedBitmp=rotateImage(morphoImage.getImage());
  
  
                 // createExternalImage(rotatetedBitmp);
                  //createExternalImage(bitmp);
  
  
  
  
                //  Logger.d(&quot;MorphoPlugin:: &quot;+&quot;bitmap with rot&quot;+rotatetedBitmp);
  
                 // createExternalImage(bitmp);
  
                 /* byte[] b1=getByteArray(bitmp);
                  byte[] b2=getByteArray(rotatetedBitmp);
                  Logger.d(&quot;MorphoPlugin:: &quot;+&quot;before rotation bytearray&quot;+b1);
                  Logger.d(&quot;MorphoPlugin:: &quot;+&quot;after rotation bytearray&quot;+b2);
  */
                  //Logger.d(&quot;MorphoPlugin::--bytearray &quot;+new String(morphoImage.getImage()));
                  FTPImage ftpImage = new FTPImage();
                  ftpImage.imgData = morphoImage.getImage();
                  ftpImage.imgHeight = morphoImage.getMorphoImageHeader().getNbRow();
                  ftpImage.imgWidth = morphoImage.getMorphoImageHeader().getNbColumn();
  
                  Bitmap bitmp=getBitmapFromRawImage(morphoImage.getImage(),imageColumnNumber,imageRowNumber);
  
                  createExternalImage(bitmp);
  
                  // byte[] bytearray= getByteArray(bitmp);
                  byte[] bytearray =  getByteArray(bitmp);
  
                  Logger.d(&quot;MorphoPlugin:: &quot;+&quot;---ftp- bytearray&quot;+Arrays.toString(bytearray).toString());
  
               /*   Logger.d(&quot;MorphoPlugin:: &quot;+&quot;ftp-actual&quot;+new String(ftpImage.imgData));
                  Bitmap ftpbitmp=getBitmapFromRawImage(morphoImage.getImage(),ftpImage.imgWidth,ftpImage.imgHeight);
                  byte[] bytearrayftp= getByteArray(ftpbitmp);
                  ftpImage.imgData = bytearrayftp;
  
                  Logger.d(&quot;MorphoPlugin:: &quot;+&quot;ftp-reversed&quot;+new String(bytearrayftp));*/
  
  
                  return ftpImage;
              }
          } catch (Exception e) {
              Logger.e(&quot;Exception occurred &quot; + e.getLocalizedMessage());
          }
          return null;
      }
  </code></pre>