title: How to get only QR Code as a image after scanning QR code from scanner result
body: <p>I am trying to get QR code as a image from scanning QR Code result I need that image to place in image view am using ZXingScanner for scanning QR Code</p>
  <p>I am not getting exact QR Code image from result am also getting extra part of image</p>
  <pre><code> @Override
     public void onPreviewFrame(byte[] data, Camera camera) {
          if (mResultHandler == null) {
              return;
          }
  
      try {
          Camera.Parameters parameters = camera.getParameters();
          Camera.Size size = parameters.getPreviewSize();
          int width = size.width;
          int height = size.height;
  
          if (DisplayUtils.getScreenOrientation(getContext()) == Configuration.ORIENTATION_PORTRAIT) {
              int rotationCount = getRotationCount();
              if (rotationCount == 1 || rotationCount == 3) {
                  int tmp = width;
                  width = height;
                  height = tmp;
              }
              data = getRotatedData(data, camera);
          }
  
          Result rawResult = null;
          PlanarYUVLuminanceSource source = buildLuminanceSource(data, width, height);
  </code></pre>
  <p>After scanning I will get result from scanner I need to decode qr code from that result with same width and height</p>
  <pre><code>Bitmap bitmapqr = renderGrayScaleBitmap(source);
  
   if (source != null) {
              BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
              try {
                  rawResult = mMultiFormatReader.decodeWithState(bitmap);
              } catch (ReaderException re) {
                  // continue
              } catch (NullPointerException npe) {
                  // This is terrible
              } catch (ArrayIndexOutOfBoundsException aoe) {
  
              } finally {
                  mMultiFormatReader.reset();
              }
  
              if (rawResult == null) {
                  LuminanceSource invertedSource = source.invert();
                  bitmap = new BinaryBitmap(new HybridBinarizer(invertedSource));
                  try {
                      rawResult = mMultiFormatReader.decodeWithState(bitmap);
                  } catch (NotFoundException e) {
                      // continue
                  } finally {
                      mMultiFormatReader.reset();
                  }
              }
          }
  
          final Result finalRawResult = rawResult;
  
          if (finalRawResult != null) {
              Log.d(TAG, &quot;onPreviewFrame: &quot;+ finalRawResult);
              Handler handler = new Handler(Looper.getMainLooper());
              handler.post(new Runnable() {
                  @Override
                  public void run() {
                      // Stopping the preview can take a little long.
                      // So we want to set result handler to null to discard subsequent calls to
                      // onPreviewFrame.
                      ResultHandler tmpResultHandler = mResultHandler;
                      mResultHandler = null;
  
                      stopCameraPreview();
                      if (tmpResultHandler != null) {
                          new Handler().postDelayed(new Runnable() {
                              @Override
                              public void run() {
                                  tmpResultHandler.handleResult(finalRawResult);
                              }
                          },1800);
                          tmpResultHandler.handleQRImageAnimation(bitmapqr);
  
                      }
                  }
              });
          } else {
              camera.setOneShotPreviewCallback(this);
          }
      } catch (RuntimeException e) {
          Log.e(TAG, e.toString(), e);
          e.printStackTrace();
      }
  }
  </code></pre>
  <p>this function which is am using for decoding the qr code from result which we get when we scanned the QR Code</p>
  <pre><code>@NotNull
  private Bitmap renderGrayScaleBitmap(@NotNull PlanarYUVLuminanceSource source) {
      int[] pixels = source.renderThumbnail();
      int width = source.getThumbnailWidth();
      int height = source.getThumbnailHeight();
      Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888);
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out);
      return bitmap;
  }
  </code></pre>