android - alloc native buffer and use in JAVA? -


i have bitmap should manipulate both in c++ , java sides. therefore, according this post allocated buffer in c++ , passed reference java. in java filled buffer bitmap using copypixelstobuffer method. when tried create bitmap buffer(without manipulations) decodebytearray returned null. , don't understand mistak. below code used.

 bitmapfactory.options options = new bitmapfactory.options();     options.inpreferredconfig = bitmap.config.argb_8888;     mcurrentbitmap = bitmapfactory.decodefile(hardcodedpath, options);      // 4- bytes count per pixel     bytescount = mcurrentbitmap.getwidth() * mcurrentbitmap.getheight() * 4;      pixels = (bytebuffer) allocnativebuffer(bytescount);     pixels.order(byteorder.nativeorder());      mcurrentbitmap.copypixelstobuffer(pixels);     pixels.flip();     pixels.order(byteorder.big_endian);     byte[] bitmapdata = new byte[pixels.remaining()];      pixels.get(bitmapdata);      bitmapfactory.options opt = new bitmapfactory.options();     opt.indither = true;     opt.inpreferredconfig = bitmap.config.argb_8888;      bitmap bitmap = bitmapfactory.decodebytearray(bitmapdata, 0, bitmapdata.length, opt); 

any comments , suggestions appreciated.

here how it.

bytebuffer mpixels = bytebuffer.allocatedirect( savewidth*saveheight*4).order(byteorder.nativeorder()); gles20.glreadpixels(0, 0, mwidth, mheight, gles20.gl_rgba, gles20.gl_unsigned_byte, mpixels);

resultbitmap = bitmap.createbitmap(mwidth, mheight, config.argb_8888);  resultbitmap.copypixelsfrombuffer(mpixels); 


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -