Forums - Use fcvScaleDownBy2 get mess image

1 post / 0 new
Use fcvScaleDownBy2 get mess image
Leox
Join Date: 30 Jul 12
Posts: 2
Posted: Sun, 2012-12-16 18:58

Hi everyone:

I use FastCV like this:

// 1st.Check aligned; 2nd return the image data to JAVA layer. 3rd set the bitmap to ImageView

/////////////////////////////// 1st setp in JNI //////////////////////////////////////////////////////

jboolean isCopy = 0;

jbyte* jimgData = NULL;

jimgData = env->GetByteArrayElements(src, &isCopy);

uint8_t* pJimgData = (uint8_t*) jimgData;

if ((int) jimgData & 0xF) {

int size = srcWidth * srcHeight * bytesPerPixel;

uint8_t* alignedImgBuf = (uint8_t*) fcvMemAlloc(size, 16);

memcpy(alignedImgBuf, jimgData, size);

pJimgData = alignedImgBuf;

}

uint8_t* dstImg = (uint8_t*) fcvMemAlloc(srcWidth * srcHeight, 16);

fcvScaleDownBy2u8(pJimgData, srcWidth, srcHeight, dstImg);

/////////////////////// 2nd step in JNI /////////////////////////////////////

jbyte* dstArray = (env)->GetByteArrayElements(dst, 0);

jsize len = (env)->GetArrayLength(dst);

for (int i = 0; i < len; i++) {

dstArray[i] = dstImg[i];

}

////////////////////////// 3rd step in JAVA/////////////////////////////

ByteBuffer dstBuf = ByteBuffer.wrap(dstArray);

Bitmap dstBitmap = Bitmap.createBitmap(dstWidth, dstHeight, Config.ARGB_8888);//dstWidth is half of origin width

dstBitmap.copyPixelsFromBuffer(dstBuf);

 

But the bitmap is mess after calling ImageView's setImageBitmap.

 

  • Up0
  • Down0

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.