2014-06-20 4 views
0

내가 다음 코드를 사용하여 비트 맵 YUV 형식에서 카메라 미리보기 프레임을 변환하려고 :이 코드는 넥서스 7에 안드로이드 4.1이 휴대폰에 확인 작동하지만 안드로이드 Renderscript은 넥서스 7 원인 오류에 대한 할당을 만들

mYuvToRgbScript = ScriptIntrinsicYuvToRGB.create(mRs, Element.RGBA_8888(mRs)); 
    final Allocation allocationIn = Allocation.createSized(mRs, Element.U8(mRs), 
      (mPreviewWidth * mPreviewHeight) + ((mPreviewHeight/2) * (mPreviewWidth/2) * 2)); 
    allocationIn.copyFrom(mPreviewFrame); 

    final Bitmap previewBitmap = Bitmap.createBitmap(mPreviewWidth, mPreviewHeight, Bitmap.Config.ARGB_8888); 
    final Allocation allocationOut = Allocation.createFromBitmap(mRs, previewBitmap); 

    mYuvToRgbScript.setInput(allocationIn); 
    mYuvToRgbScript.forEach(allocationOut); 

    allocationIn.destroy(); 
    allocationOut.destroy(); 

    if (previewBitmap != null) { 
     return previewBitmap; 
    } else 
     return null; 

(2013) android 4.4.3 다음 줄이 모든 미리보기 프레임에 표시됩니다.

W/Adreno-RS﹕ <rsdVendorAllocationSetupTexture:647>: ERROR: Runtime texture creation failed err: -10 image: 0x0 alloc: 0xad720000 
W/Adreno-RS﹕ <rsdVendorAllocationSetupTexture:649>: ERROR: Runtime texture creation failed type: 8 kind: 0 eleSize: 1 

전환이 발생하지 않습니다.

final Allocation allocationIn = Allocation.createSized(mRs, Element.U8(mRs), 
      (mPreviewWidth * mPreviewHeight) + ((mPreviewHeight/2) * (mPreviewWidth/2) * 2)); 

은 또한 내가 다른 allocationIn 생성 시도 : 일부 디버깅 이런 로그 메시지를 발생 선 위치

final Type.Builder tb = new Type.Builder(mRs, Element.U8(mRs)); 
    tb.setX(mPreviewFrame.length); 
    final Allocation allocationIn = Allocation.createTyped(mRs, tb.create(), Allocation.USAGE_SCRIPT); 

이 있지만, 동일한 에러 로그 라인을 일으키는 어떠한 변환이 일어나지 않는다. 어떤 생각으로 그것을 고치는 방법?

답변

3

할당을 다시 미리보기 비트 맵에 복사하는 것을 잊어 버리는 것입니다. forEach() 호출 후, 다음을 수행해야합니다.

allocationOut.copyTo(previewBitmap);