android.view.TextureView.getBitmap()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(265)

本文整理了Java中android.view.TextureView.getBitmap()方法的一些代码示例,展示了TextureView.getBitmap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextureView.getBitmap()方法的具体详情如下:
包路径:android.view.TextureView
类名称:TextureView
方法名:getBitmap

TextureView.getBitmap介绍

暂无

代码示例

代码示例来源:origin: andkulikov/Transitions-Everywhere

private void captureValues(@NonNull TransitionValues transitionValues) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
    return;
  }
  View view = transitionValues.view;
  if (view.getWidth() <= 0 || view.getHeight() <= 0) {
    return;
  }
  Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
  if (mFadeBehavior != FADE_BEHAVIOR_REVEAL) {
    bounds.offset(view.getLeft(), view.getTop());
  }
  transitionValues.values.put(PROPNAME_BOUNDS, bounds);
  Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),
      Bitmap.Config.ARGB_8888);
  if (view instanceof TextureView) {
    bitmap = ((TextureView) view).getBitmap();
  } else {
    Canvas c = new Canvas(bitmap);
    view.draw(c);
  }
  transitionValues.values.put(PROPNAME_BITMAP, bitmap);
  BitmapDrawable drawable = new BitmapDrawable(view.getResources(), bitmap);
  // TODO: lrtb will be wrong if the view has transXY set
  drawable.setBounds(bounds);
  transitionValues.values.put(PROPNAME_DRAWABLE, drawable);
}

代码示例来源:origin: nekocode/CameraFilter

private boolean capture() {
  String mPath = genSaveFileName(getTitle().toString() + "_", ".png");
  File imageFile = new File(mPath);
  if (imageFile.exists()) {
    imageFile.delete();
  }
  // create bitmap screen capture
  Bitmap bitmap = textureView.getBitmap();
  OutputStream outputStream = null;
  try {
    outputStream = new FileOutputStream(imageFile);
    bitmap.compress(Bitmap.CompressFormat.PNG, 90, outputStream);
    outputStream.flush();
    outputStream.close();
  } catch (FileNotFoundException e) {
    e.printStackTrace();
    return false;
  } catch (IOException e) {
    e.printStackTrace();
    return false;
  }
  return true;
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

private void captureValues(@NonNull TransitionValues transitionValues) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    return;
  }
  View view = transitionValues.view;
  if (view.getWidth() <= 0 || view.getHeight() <= 0) {
    return;
  }
  Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
  if (mFadeBehavior != FADE_BEHAVIOR_REVEAL) {
    bounds.offset(view.getLeft(), view.getTop());
  }
  transitionValues.values.put(PROPNAME_BOUNDS, bounds);
  if (Transition.DBG) {
    Log.d(LOG_TAG, "Captured bounds " + transitionValues.values.get(PROPNAME_BOUNDS));
  }
  Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),
      Bitmap.Config.ARGB_8888);
  if (view instanceof TextureView) {
    bitmap = ((TextureView) view).getBitmap();
  } else {
    Canvas c = new Canvas(bitmap);
    view.draw(c);
  }
  transitionValues.values.put(PROPNAME_BITMAP, bitmap);
  BitmapDrawable drawable = new BitmapDrawable(view.getResources(), bitmap);
  // TODO: lrtb will be wrong if the view has transXY set
  drawable.setBounds(bounds);
  transitionValues.values.put(PROPNAME_DRAWABLE, drawable);
}

代码示例来源:origin: google/cameraview

@Override
  public void check(View view, NoMatchingViewException noViewFoundException) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
      return;
    }
    CameraView cameraView = (CameraView) view;
    TextureView textureView = (TextureView) cameraView.findViewById(R.id.texture_view);
    Bitmap bitmap = textureView.getBitmap();
    int topLeft = bitmap.getPixel(0, 0);
    int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
    int bottomRight = bitmap.getPixel(
        bitmap.getWidth() - 1, bitmap.getHeight() - 1);
    assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft),
        topLeft == center && center == bottomRight);
  }
};

代码示例来源:origin: brianwernick/ExoMedia

/**
 * Returns a {@link Bitmap} representation of the current contents of the
 * view. If the surface isn't ready or we cannot access it for some reason then
 * <code>null</code> will be returned instead.
 * <p>
 * <b>NOTE:</b> Only the <code>TextureView</code> implementations support getting the bitmap
 * meaning that if the backing implementation is a <code>SurfaceView</code> then the result
 * will always be <code>null</code>
 *
 * @return A {@link Bitmap} representation of the view or <code>null</code>
 */
@Nullable
public Bitmap getBitmap() {
  if (videoViewImpl instanceof TextureView) {
    return ((TextureView) videoViewImpl).getBitmap();
  }
  return null;
}

代码示例来源:origin: Stoick001/SnapchatClone

public void captureImage() {
  FileOutputStream outputPhoto = null;
  try {
    outputPhoto = new FileOutputStream(createImageFile(galleryFolder));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    textureView.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, out);
    out.writeTo(outputPhoto);
    switchFragment(out.toByteArray());
  } catch (Exception e) {
    e.printStackTrace();
  } finally {
    try {
      if (outputPhoto != null) {
        outputPhoto.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: stackoverflow.com

TextureView textureView = (TextureView) findViewById( R.id.texture );
Matrix m = new Matrix();
// Do matrix creation here.
textureView.setTransform( m );

// When you need to get the Bitmap
Bitmap bitmap = textureView.getBitmap();
bitmap = Bitmap.createBitmap( bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), textureView.getTransform( null ), true );

代码示例来源:origin: Tastenkunst/brfv4_android_examples

@Override
      public void onPreviewFrame(byte[] data, Camera camera) {
        Camera.Parameters parameters = camera.getParameters();
        Camera.Size previewSize = parameters.getPreviewSize();
        int format = parameters.getPreviewFormat();

        // TODO: BRFManager should be able to handle raw byte buffers
//                synchronized (BRFv4View.this) {
          if (mFaceDetectionBitmap == null) {
            mFaceDetectionBitmap = mTextureView.getBitmap();
            mHandler.obtainMessage(MSG_NEW_BITMAP).sendToTarget();
          }
//                }
        invalidate();

        camera.addCallbackBuffer(data);
      }
    });

代码示例来源:origin: stackoverflow.com

return  mPreview.getBitmap();

代码示例来源:origin: stackoverflow.com

Toast.makeText(getApplicationContext(), "Capturing Screenshot: " + mPath, Toast.LENGTH_SHORT).show();
Bitmap bm = vv.getBitmap();
if(bm == null)
  Log.e(TAG,"bitmap is null");

代码示例来源:origin: stackoverflow.com

Toast.makeText(getApplicationContext(), "Capturing Screenshot: " + mPath, Toast.LENGTH_SHORT).show();
Bitmap bm = vv.getBitmap();
if(bm == null)
  Log.e(TAG,"bitmap is null");

代码示例来源:origin: RameshBhupathi/ImagePicker-OLX

@Override
  public void check(View view, NoMatchingViewException noViewFoundException) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
      return;
    }
    CameraView cameraView = (CameraView) view;
    TextureView textureView = (TextureView) cameraView.findViewById(R.id.texture_view);
    Bitmap bitmap = textureView.getBitmap();
    int topLeft = bitmap.getPixel(0, 0);
    int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
    int bottomRight = bitmap.getPixel(
        bitmap.getWidth() - 1, bitmap.getHeight() - 1);
    assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft),
        topLeft == center && center == bottomRight);
  }
};

相关文章