Android picture call back data is null

前端 未结 1 446
离开以前
离开以前 2021-02-14 17:52

I am using camera code for Android after taking the picture the byte[] imageData parameter is null, I don\'t know why.

package com.pictures;

import java.io.Buff         


        
1条回答
  •  死守一世寂寞
    2021-02-14 18:18

    Ok, I see the problem. You are reusing picture callback for both raw and jpeg callbacks. ANd from javadoc you can read:

    Triggers an asynchronous image capture. The camera service will initiate a series of callbacks to the application as the image capture progresses. The shutter callback occurs after the image is captured. This can be used to trigger a sound to let the user know that image has been captured. The raw callback occurs when the raw image data is available (NOTE: the data will be null if there is no raw image callback buffer available or the raw image callback buffer is not large enough to hold the raw image). The postview callback occurs when a scaled, fully processed postview image is available (NOTE: not all hardware supports this). The jpeg callback occurs when the compressed image is available. If the application does not need a particular callback, a null can be passed instead of a callback method.

    So if it was called as raw callback, data could be null. If you do not like raw data, just use:

     mCamera.takePicture(null, null, mPictureCallback);
    

    0 讨论(0)
提交回复
热议问题