mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
add board_getActiveRect to jni, and use it to capture a thumbnail
that's smaller. Scaling is still a problem, though: some but not all grid lines show up.
This commit is contained in:
parent
26f5a0b269
commit
0960e5510c
5 changed files with 59 additions and 7 deletions
|
@ -275,13 +275,25 @@ getIntFromArray( JNIEnv* env, jintArray arr, bool del )
|
|||
{
|
||||
jint* ints = (*env)->GetIntArrayElements(env, arr, 0);
|
||||
int result = ints[0];
|
||||
(*env)->ReleaseIntArrayElements( env, arr, ints, 0);
|
||||
(*env)->ReleaseIntArrayElements( env, arr, ints, 0 );
|
||||
if ( del ) {
|
||||
deleteLocalRef( env, arr );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
setIntInArray( JNIEnv* env, jintArray arr, int index, int val )
|
||||
{
|
||||
jint* ints = (*env)->GetIntArrayElements( env, arr, 0 );
|
||||
#ifdef DEBUG
|
||||
jsize len = (*env)->GetArrayLength( env, arr );
|
||||
XP_ASSERT( len > index );
|
||||
#endif
|
||||
ints[index] = val;
|
||||
(*env)->ReleaseIntArrayElements( env, arr, ints, 0 );
|
||||
}
|
||||
|
||||
jobjectArray
|
||||
makeStringArray( JNIEnv *env, int siz, const XP_UCHAR** vals )
|
||||
{
|
||||
|
|
|
@ -48,6 +48,7 @@ bool getObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
|
|||
|
||||
jintArray makeIntArray( JNIEnv *env, int size, const jint* vals );
|
||||
int getIntFromArray( JNIEnv* env, jintArray arr, bool del );
|
||||
void setIntInArray( JNIEnv* env, jintArray arr, int index, int val );
|
||||
|
||||
jbyteArray makeByteArray( JNIEnv* env, int size, const jbyte* vals );
|
||||
|
||||
|
|
|
@ -640,6 +640,29 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setTrayLoc
|
|||
XWJNI_END();
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_ACTIVERECT
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1getActiveRect
|
||||
( JNIEnv* env, jclass C, jint gamePtr, jobject jrect, jintArray dims )
|
||||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
XP_Rect rect;
|
||||
XP_U16 nCols, nRows;
|
||||
result = board_getActiveRect( state->game.board, &rect, &nCols, &nRows );
|
||||
if ( result ) {
|
||||
setInt( env, jrect, "left", rect.left );
|
||||
setInt( env, jrect, "top", rect.top );
|
||||
setInt( env, jrect, "right", rect.left + rect.width );
|
||||
setInt( env, jrect, "bottom", rect.top + rect.height );
|
||||
setIntInArray( env, dims, 0, nCols );
|
||||
setIntInArray( env, dims, 1, nRows );
|
||||
}
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenDown
|
||||
(JNIEnv *env, jclass C, jint gamePtr, jint xx, jint yy, jbooleanArray barray )
|
||||
|
|
|
@ -940,12 +940,23 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
public Bitmap getScaledBoard()
|
||||
{
|
||||
Bitmap result = null;
|
||||
int divisor = XWPrefs.getThumbScale( m_context );
|
||||
if ( 0 < divisor ) {
|
||||
result = Bitmap.createScaledBitmap( s_bitmap,
|
||||
m_layoutWidth / divisor,
|
||||
m_layoutHeight / divisor,
|
||||
false );
|
||||
if ( GitVersion.THUMBNAIL_SUPPORTED ) {
|
||||
int divisor = XWPrefs.getThumbScale( m_context );
|
||||
|
||||
if ( 0 < divisor ) {
|
||||
int[] dims = new int[2];
|
||||
Rect rect = new Rect();
|
||||
XwJNI.board_getActiveRect( m_jniGamePtr, rect, dims );
|
||||
|
||||
Bitmap tmpb =
|
||||
Bitmap.createBitmap( s_bitmap, rect.left, rect.top,
|
||||
1 + rect.width(), 1 + rect.height() );
|
||||
|
||||
result = Bitmap.createScaledBitmap( tmpb,
|
||||
rect.width() / divisor,
|
||||
rect.height() / divisor,
|
||||
false );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
package org.eehouse.android.xw4.jni;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
|
||||
// Collection of native methods
|
||||
public class XwJNI {
|
||||
|
||||
|
@ -159,6 +162,8 @@ public class XwJNI {
|
|||
public static native void board_setTimerLoc( int gamePtr,
|
||||
int timerLeft, int timerTop,
|
||||
int timerWidth, int timerHeight );
|
||||
public static native boolean board_getActiveRect( int gamePtr, Rect rect,
|
||||
int[] dims );
|
||||
|
||||
public static native boolean board_handlePenDown( int gamePtr,
|
||||
int xx, int yy,
|
||||
|
|
Loading…
Reference in a new issue