Ejemplo n.º 1
0
JNIEXPORT void JNICALL Java_com_congnt_ndkguide_Store_setInteger(JNIEnv* pEnv,
		jobject pThis, jstring pKey, jint pInteger) {
	StoreEntry* lEntry = allocateEntry(pEnv, &gStore, pKey);
	if (lEntry != NULL) {
		lEntry->mType = StoreType_Integer;
		lEntry->mValue.mInteger = pInteger;
	}
}
JNIEXPORT void JNICALL Java_com_example_micthebick_ndktest_Store_setInteger
        (JNIEnv *pEnv, jobject pThis, jstring pKey, jint pInteger){

    StoreEntry* lEntry  =   allocateEntry(pEnv, &mStore, pKey);
    if (lEntry != NULL){
        lEntry->mType   =   StoreType_Integer;
        lEntry->mValue.mInteger =   pInteger;
    }
}
Ejemplo n.º 3
0
// Create an entry with a single EXIF LONG (32-bit value) and place it in
// |exifData|.
static bool createEntry(ExifData* exifData,
                        ExifIfd ifd,
                        int tag,
                        int value) {
    removeExistingEntry(exifData, ifd, tag);
    ExifByteOrder byteOrder = exif_data_get_byte_order(exifData);
    ExifEntry* entry = allocateEntry(tag, EXIF_FORMAT_LONG, 1);
    exif_content_add_entry(exifData->ifd[ifd], entry);
    exif_set_long(entry->data, byteOrder, value);

    // Unref entry after changing owner to the ExifData struct
    exif_entry_unref(entry);
    return true;
}
Ejemplo n.º 4
0
// Create an entry and place it in |exifData|, the entry contains the raw data
// pointed to by |data| of length |size|.
static bool createEntry(ExifData* exifData,
                        ExifIfd ifd,
                        int tag,
                        const unsigned char* data,
                        size_t size,
                        ExifFormat format = EXIF_FORMAT_UNDEFINED) {
    removeExistingEntry(exifData, ifd, tag);
    ExifEntry* entry = allocateEntry(tag, format, size);
    memcpy(entry->data, data, size);
    exif_content_add_entry(exifData->ifd[ifd], entry);
    // Unref entry after changing owner to the ExifData struct
    exif_entry_unref(entry);
    return true;
}
Ejemplo n.º 5
0
JNIEXPORT void JNICALL Java_com_congnt_ndkguide_Store_setColor(JNIEnv* pEnv,
		jobject pThis, jstring pKey, jobject pColor) {
	jobject lColor = (*pEnv)->NewGlobalRef(pEnv, pColor);
	if (lColor == NULL) {
		return;
	}
	StoreEntry* lEntry = allocateEntry(pEnv, &gStore, pKey);
	if (lEntry != NULL) {
		lEntry->mType = StoreType_Color;
		lEntry->mValue.mColor = lColor;
	} else {
		(*pEnv)->DeleteGlobalRef(pEnv, lColor);
	}
}
Ejemplo n.º 6
0
JNIEXPORT void JNICALL Java_com_congnt_ndkguide_Store_setString(JNIEnv* pEnv,
		jobject pThis, jstring pKey, jstring pString) {
	const char* lStringTmp = (*pEnv)->GetStringUTFChars(pEnv, pString, NULL);
	if (lStringTmp == NULL) {
		return;
	}
	StoreEntry* lEntry = allocateEntry(pEnv, &gStore, pKey);
	if (lEntry != NULL) {
		lEntry->mType = StoreType_String;
		jsize lStringLength = (*pEnv)->GetStringUTFLength(pEnv, pString);
		lEntry->mValue.mString = (char*) malloc(
				sizeof(char) * (lStringLength + 1));
		strcpy(lEntry->mValue.mString, lStringTmp);
	}
	(*pEnv)->ReleaseStringUTFChars(pEnv, pString, lStringTmp);
}
Ejemplo n.º 7
0
JNIEXPORT void JNICALL Java_com_congnt_ndkguide_Store_setIntegerArray(
		JNIEnv* pEnv, jobject pThis, jstring pKey, jintArray pIntegerArray) {
	jsize lLength = (*pEnv)->GetArrayLength(pEnv, pIntegerArray);
	int32_t* lArray = (int32_t*) malloc(lLength * sizeof(int32_t));
	(*pEnv)->GetIntArrayRegion(pEnv, pIntegerArray, 0, lLength, lArray);
	if ((*pEnv)->ExceptionCheck(pEnv)) {
		free(lArray);
		return;
	}

	StoreEntry* lEntry = allocateEntry(pEnv, &gStore, pKey);
	if (lEntry != NULL) {
		lEntry->mType = StoreType_ArrayInteger;
		lEntry->mLength = lLength;
		lEntry->mValue.mIntegerArray = lArray;
	} else {
		free(lArray);
		return;
	}
}
Ejemplo n.º 8
0
JNIEXPORT void JNICALL Java_com_example_store_Store_setColorArray
  (JNIEnv *pEnv, jobject pThis, jstring pKey, jobjectArray pColorArray)
{
	jsize lLength = (*pEnv)->GetArrayLength(pEnv, pColorArray);
	jobject* lArray = (jobject*)malloc(lLength*sizeof(jobject));
	int32_t i,j;
	for(i = 0; i<lLength;++i){
		jobject lLocalColor = (*pEnv)->GetObjectArrayElement(pEnv, pColorArray, i);
		if(lLocalColor == NULL)
		{
			for(j =0;j<i;++j){
				(*pEnv)->DeleteGlobalRef(pEnv, lArray[j]);
			}
			free(lArray);
			return;
		}
		lArray[i] = (*pEnv)->NewGlobalRef(pEnv, lLocalColor);
		if(lArray[i] == NULL)
		{
			for(j =0;j<i;++j){
				(*pEnv)->DeleteGlobalRef(pEnv, lArray[j]);
			}
			free(lArray);
			return;
		}
		(*pEnv)->DeleteLocalRef(pEnv, lLocalColor);
	}
	StoreEntry* lEntry = allocateEntry(pEnv, &gStore, pKey);
	if(lEntry != NULL){
		lEntry->mType = StoreType_ColorArray;
		lEntry->mLength = lLength;
		lEntry->mValue.mColorArray = lArray;
	}else{
		for(j = 0;j<i;++j){
			(*pEnv)->DeleteGlobalRef(pEnv, lArray[j]);
		}
		free(lArray);
	}

}
Ejemplo n.º 9
0
static bool createEntry(ExifData* exifData,
                        ExifIfd ifd,
                        int tag,
                        const float (&values)[N],
                        float denominator = 1000.0) {
    removeExistingEntry(exifData, ifd, tag);
    ExifByteOrder byteOrder = exif_data_get_byte_order(exifData);
    ExifEntry* entry = allocateEntry(tag, EXIF_FORMAT_RATIONAL, N);
    exif_content_add_entry(exifData->ifd[ifd], entry);
    unsigned int rationalSize = exif_format_get_size(EXIF_FORMAT_RATIONAL);
    for (size_t i = 0; i < N; ++i) {
        ExifRational rational = {
            static_cast<uint32_t>(values[i] * denominator),
            static_cast<uint32_t>(denominator)
        };

        exif_set_rational(&entry->data[i * rationalSize], byteOrder, rational);
    }

    // Unref entry after changing owner to the ExifData struct
    exif_entry_unref(entry);
    return true;
}