Override this in subclasses to intercept save calls for other formats or higher-performance implementations. When reaching this code, pixels must be loaded and that path should be absolute. @param path must be a full path (not relative or simply a filename)
(String path)
| 3225 | * @param path must be a full path (not relative or simply a filename) |
| 3226 | */ |
| 3227 | protected boolean saveImpl(String path) { |
| 3228 | // Make sure the pixel data is ready to go |
| 3229 | loadPixels(); |
| 3230 | boolean success; |
| 3231 | |
| 3232 | try { |
| 3233 | final String lower = path.toLowerCase(); |
| 3234 | |
| 3235 | if (lower.endsWith(".tga")) { |
| 3236 | OutputStream os = new BufferedOutputStream(new FileOutputStream(path), 32768); |
| 3237 | success = saveTGA(os); //, pixels, width, height, format); |
| 3238 | os.close(); |
| 3239 | |
| 3240 | } else { |
| 3241 | // TODO Imperfect, possibly temporary solution for 4.x releases |
| 3242 | // https://github.com/processing/processing4/wiki/Exorcising-AWT |
| 3243 | success = ShimAWT.saveImage(this, path); |
| 3244 | } |
| 3245 | } catch (IOException e) { |
| 3246 | System.err.println("Error while saving " + path); |
| 3247 | e.printStackTrace(); |
| 3248 | success = false; |
| 3249 | } |
| 3250 | return success; |
| 3251 | } |
| 3252 | } |
no test coverage detected