Пример #1
0
/*
 * Class:     nitf_BandInfo
 * Method:    setLookupTable
 * Signature: (Lnitf/LookupTable;)V
 */
JNIEXPORT void JNICALL Java_nitf_BandInfo_setLookupTable
    (JNIEnv * env, jobject self, jobject lookupTable)
{
    nitf_BandInfo *info = _GetObj(env, self);
    jclass lutClass;            /* the class for the LUT */
    jmethodID methodID;
    nitf_LookupTable *lut = NULL;       /* the LUT */
    nitf_Error error;           /* temp error object */

    /* get the class, method, and C object */
    lutClass = (*env)->GetObjectClass(env, lookupTable);
    methodID = (*env)->GetMethodID(env, lutClass, "getAddress", "()J");
    lut =
        (nitf_LookupTable *) (*env)->CallLongMethod(env, lookupTable,
                                                    methodID);

    /* if alreay has a LUT, release it to Java */
    if (info->lut)
    {
        _ManageObject(env, (jlong)info->lut, JNI_TRUE);
    }
    /* set the lut */
    info->lut = lut;

    /* set the tables and entries field in the BandInfo object */
    nitf_Field_setUint32(info->numLUTs, lut->tables, &error);
    nitf_Field_setUint32(info->bandEntriesPerLUT, lut->entries, &error);
    
    /* tell Java not to manage it */
    _ManageObject(env, (jlong)info->lut, JNI_FALSE);

    return;
}
Пример #2
0
/*
 * Class:     nitf_ImageSource
 * Method:    addBand
 * Signature: (Lnitf/BandSource;)Z
 */
JNIEXPORT jboolean JNICALL Java_nitf_ImageSource_addBand
    (JNIEnv * env, jobject self, jobject jBandSource)
{
    nitf_ImageSource *source = _GetObj(env, self);
    nitf_BandSource *bandSource;
    nitf_Error error;
    jclass bandSourceClass = (*env)->FindClass(env, "nitf/BandSource");
    jmethodID methodID =
        (*env)->GetMethodID(env, bandSourceClass, "getAddress", "()J");

    bandSource = (nitf_BandSource *) (*env)->CallLongMethod(
            env, jBandSource, methodID);

    if (!bandSource)
    {
        return JNI_FALSE;
    }

    if (!nitf_ImageSource_addBand(source, bandSource, &error))
    {
        _ThrowNITFException(env, error.message);
        return JNI_FALSE;
    }

    /* Now, tell Java not to manage it anymore */
    _ManageObject(env, (jlong)bandSource, JNI_FALSE);

    return JNI_TRUE;
}
Пример #3
0
JNIEXPORT jobject JNICALL Java_nitf_DESubheader_setSubheaderFields
  (JNIEnv *env, jobject self, jobject subheaderFields)
{
    nitf_DESubheader *header = _GetObj(env, self);
    jobject tre = NULL;
    jmethodID initMethod = NULL, addressMethod = NULL;
    nitf_TRE *newTRE = NULL, *clonedTRE = NULL;
    jclass treClass = (*env)->FindClass(env, "nitf/TRE");
    nitf_Error error;

    if (subheaderFields != NULL)
    {
        initMethod = (*env)->GetMethodID(env, treClass, "<init>", "(J)V");
        addressMethod = (*env)->GetMethodID(env, treClass, "getAddress", "()J");

        /* get the address of the new one passed in */
        newTRE = (nitf_TRE*) (*env)->CallLongMethod(env, subheaderFields,
                                                    addressMethod);

        /* clone it */
        clonedTRE = nitf_TRE_clone(newTRE, &error);
        if (!clonedTRE)
        {
            _ThrowNITFException(env, error.message);
            return NULL;
        }
    }

    /* get the current TRE object, and tell Java we're done with it */
    if (header->subheaderFields)
    {
        _ManageObject(env, (jlong)header->subheaderFields, JNI_TRUE);
    }

    /* set the cloned one to the subheaderFields */
    header->subheaderFields = clonedTRE;

    if (clonedTRE != NULL)
    {
        /* create a new Java TRE from the clone and tell Java not to manage it */
        tre = _NewObject(env, (jlong)header->subheaderFields, "nitf/TRE");
        _ManageObject(env, (jlong)header->subheaderFields, JNI_FALSE);
    }
    return tre;
}
Пример #4
0
/*
 * Class:     nitf_DESubheader
 * Method:    getSubheaderFields
 * Signature: ()Lnitf/TRE;
 */
JNIEXPORT jobject JNICALL Java_nitf_DESubheader_getSubheaderFields
    (JNIEnv * env, jobject self)
{
    nitf_DESubheader *header = _GetObj(env, self);
    jobject tre = NULL;

    if (header->subheaderFields)
    {
        tre = _NewObject(env, (jlong)header->subheaderFields, "nitf/TRE");
        _ManageObject(env, (jlong)header->subheaderFields, JNI_FALSE);
    }
    return tre;
}
Пример #5
0
/*
 * Class:     nitf_BandInfo
 * Method:    getLookupTable
 * Signature: ()Lnitf/LookupTable;
 */
JNIEXPORT jobject JNICALL Java_nitf_BandInfo_getLookupTable
    (JNIEnv * env, jobject self)
{
    nitf_BandInfo *info = _GetObj(env, self);
    jobject lut = NULL;

    if (info->lut)
    {
        lut = _NewObject(env, (jlong)info->lut, "nitf/LookupTable");
        /* tell Java not to manage it */
        _ManageObject(env, (jlong)info->lut, JNI_FALSE);
    }
    return lut;
}