android.media.Image.getHeight()方法的使用及代码示例

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

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

Image.getHeight介绍

[英]The height of the image in pixels. For formats where some color channels are subsampled, this is the height of the largest-resolution plane.
[中]图像的高度(以像素为单位)。对于某些颜色通道被二次采样的格式,这是最大分辨率平面的高度。

代码示例

代码示例来源:origin: daniulive/SmarterStreaming

/**
 * Process image data as desired.
 */
@SuppressLint("NewApi")
private void processScreenImage(Image image) {
  if(!isPushing && !isRecording &&!isRTSPPublisherRunning)
  {
    return;
  }
  final Image.Plane[] planes = image.getPlanes();
  width_ = image.getWidth();
  height_ = image.getHeight();
  row_stride_ = planes[0].getRowStride();
  ByteBuffer buf = deepCopy(planes[0].getBuffer());
  synchronized(this)
  {
    data_list.add(buf);
  }
}

代码示例来源:origin: com.harium.android/core

/**
 * Get the crop rectangle associated with this frame.
 * <p>
 * The crop rectangle specifies the region of valid pixels in the image,
 * using coordinates in the largest-resolution plane.
 */
public Rect getCropRect() {
  throwISEIfImageIsInvalid();
  if (mCropRect == null) {
    return new Rect(0, 0, getWidth(), getHeight());
  } else {
    return new Rect(mCropRect); // return a copy
  }
}

代码示例来源:origin: WangShuo1143368701/VideoView

Image image = mImageReader.acquireLatestImage();
int width = image.getWidth();
int height = image.getHeight();
final Image.Plane[] planes = image.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();

代码示例来源:origin: killer8000/FloatingBall

int height = mImage.getHeight();
final Image.Plane[] planes = mImage.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();

代码示例来源:origin: com.harium.android/core

/**
 * Set the crop rectangle associated with this frame.
 * <p>
 * The crop rectangle specifies the region of valid pixels in the image,
 * using coordinates in the largest-resolution plane.
 */
public void setCropRect(Rect cropRect) {
  throwISEIfImageIsInvalid();
  if (cropRect != null) {
    cropRect = new Rect(cropRect);  // make a copy
    if (!cropRect.intersect(0, 0, getWidth(), getHeight())) {
      cropRect.setEmpty();
    }
  }
  mCropRect = cropRect;
}

代码示例来源:origin: goodbranch/ScreenCapture

int height = image.getHeight();
final Image.Plane[] planes = image.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();

代码示例来源:origin: Gutyn/camera2QRcodeReader

buffer.get(data);
int width = img.getWidth();
int height = img.getHeight();
PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(data, width, height);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

代码示例来源:origin: gqjjqg/android-extend

size += buffer.remaining();
CameraFrameData data = new CameraFrameData(image.getWidth(), image.getHeight(), image.getFormat(), size);
      bytes, image.getWidth(), image.getHeight(), image.getFormat(), image.getTimestamp());
  data.setParams(param);

代码示例来源:origin: JustinRoom/JSCKit

private void screenshot(){
  if (mMediaProjection == null)
    return;
  Image image = mImageReader.acquireLatestImage();
  if (image == null)
    return;
  int width = image.getWidth();
  int height = image.getHeight();
  final Image.Plane[] planes = image.getPlanes();
  final ByteBuffer buffer = planes[0].getBuffer();
  int pixelStride = planes[0].getPixelStride();
  int rowStride = planes[0].getRowStride();
  int rowPadding = rowStride - pixelStride * width;
  Bitmap mBitmap = Bitmap.createBitmap(width + rowPadding / pixelStride, height, Bitmap.Config.ARGB_8888);
  mBitmap.copyPixelsFromBuffer(buffer);
  mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height);
  image.close();
  saveBitmapToFile(mBitmap);
}

代码示例来源:origin: kaixuanluo/pc-android-controller-android

int height = image.getHeight();
final Image.Plane[] planes = image.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();

代码示例来源:origin: tranquvis/SimpleSmsRemote

/**
   * Retrieve Bitmap with specific format from ImageReader.
   *
   * @param imageReader the image reader
   * @return bitmap
   */
  @RequiresApi(api = Build.VERSION_CODES.KITKAT)
  public static Bitmap GetBitmapFromImageReader(ImageReader imageReader) {
    Bitmap bitmap;

    //get image buffer
    Image image = imageReader.acquireLatestImage();
    final Image.Plane[] planes = image.getPlanes();
    final ByteBuffer buffer = planes[0].getBuffer();

    int pixelStride = planes[0].getPixelStride();
    int rowStride = planes[0].getRowStride();
    int rowPadding = rowStride - pixelStride * image.getWidth();
    // create bitmap
    bitmap = Bitmap.createBitmap(image.getWidth() + rowPadding / pixelStride, image.getHeight(), Bitmap.Config.ARGB_8888);
    bitmap.copyPixelsFromBuffer(buffer);
    image.close();
    return bitmap;
  }
}

代码示例来源:origin: kaixuanluo/pc-android-controller-android

@Override
protected Bitmap doInBackground(Image... params) {
  if (params == null || params.length < 1 || params[0] == null) {
    L.e(" params is null ...");
    return null;
  }
  Image image = params[0];
  int width = image.getWidth();
  int height = image.getHeight();
  final Image.Plane[] planes = image.getPlanes();
  final ByteBuffer buffer = planes[0].getBuffer();
  //每个像素的间距
  int pixelStride = planes[0].getPixelStride();
  //总的间距
  int rowStride = planes[0].getRowStride();
  image.close();
  int rowPadding = rowStride - pixelStride * width;
  Bitmap bitmap = Bitmap.createBitmap(width + rowPadding / pixelStride, height, Bitmap.Config.ARGB_8888);
  bitmap.copyPixelsFromBuffer(buffer);
  bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
  image.close();
  compressAndWrite(bitmap);
  return null;
}

代码示例来源:origin: gicheonkang/fast-face-android

if (mPreviewWdith != image.getWidth() || mPreviewHeight != image.getHeight()) {
  mPreviewWdith = image.getWidth();
  mPreviewHeight = image.getHeight();

代码示例来源:origin: PaulTR/AndroidDemoProjects

if (previewWidth != image.getWidth() || previewHeight != image.getHeight()) {
 previewWidth = image.getWidth();
 previewHeight = image.getHeight();

代码示例来源:origin: fg607/RelaxFinger

int height = image.getHeight();
final Image.Plane[] planes = image.getPlanes();
final ByteBuffer buffer = planes[0].getBuffer();

代码示例来源:origin: vbier/habpanelviewer

if (ld == null && i != null) {
  ByteBuffer buffer = i.getPlanes()[0].getBuffer();
  ld = new LumaData(buffer, i.getWidth(), i.getHeight());

代码示例来源:origin: org.boofcv/boofcv-android

public static void imageToBoof(Image yuv, ColorFormat colorOutput, ImageBase output, byte[] work) {
    if( BOverrideConvertAndroid.invokeYuv420ToBoof(yuv,colorOutput,output,work))
      return;

    if(ImageFormat.YUV_420_888 != yuv.getFormat() )
      throw new RuntimeException("Unexpected format");

    Image.Plane planes[] = yuv.getPlanes();

    ByteBuffer bufferY = planes[0].getBuffer();
    ByteBuffer bufferU = planes[2].getBuffer();
    ByteBuffer bufferV = planes[1].getBuffer();

    int width = yuv.getWidth();
    int height = yuv.getHeight();

    int strideY = planes[0].getRowStride();
    int strideUV = planes[1].getRowStride();
    int stridePixelUV = planes[1].getPixelStride();

    ConvertYuv420_888.yuvToBoof(
        bufferY,bufferU,bufferV,
        width,height,strideY,strideUV,stridePixelUV,
        colorOutput,output,work);
  }
}

代码示例来源:origin: abrenoch/hyperion-android-grabber

int height = img.getHeight();
int pixelStride = plane.getPixelStride();
int rowStride = plane.getRowStride();

相关文章