Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
Remove unused code. Partially addresses #25.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtheis committed May 13, 2015
1 parent 6e0d209 commit 935cdc8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 139 deletions.
24 changes: 0 additions & 24 deletions tess-two/jni/com_googlecode_leptonica_android/readfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,6 @@ jboolean Java_com_googlecode_leptonica_android_ReadFile_nativeReplaceBytes8(JNIE
return JNI_TRUE;
}

jlong Java_com_googlecode_leptonica_android_ReadFile_nativeReadFiles(JNIEnv *env, jclass clazz,
jstring dirName, jstring prefix) {
PIXA *pixad = NULL;

const char *c_dirName = env->GetStringUTFChars(dirName, NULL);
if (c_dirName == NULL) {
LOGE("could not extract dirName string!");
return (jlong) NULL;
}

const char *c_prefix = env->GetStringUTFChars(prefix, NULL);
if (c_prefix == NULL) {
LOGE("could not extract prefix string!");
return (jlong) NULL;
}

pixad = pixaReadFiles(c_dirName, c_prefix);

env->ReleaseStringUTFChars(dirName, c_dirName);
env->ReleaseStringUTFChars(prefix, c_prefix);

return (jlong) pixad;
}

jlong Java_com_googlecode_leptonica_android_ReadFile_nativeReadFile(JNIEnv *env, jclass clazz,
jstring fileName) {
PIX *pixd = NULL;
Expand Down
48 changes: 0 additions & 48 deletions tess-two/jni/com_googlecode_leptonica_android/writefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,54 +48,6 @@ jint Java_com_googlecode_leptonica_android_WriteFile_nativeWriteBytes8(JNIEnv *e
return (jint)(w * h);
}

jboolean Java_com_googlecode_leptonica_android_WriteFile_nativeWriteFiles(JNIEnv *env,
jclass clazz,
jlong nativePixa,
jstring rootName,
jint format) {
PIXA *pixas = (PIXA *) nativePixa;

const char *c_rootName = env->GetStringUTFChars(rootName, NULL);
if (c_rootName == NULL) {
LOGE("could not extract rootName string!");
return JNI_FALSE;
}

jboolean result = JNI_TRUE;

if (pixaWriteFiles(c_rootName, pixas, (l_uint32) format)) {
LOGE("could not write pixa data to %s", c_rootName);
result = JNI_FALSE;
}

env->ReleaseStringUTFChars(rootName, c_rootName);

return result;
}

jbyteArray Java_com_googlecode_leptonica_android_WriteFile_nativeWriteMem(JNIEnv *env,
jclass clazz,
jlong nativePix,
jint format) {
PIX *pixs = (PIX *) nativePix;

l_uint8 *data;
size_t size;

if (pixWriteMem(&data, &size, pixs, (l_uint32) format)) {
LOGE("Failed to write pix data");
return NULL;
}

// TODO Can we just use the byte array directly?
jbyteArray array = env->NewByteArray(size);
env->SetByteArrayRegion(array, 0, size, (jbyte *) data);

free(data);

return array;
}

jboolean Java_com_googlecode_leptonica_android_WriteFile_nativeWriteImpliedFormat(JNIEnv *env,
jclass clazz,
jlong nativePix,
Expand Down
22 changes: 0 additions & 22 deletions tess-two/src/com/googlecode/leptonica/android/ReadFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,6 @@ public static boolean replaceBytes8(Pix pixs, byte[] pixelData, int width, int h
return nativeReplaceBytes8(pixs.mNativePix, pixelData, width, height);
}

/**
* Creates a Pixa object from encoded files in a directory. Supported
* formats are BMP and JPEG.
*
* @param dir The directory containing the files.
* @param prefix The prefix of the files to load into a Pixa.
* @return a Pixa object containing one Pix for each file
*/
public static Pixa readFiles(File dir, String prefix) {
if (dir == null)
throw new IllegalArgumentException("Directory must be non-null");
if (!dir.exists())
throw new IllegalArgumentException("Directory does not exist");
if (!dir.canRead())
throw new IllegalArgumentException("Cannot read directory");

// TODO: Remove or fix this.
throw new RuntimeException("readFiles() is not current supported");
}

/**
* Creates a Pix object from encoded file data. Supported formats are BMP
* and JPEG.
Expand Down Expand Up @@ -207,8 +187,6 @@ public static Pix readBitmap(Bitmap bmp) {

private static native boolean nativeReplaceBytes8(long nativePix, byte[] data, int w, int h);

private static native long nativeReadFiles(String dirname, String prefix);

private static native long nativeReadFile(String filename);

private static native long nativeReadBitmap(Bitmap bitmap);
Expand Down
45 changes: 0 additions & 45 deletions tess-two/src/com/googlecode/leptonica/android/WriteFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,47 +80,6 @@ public static int writeBytes8(Pix pixs, byte[] data) {
return bytesWritten;
}

/**
* Writes all the images in a Pixa array to individual files using the
* specified format. The output file extension will be determined by the
* format.
* <p>
* Output file names will take the format <path>/<prefix><index>.<extension>
*
* @param pixas The source Pixa image array.
* @param path The output directory.
* @param prefix The prefix to give output files.
* @param format The format to use for output files.
* @return <code>true</code> on success
*/
public static boolean writeFiles(Pixa pixas, File path, String prefix, int format) {
if (pixas == null)
throw new IllegalArgumentException("Source pixa must be non-null");
if (path == null)
throw new IllegalArgumentException("Destination path non-null");
if (prefix == null)
throw new IllegalArgumentException("Filename prefix must be non-null");

//String rootname = new File(path, prefix).getAbsolutePath();

throw new RuntimeException("writeFiles() is not currently supported");
}

/**
* Write a Pix to a byte array using the specified encoding from
* Constants.IFF_*.
*
* @param pixs The source image.
* @param format A format from Constants.IFF_*.
* @return a byte array containing encoded bytes
*/
public static byte[] writeMem(Pix pixs, int format) {
if (pixs == null)
throw new IllegalArgumentException("Source pix must be non-null");

throw new RuntimeException("writeMem() is not currently supported");
}

/**
* Writes a Pix to file using the file extension as the output format;
* supported formats are .jpg or .jpeg for JPEG and .bmp for bitmap.
Expand Down Expand Up @@ -199,10 +158,6 @@ public static Bitmap writeBitmap(Pix pixs) {

private static native int nativeWriteBytes8(long nativePix, byte[] data);

private static native boolean nativeWriteFiles(long nativePix, String rootname, int format);

private static native byte[] nativeWriteMem(long nativePix, int format);

private static native boolean nativeWriteImpliedFormat(
long nativePix, String fileName, int quality, boolean progressive);

Expand Down

0 comments on commit 935cdc8

Please sign in to comment.