public static void saveImage(string path, ProcessSettings settings) { if (!image.fileExists()) { return; } imageProcessor = new mImageProcessor(); imageBytes = image.getByteArray(); outputBytes = imageBytes; if (settings.filterGrayscale) { outputBytes = imageProcessor.toGreyScale(outputBytes); } if (settings.colorAdjustEnable) { outputBytes = imageProcessor.adjustColor(outputBytes, settings.brightnessValue, settings.contrastValue, settings.saturationValue); } if (settings.hueEnable) { outputBytes = imageProcessor.adjustHue(outputBytes, settings.hueValue, settings.hueRotate); } if (settings.rotateEnable) { outputBytes = imageProcessor.rotateImage(outputBytes, settings.rotateValue); } if (settings.resizeEnable) { //Resize needs to be done last for best image quality outputBytes = imageProcessor.resize(outputBytes, settings.resizeX, settings.resizeY, settings.resizeLockAspect); } if (outputBytes != null) { writeFile(outputBytes, path); //save to file //clear byte arrays to free up memory imageBytes = null; outputBytes = null; } }
private void onClick(object sender, EventArgs e) { Button button = sender as Button; if (button == null) { return; } else if (button == buttonOpen) { Debug.WriteLine(TAG + ": buttonOpen: onClick()"); openFileDialog(); } else if (button == buttonSave) { //Show savefile dialog and save the file Debug.WriteLine(TAG + ": buttonSave: onClick()"); //Fetch enabled settings and their values ProcessSettings settings = fetchSettings(); //Open save dialog saveFileDialog(settings); } }