public static int Main(string[] args) { string filename = args[0]; string outfilename = args[1]; using (var sfcts = FileChangeTransferSyntax.New()) { FileChangeTransferSyntax fcts = sfcts.__ref__(); //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax"); gdcm.TransferSyntax ts = new TransferSyntax(TransferSyntax.TSType.JPEGBaselineProcess1); fcts.SetTransferSyntax(ts); ImageCodec ic = fcts.GetCodec(); JPEGCodec jpeg = JPEGCodec.Cast(ic); jpeg.SetLossless(false); jpeg.SetQuality(50); // poor quality ! fcts.SetInputFileName(filename); fcts.SetOutputFileName(outfilename); if (!fcts.Change()) { return(1); } } return(0); }
static private void CompressIntoJPEG(string rawdicom, string jpegdicom) { using (var sfcts = FileChangeTransferSyntax.New()) { // Need to retrieve the actual C++ reference, to pass to // SimpleSubjectWatcher: FileChangeTransferSyntax fcts = sfcts.__ref__(); SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax"); gdcm.TransferSyntax ts = new TransferSyntax(TransferSyntax.TSType.JPEGBaselineProcess1); fcts.SetTransferSyntax(ts); ImageCodec ic = fcts.GetCodec(); JPEGCodec jpeg = JPEGCodec.Cast(ic); jpeg.SetLossless(false); jpeg.SetQuality(50); // poor quality ! fcts.SetInputFileName(rawdicom); fcts.SetOutputFileName(jpegdicom); fcts.Change(); } }