diff options
author | Tor Lillqvist <tlillqvist@suse.com> | 2012-05-31 16:11:44 +0300 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2012-05-31 16:20:53 +0300 |
commit | 9776138e973e22cfd4ae418782ab87d01335ad22 (patch) | |
tree | 784cebafe3362d5c5a12314a4712f7fcf29ec2da /sal | |
parent | Uploading new libwps 0.2.7 (diff) | |
download | core-9776138e973e22cfd4ae418782ab87d01335ad22.tar.gz core-9776138e973e22cfd4ae418782ab87d01335ad22.zip |
Add a BGR to RGBA twiddling JNI function
Change-Id: Iafa2c1805eea2f521479dc97d5668d82b1c91bef
Diffstat (limited to 'sal')
-rw-r--r-- | sal/android/lo-bootstrap.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c index 9adadef636ce..fed7a4d5e271 100644 --- a/sal/android/lo-bootstrap.c +++ b/sal/android/lo-bootstrap.c @@ -1862,6 +1862,50 @@ Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env, } __attribute__ ((visibility("default"))) +void +Java_org_libreoffice_android_Bootstrap_twiddle_1BGR_1to_1RGBA(JNIEnv* env, + jobject clazz, + jbyteArray source, + jint offset, + jint width, + jint height, + jobject destination) +{ + jbyte *dst = (jbyte*) (*env)->GetDirectBufferAddress(env, destination); + void *a = (*env)->GetPrimitiveArrayCritical(env, source, NULL); + jbyte *src = ((jbyte *) a) + offset; + + jbyte *srcp; + jbyte *dstp = dst; + int step = ((((width * 3) - 1) / 4) + 1) * 4; + + int i, j; + + (void) clazz; + + if (height > 0) { + srcp = src + step * (height - 1); + step = -step; + } else { + srcp = src; + } + + LOGI("twiddle: src=%p, srcp=%p, dstp=%p, step=%d", src, srcp, dstp, step); + + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) { + *dstp++ = srcp[j*3+2]; + *dstp++ = srcp[j*3+1]; + *dstp++ = srcp[j*3+0]; + *dstp++ = 0xFF; + } + srcp += step; + } + + (*env)->ReleasePrimitiveArrayCritical(env, source, a, 0); +} + +__attribute__ ((visibility("default"))) JavaVM * lo_get_javavm(void) { |