Undo/Redoing image adjustments
in
Android Processing
•
6 months ago
I'm trying to implement a simple, one-step undo/redo function in my image manipulation application. Unfortunately buffering the before/after images is
not an option because of memory limitations.
So what I'm doing at the moment is saving the before/after images. But that creates a performance/quality dilemma:
-
jpeg is fast (i.e. ~500ms to save on my Xperia Arc S) but degrades the quality beyond acceptability after two/three iterations.
-
png is of course lossless, but is super slow (~7000ms to save) which makes it impractical.
-
bmp would probably be fast, but android does not encode bmp (I think processing saves "file.bmp" as tiff).
-
tiff has acceptable performance (~1500ms to save), but android does not decode tiff.
...so, is there anything else I can do?
EDIT: I also tried writing the raw pixel array to a file using this function (I copy/pasted from here and there):
- void writeData(String filename, int[] data) {
- try {
- DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(openFileOutput(filename, Context.MODE_PRIVATE)));
- for (int i = 0; i < data.length; i++) {
- dos.writeInt(data[i]);
- }
- dos.close();
- dos.flush();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
1