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

Commit 935cdc8

Browse files
committed
Remove unused code. Partially addresses #25.
1 parent 6e0d209 commit 935cdc8

File tree

4 files changed

+0
-139
lines changed

4 files changed

+0
-139
lines changed

tess-two/jni/com_googlecode_leptonica_android/readfile.cpp

-24
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,6 @@ jboolean Java_com_googlecode_leptonica_android_ReadFile_nativeReplaceBytes8(JNIE
9393
return JNI_TRUE;
9494
}
9595

96-
jlong Java_com_googlecode_leptonica_android_ReadFile_nativeReadFiles(JNIEnv *env, jclass clazz,
97-
jstring dirName, jstring prefix) {
98-
PIXA *pixad = NULL;
99-
100-
const char *c_dirName = env->GetStringUTFChars(dirName, NULL);
101-
if (c_dirName == NULL) {
102-
LOGE("could not extract dirName string!");
103-
return (jlong) NULL;
104-
}
105-
106-
const char *c_prefix = env->GetStringUTFChars(prefix, NULL);
107-
if (c_prefix == NULL) {
108-
LOGE("could not extract prefix string!");
109-
return (jlong) NULL;
110-
}
111-
112-
pixad = pixaReadFiles(c_dirName, c_prefix);
113-
114-
env->ReleaseStringUTFChars(dirName, c_dirName);
115-
env->ReleaseStringUTFChars(prefix, c_prefix);
116-
117-
return (jlong) pixad;
118-
}
119-
12096
jlong Java_com_googlecode_leptonica_android_ReadFile_nativeReadFile(JNIEnv *env, jclass clazz,
12197
jstring fileName) {
12298
PIX *pixd = NULL;

tess-two/jni/com_googlecode_leptonica_android/writefile.cpp

-48
Original file line numberDiff line numberDiff line change
@@ -48,54 +48,6 @@ jint Java_com_googlecode_leptonica_android_WriteFile_nativeWriteBytes8(JNIEnv *e
4848
return (jint)(w * h);
4949
}
5050

51-
jboolean Java_com_googlecode_leptonica_android_WriteFile_nativeWriteFiles(JNIEnv *env,
52-
jclass clazz,
53-
jlong nativePixa,
54-
jstring rootName,
55-
jint format) {
56-
PIXA *pixas = (PIXA *) nativePixa;
57-
58-
const char *c_rootName = env->GetStringUTFChars(rootName, NULL);
59-
if (c_rootName == NULL) {
60-
LOGE("could not extract rootName string!");
61-
return JNI_FALSE;
62-
}
63-
64-
jboolean result = JNI_TRUE;
65-
66-
if (pixaWriteFiles(c_rootName, pixas, (l_uint32) format)) {
67-
LOGE("could not write pixa data to %s", c_rootName);
68-
result = JNI_FALSE;
69-
}
70-
71-
env->ReleaseStringUTFChars(rootName, c_rootName);
72-
73-
return result;
74-
}
75-
76-
jbyteArray Java_com_googlecode_leptonica_android_WriteFile_nativeWriteMem(JNIEnv *env,
77-
jclass clazz,
78-
jlong nativePix,
79-
jint format) {
80-
PIX *pixs = (PIX *) nativePix;
81-
82-
l_uint8 *data;
83-
size_t size;
84-
85-
if (pixWriteMem(&data, &size, pixs, (l_uint32) format)) {
86-
LOGE("Failed to write pix data");
87-
return NULL;
88-
}
89-
90-
// TODO Can we just use the byte array directly?
91-
jbyteArray array = env->NewByteArray(size);
92-
env->SetByteArrayRegion(array, 0, size, (jbyte *) data);
93-
94-
free(data);
95-
96-
return array;
97-
}
98-
9951
jboolean Java_com_googlecode_leptonica_android_WriteFile_nativeWriteImpliedFormat(JNIEnv *env,
10052
jclass clazz,
10153
jlong nativePix,

tess-two/src/com/googlecode/leptonica/android/ReadFile.java

-22
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,6 @@ public static boolean replaceBytes8(Pix pixs, byte[] pixelData, int width, int h
114114
return nativeReplaceBytes8(pixs.mNativePix, pixelData, width, height);
115115
}
116116

117-
/**
118-
* Creates a Pixa object from encoded files in a directory. Supported
119-
* formats are BMP and JPEG.
120-
*
121-
* @param dir The directory containing the files.
122-
* @param prefix The prefix of the files to load into a Pixa.
123-
* @return a Pixa object containing one Pix for each file
124-
*/
125-
public static Pixa readFiles(File dir, String prefix) {
126-
if (dir == null)
127-
throw new IllegalArgumentException("Directory must be non-null");
128-
if (!dir.exists())
129-
throw new IllegalArgumentException("Directory does not exist");
130-
if (!dir.canRead())
131-
throw new IllegalArgumentException("Cannot read directory");
132-
133-
// TODO: Remove or fix this.
134-
throw new RuntimeException("readFiles() is not current supported");
135-
}
136-
137117
/**
138118
* Creates a Pix object from encoded file data. Supported formats are BMP
139119
* and JPEG.
@@ -207,8 +187,6 @@ public static Pix readBitmap(Bitmap bmp) {
207187

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

210-
private static native long nativeReadFiles(String dirname, String prefix);
211-
212190
private static native long nativeReadFile(String filename);
213191

214192
private static native long nativeReadBitmap(Bitmap bitmap);

tess-two/src/com/googlecode/leptonica/android/WriteFile.java

-45
Original file line numberDiff line numberDiff line change
@@ -80,47 +80,6 @@ public static int writeBytes8(Pix pixs, byte[] data) {
8080
return bytesWritten;
8181
}
8282

83-
/**
84-
* Writes all the images in a Pixa array to individual files using the
85-
* specified format. The output file extension will be determined by the
86-
* format.
87-
* <p>
88-
* Output file names will take the format <path>/<prefix><index>.<extension>
89-
*
90-
* @param pixas The source Pixa image array.
91-
* @param path The output directory.
92-
* @param prefix The prefix to give output files.
93-
* @param format The format to use for output files.
94-
* @return <code>true</code> on success
95-
*/
96-
public static boolean writeFiles(Pixa pixas, File path, String prefix, int format) {
97-
if (pixas == null)
98-
throw new IllegalArgumentException("Source pixa must be non-null");
99-
if (path == null)
100-
throw new IllegalArgumentException("Destination path non-null");
101-
if (prefix == null)
102-
throw new IllegalArgumentException("Filename prefix must be non-null");
103-
104-
//String rootname = new File(path, prefix).getAbsolutePath();
105-
106-
throw new RuntimeException("writeFiles() is not currently supported");
107-
}
108-
109-
/**
110-
* Write a Pix to a byte array using the specified encoding from
111-
* Constants.IFF_*.
112-
*
113-
* @param pixs The source image.
114-
* @param format A format from Constants.IFF_*.
115-
* @return a byte array containing encoded bytes
116-
*/
117-
public static byte[] writeMem(Pix pixs, int format) {
118-
if (pixs == null)
119-
throw new IllegalArgumentException("Source pix must be non-null");
120-
121-
throw new RuntimeException("writeMem() is not currently supported");
122-
}
123-
12483
/**
12584
* Writes a Pix to file using the file extension as the output format;
12685
* supported formats are .jpg or .jpeg for JPEG and .bmp for bitmap.
@@ -199,10 +158,6 @@ public static Bitmap writeBitmap(Pix pixs) {
199158

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

202-
private static native boolean nativeWriteFiles(long nativePix, String rootname, int format);
203-
204-
private static native byte[] nativeWriteMem(long nativePix, int format);
205-
206161
private static native boolean nativeWriteImpliedFormat(
207162
long nativePix, String fileName, int quality, boolean progressive);
208163

0 commit comments

Comments
 (0)