当前位置: 首页>>代码示例>>Java>>正文


Java PixelFormat.getPixelFormatInfo方法代码示例

本文整理汇总了Java中android.graphics.PixelFormat.getPixelFormatInfo方法的典型用法代码示例。如果您正苦于以下问题:Java PixelFormat.getPixelFormatInfo方法的具体用法?Java PixelFormat.getPixelFormatInfo怎么用?Java PixelFormat.getPixelFormatInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.PixelFormat的用法示例。


在下文中一共展示了PixelFormat.getPixelFormatInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPreviewCallback

import android.graphics.PixelFormat; //导入方法依赖的package包/类
/** 设置回调 */
protected void setPreviewCallback() {
	Size size = mParameters.getPreviewSize();
	if (size != null) {
		PixelFormat pf = new PixelFormat();
		PixelFormat.getPixelFormatInfo(mParameters.getPreviewFormat(), pf);
		int buffSize = size.width * size.height * pf.bitsPerPixel / 8;
		try {
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.addCallbackBuffer(new byte[buffSize]);
			camera.setPreviewCallbackWithBuffer(this);
		} catch (OutOfMemoryError e) {
			Log.e("Yixia", "startPreview...setPreviewCallback...", e);
		}
		Log.e("Yixia", "startPreview...setPreviewCallbackWithBuffer...width:" + size.width + " height:" + size.height);
	} else {
		camera.setPreviewCallback(this);
	}
}
 
开发者ID:Zhaoss,项目名称:WeiXinRecordedDemo,代码行数:21,代码来源:MediaRecorderBase.java

示例2: tryStartCapture

import android.graphics.PixelFormat; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private int tryStartCapture(int width, int height, int frameRate) {
    if (camera == null) {
        Log.e(TAG, "Camera not initialized %d" + id);
        return -1;
    }

    Log.d(TAG, "tryStartCapture: " + width +
        "x" + height +", frameRate: " + frameRate +
        ", isCaptureRunning: " + isCaptureRunning +
        ", isSurfaceReady: " + isSurfaceReady +
        ", isCaptureStarted: " + isCaptureStarted);

    if (isCaptureRunning || !isCaptureStarted) {
        return 0;
    }

    CaptureCapabilityAndroid currentCapability =
            new CaptureCapabilityAndroid();
    currentCapability.width = width;
    currentCapability.height = height;
    currentCapability.maxFPS = frameRate;
    PixelFormat.getPixelFormatInfo(PIXEL_FORMAT, pixelFormat);

    Camera.Parameters parameters = camera.getParameters();
    parameters.setPreviewSize(currentCapability.width,
            currentCapability.height);
    parameters.setPreviewFormat(PIXEL_FORMAT);
    parameters.setPreviewFrameRate(currentCapability.maxFPS);
    camera.setParameters(parameters);

    int bufSize = width * height * pixelFormat.bitsPerPixel / 8;
    cameraUtils.setCallback(this, numCaptureBuffers, bufSize, camera);

    camera.startPreview();
    previewBufferLock.lock();
    expectedFrameSize = bufSize;
    isCaptureRunning = true;
    previewBufferLock.unlock();

    isCaptureRunning = true;
    return 0;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:44,代码来源:VideoCaptureAndroid.java

示例3: acquireScreenshot

import android.graphics.PixelFormat; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static Bitmap acquireScreenshot(Context context) {
    WindowManager mWinManager = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics metrics = new DisplayMetrics();
    Display display = mWinManager.getDefaultDisplay();
    display.getMetrics(metrics);
    // 屏幕高
    int height = metrics.heightPixels;
    // 屏幕的宽
    int width = metrics.widthPixels;

    int pixelformat = display.getPixelFormat();
    PixelFormat localPixelFormat1 = new PixelFormat();
    PixelFormat.getPixelFormatInfo(pixelformat, localPixelFormat1);
    // 位深
    int deepth = localPixelFormat1.bytesPerPixel;

    byte[] arrayOfByte = new byte[height * width * deepth];
    try {
        // 读取设备缓存,获取屏幕图像流
        InputStream localInputStream = readAsRoot();
        DataInputStream localDataInputStream = new DataInputStream(
                localInputStream);
        localDataInputStream.readFully(arrayOfByte);
        localInputStream.close();

        int[] tmpColor = new int[width * height];
        int r, g, b;
        for (int j = 0; j < width * height * deepth; j += deepth) {
            b = arrayOfByte[j] & 0xff;
            g = arrayOfByte[j + 1] & 0xff;
            r = arrayOfByte[j + 2] & 0xff;
            tmpColor[j / deepth] = (r << 16) | (g << 8) | b | (0xff000000);
        }
        // 构建bitmap
        Bitmap scrBitmap = Bitmap.createBitmap(tmpColor, width, height,
                Bitmap.Config.ARGB_8888);
        return scrBitmap;

    } catch (Exception e) {
        L.d( "#### 读取屏幕截图失败");
        e.printStackTrace();
    }
    return null;

}
 
开发者ID:kaixuanluo,项目名称:pc-android-controller-android,代码行数:48,代码来源:KIKATSCUtil.java


注:本文中的android.graphics.PixelFormat.getPixelFormatInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。