private ImageResizeProcessor GetProcessor(MediaDimension resizeBy, int size, ImageSaveFormat format, bool overwrite) { ImageResizeProcessor processor = new ImageResizeProcessor(); processor.SetParameter("NewPath", GetCurrentTestResultsFilePath("out" + GetExtension(format))); processor.SetParameter("Format", format); processor.SetParameter("ResizeBy", resizeBy); processor.SetParameter("Size", size); processor.SetParameter("Overwrite", overwrite); return(processor); }
private void ResizeBeetleSuccess(MediaDimension resizeBy, int size, ImageSaveFormat format) { ImageResizeProcessor processor = GetProcessor(resizeBy, size, format, false); processor.Init(RunInfo); ProcessingResult result = processor.Process(GetTestFile("beetle.jpg"), MatchResultType.Yes, new string[0], new FileInfo[0], ProcessInput.OriginalFile, CancellationToken.None); processor.Cleanup(); Assert.AreEqual(ProcessingResultType.Success, result.Type); Assert.AreEqual(1, result.OutputFiles.Length); }
public void LoadSettings() { this.isShowForm = Properties.Settings.Default.isShowForm; this.isAutoStart = Properties.Settings.Default.isAutoStart; this.isShowEditorAfterCaptureSShot = Properties.Settings.Default.isShowEditorAfterCaptureSShot; this.isCopytoClipboard = Properties.Settings.Default.isCopytoClipboard; this.isSaveAutoAfterCaptureSShot = Properties.Settings.Default.isSaveAutoAfterCaptureSShot; this.AutoSavePath = Properties.Settings.Default.AutoSavePath; this.AutoSaveFileNumber = Properties.Settings.Default.AutoSaveFileNumber; this.AutoSaveFileName = Properties.Settings.Default.AutoSaveFileName; this.isShowCheckCapturedForm = Properties.Settings.Default.isShowCheckCapturedForm; this.ImageSaveFormat = (ImageSaveFormat)Enum.Parse(typeof(ImageSaveFormat), Properties.Settings.Default.ImageSaveFormat); }
public void Save(string filename, ImageSaveFormat format) { if (string.IsNullOrEmpty(filename)) { throw new ArgumentNullException("specify a file"); } int result = LeptonicaNativeApi.Native.pixWrite(filename, handle, format); if (result != 0) { throw new IOException(string.Format("failed to write into '{0}'.", filename)); } }
private string GetExtension(ImageSaveFormat format) { switch (format) { case ImageSaveFormat.Bitmap: return(".bmp"); case ImageSaveFormat.Exif: return(".exif"); case ImageSaveFormat.Gif: return(".gif"); case ImageSaveFormat.Jpeg: return(".jpg"); case ImageSaveFormat.Png: return(".png"); case ImageSaveFormat.Tiff: return(".tif"); } return(""); }
public void SaveProcessedImage(Bitmap srcBm, string path, ImageSaveFormat format, int compressionRatio, bool isSaveAsOrExport = false) { try { //if the bool isSaveAsOrExport is true it will compute the image path directly and save the image else it will compute for exporting of images or save images if (isSaveAsOrExport) { imagePath = path + "." + format.ToString(); } else { IVLCamVariables.ImageName = string.Empty; if (IVLCamVariables._Settings.ImageNameSettings.containsEyeSide) { if (IVLCamVariables.leftRightPos == LeftRightPosition.Left) { IVLCamVariables.ImageName = "OS"; } else { IVLCamVariables.ImageName = "OD"; } } if (!string.IsNullOrEmpty(IVLCamVariables.ImageName)) { IVLCamVariables.ImageName += "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "." + format.ToString(); } else { IVLCamVariables.ImageName = DateTime.Now.ToString("yyyyMMddHHmmss") + "." + format.ToString(); } if (IVLCamVariables.isCapturing) { if (!(IVLCamVariables._Settings.ImageSaveSettings.isMRNFolderSave)) { imagePath = IVLCamVariables.ProcessedImageSaveDirPath + Path.DirectorySeparatorChar + IVLCamVariables.ImageName; } else { imagePath = IVLCamVariables.ProcessedImageSaveDirPath + System.IO.Path.DirectorySeparatorChar + IVLCamVariables.intucamHelper.MRNValue + Path.DirectorySeparatorChar + IVLCamVariables.intucamHelper.VisitDate + Path.DirectorySeparatorChar + IVLCamVariables.ImageName; } //path = IVLCamVariables.CaptureArg["ImageName"] as string; } else { imagePath = path + Path.DirectorySeparatorChar + IVLCamVariables.ImageName; } } Args arg = new Args(); arg["TimeStamp"] = DateTime.Now; arg["Msg"] = imagePath; //arg["callstack"] = Environment.StackTrace; capture_log.Add(arg); switch (format) { case ImageSaveFormat.png: { System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.Quality; EncoderParameters jpegParams = new EncoderParameters(1); EncoderParameter encodingParamater = new EncoderParameter(encoder, compressionRatio); jpegParams.Param[0] = encodingParamater; //IVLCamVariables.CaptureBm.Save(IVLCamVariables.CaptureArg["ImageName"] as string, getCodecInfo(ImageFormat.Png), jpegParams); srcBm.Save(imagePath, getCodecInfo(ImageFormat.Png), jpegParams); } break; case ImageSaveFormat.jpg: { System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.Quality; EncoderParameters jpegParams = new EncoderParameters(1); EncoderParameter encodingParamater = new EncoderParameter(encoder, compressionRatio); jpegParams.Param[0] = encodingParamater; //IVLCamVariables.CaptureBm.Save(IVLCamVariables.CaptureArg["ImageName"] as string, getCodecInfo(ImageFormat.Jpeg), jpegParams); srcBm.Save(imagePath, getCodecInfo(ImageFormat.Jpeg), jpegParams); } break; case ImageSaveFormat.bmp: { System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.Quality; EncoderParameters jpegParams = new EncoderParameters(1); EncoderParameter encodingParamater = new EncoderParameter(encoder, compressionRatio); jpegParams.Param[0] = encodingParamater; // IVLCamVariables.CaptureBm.Save(IVLCamVariables.CaptureArg["ImageName"] as string, getCodecInfo(ImageFormat.Bmp), jpegParams); srcBm.Save(imagePath, getCodecInfo(ImageFormat.Bmp), jpegParams); } break; case ImageSaveFormat.tiff: { System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.Quality; EncoderParameters jpegParams = new EncoderParameters(1); EncoderParameter encodingParamater = new EncoderParameter(encoder, 100); jpegParams.Param[0] = encodingParamater; //IVLCamVariables.CaptureBm.Save(IVLCamVariables.CaptureArg["ImageName"] as string, getCodecInfo(ImageFormat.Tiff), jpegParams); srcBm.Save(imagePath, getCodecInfo(ImageFormat.Tiff), jpegParams); } break; } } catch (Exception ex) { //IVLCamVariables.intucamHelper.CompleteCaptureSequence(); CameraLogger.WriteException(ex, Exception_Log); // CameraLogger.WriteException(ex, Exception_Log); } IVLCamVariables.ImagePath = imagePath; }