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

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

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

TextureView.getBitmap介绍

暂无

代码示例

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

  1. private void captureValues(@NonNull TransitionValues transitionValues) {
  2. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
  3. return;
  4. }
  5. View view = transitionValues.view;
  6. if (view.getWidth() <= 0 || view.getHeight() <= 0) {
  7. return;
  8. }
  9. Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
  10. if (mFadeBehavior != FADE_BEHAVIOR_REVEAL) {
  11. bounds.offset(view.getLeft(), view.getTop());
  12. }
  13. transitionValues.values.put(PROPNAME_BOUNDS, bounds);
  14. Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),
  15. Bitmap.Config.ARGB_8888);
  16. if (view instanceof TextureView) {
  17. bitmap = ((TextureView) view).getBitmap();
  18. } else {
  19. Canvas c = new Canvas(bitmap);
  20. view.draw(c);
  21. }
  22. transitionValues.values.put(PROPNAME_BITMAP, bitmap);
  23. BitmapDrawable drawable = new BitmapDrawable(view.getResources(), bitmap);
  24. // TODO: lrtb will be wrong if the view has transXY set
  25. drawable.setBounds(bounds);
  26. transitionValues.values.put(PROPNAME_DRAWABLE, drawable);
  27. }

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

  1. private boolean capture() {
  2. String mPath = genSaveFileName(getTitle().toString() + "_", ".png");
  3. File imageFile = new File(mPath);
  4. if (imageFile.exists()) {
  5. imageFile.delete();
  6. }
  7. // create bitmap screen capture
  8. Bitmap bitmap = textureView.getBitmap();
  9. OutputStream outputStream = null;
  10. try {
  11. outputStream = new FileOutputStream(imageFile);
  12. bitmap.compress(Bitmap.CompressFormat.PNG, 90, outputStream);
  13. outputStream.flush();
  14. outputStream.close();
  15. } catch (FileNotFoundException e) {
  16. e.printStackTrace();
  17. return false;
  18. } catch (IOException e) {
  19. e.printStackTrace();
  20. return false;
  21. }
  22. return true;
  23. }

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

  1. private void captureValues(@NonNull TransitionValues transitionValues) {
  2. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
  3. return;
  4. }
  5. View view = transitionValues.view;
  6. if (view.getWidth() <= 0 || view.getHeight() <= 0) {
  7. return;
  8. }
  9. Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
  10. if (mFadeBehavior != FADE_BEHAVIOR_REVEAL) {
  11. bounds.offset(view.getLeft(), view.getTop());
  12. }
  13. transitionValues.values.put(PROPNAME_BOUNDS, bounds);
  14. if (Transition.DBG) {
  15. Log.d(LOG_TAG, "Captured bounds " + transitionValues.values.get(PROPNAME_BOUNDS));
  16. }
  17. Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),
  18. Bitmap.Config.ARGB_8888);
  19. if (view instanceof TextureView) {
  20. bitmap = ((TextureView) view).getBitmap();
  21. } else {
  22. Canvas c = new Canvas(bitmap);
  23. view.draw(c);
  24. }
  25. transitionValues.values.put(PROPNAME_BITMAP, bitmap);
  26. BitmapDrawable drawable = new BitmapDrawable(view.getResources(), bitmap);
  27. // TODO: lrtb will be wrong if the view has transXY set
  28. drawable.setBounds(bounds);
  29. transitionValues.values.put(PROPNAME_DRAWABLE, drawable);
  30. }

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

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

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

  1. /**
  2. * Returns a {@link Bitmap} representation of the current contents of the
  3. * view. If the surface isn't ready or we cannot access it for some reason then
  4. * <code>null</code> will be returned instead.
  5. * <p>
  6. * <b>NOTE:</b> Only the <code>TextureView</code> implementations support getting the bitmap
  7. * meaning that if the backing implementation is a <code>SurfaceView</code> then the result
  8. * will always be <code>null</code>
  9. *
  10. * @return A {@link Bitmap} representation of the view or <code>null</code>
  11. */
  12. @Nullable
  13. public Bitmap getBitmap() {
  14. if (videoViewImpl instanceof TextureView) {
  15. return ((TextureView) videoViewImpl).getBitmap();
  16. }
  17. return null;
  18. }

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

  1. public void captureImage() {
  2. FileOutputStream outputPhoto = null;
  3. try {
  4. outputPhoto = new FileOutputStream(createImageFile(galleryFolder));
  5. ByteArrayOutputStream out = new ByteArrayOutputStream();
  6. textureView.getBitmap().compress(Bitmap.CompressFormat.PNG, 100, out);
  7. out.writeTo(outputPhoto);
  8. switchFragment(out.toByteArray());
  9. } catch (Exception e) {
  10. e.printStackTrace();
  11. } finally {
  12. try {
  13. if (outputPhoto != null) {
  14. outputPhoto.close();
  15. }
  16. } catch (Exception e) {
  17. e.printStackTrace();
  18. }
  19. }
  20. }

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

  1. TextureView textureView = (TextureView) findViewById( R.id.texture );
  2. Matrix m = new Matrix();
  3. // Do matrix creation here.
  4. textureView.setTransform( m );
  5. // When you need to get the Bitmap
  6. Bitmap bitmap = textureView.getBitmap();
  7. bitmap = Bitmap.createBitmap( bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), textureView.getTransform( null ), true );

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

  1. @Override
  2. public void onPreviewFrame(byte[] data, Camera camera) {
  3. Camera.Parameters parameters = camera.getParameters();
  4. Camera.Size previewSize = parameters.getPreviewSize();
  5. int format = parameters.getPreviewFormat();
  6. // TODO: BRFManager should be able to handle raw byte buffers
  7. // synchronized (BRFv4View.this) {
  8. if (mFaceDetectionBitmap == null) {
  9. mFaceDetectionBitmap = mTextureView.getBitmap();
  10. mHandler.obtainMessage(MSG_NEW_BITMAP).sendToTarget();
  11. }
  12. // }
  13. invalidate();
  14. camera.addCallbackBuffer(data);
  15. }
  16. });

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

  1. return mPreview.getBitmap();

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

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

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

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

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

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

相关文章