MCPcopy Create free account
hub / github.com/buggins/coolreader / lock

Method lock

android/jni/cr3java.cpp:214–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212 int (*AndroidBitmap_unlockPixels)(JNIEnv* env, jobject jbitmap);
213public:
214 virtual LVDrawBuf * lock(JNIEnv* env, jobject jbitmap) {
215 //CRLog::trace("JNIGraphicsLib::lock entered");
216 AndroidBitmapInfo info;
217 if ( ANDROID_BITMAP_RESUT_SUCCESS!=AndroidBitmap_getInfo(env, jbitmap, &info) ) {
218 CRLog::error("BitmapAccessor : cannot get bitmap info");
219 return NULL;
220 }
221 int width = info.width;
222 int height = info.height;
223 int stride = info.stride;
224 int format = info.format;
225 if ( format!=ANDROID_BITMAP_FORMAT_RGBA_8888 && format!=ANDROID_BITMAP_FORMAT_RGB_565 && format!=8 ) {
226 CRLog::error("BitmapAccessor : bitmap format %d is not yet supported", format);
227 return NULL;
228 }
229 int bpp = (format==ANDROID_BITMAP_FORMAT_RGBA_8888) ? 32 : 16;
230 //CRLog::trace("JNIGraphicsLib::lock info: %d (%d) x %d", width, stride, height);
231 lUInt8 * pixels = NULL;
232 if ( ANDROID_BITMAP_RESUT_SUCCESS!=AndroidBitmap_lockPixels(env, jbitmap, (void**)&pixels) ) {
233 CRLog::error("AndroidBitmap_lockPixels failed");
234 pixels = NULL;
235 }
236 //CRLog::trace("JNIGraphicsLib::lock pixels locked!" );
237 return new LVColorDrawBufEx( width, height, pixels, bpp );
238 }
239 virtual void unlock(JNIEnv* env, jobject jbitmap, LVDrawBuf * buf ) {
240 LVColorDrawBufEx * bmp = (LVColorDrawBufEx*)buf;
241 bmp->convert();

Calls

no outgoing calls

Tested by

no test coverage detected