/// <summary> /// Creates a new delimiterConverter /// </summary> /// <param name="delimiter"></param> public DelimiterConverter(Char delimiter) { _parseList = new Queue<Boolean>(); _delimiter = delimiter; _options = ConversionOptions.CleanupQuotes | ConversionOptions.GlueStrings; }
static ConversionOptions() { DefaultMultiLine = new ConversionOptions(); DefaultMultiLine.ForceMultilineMode = true; CaseInsensitiveMultiline = new ConversionOptions(); CaseInsensitiveMultiline.IgnoreCase = true; CaseInsensitiveMultiline.ForceMultilineMode = true; }
public PedamorfResponse ConvertFiles(Stream fileStream1, string fileName1, Stream fileStream2, string fileName2, ConversionOptions options) { Dictionary<string, byte[]> files = new Dictionary<string, byte[]>(); byte[] file1 = GetStreamFile(fileStream1); byte[] file2 = GetStreamFile(fileStream2); files.Add(fileName1, file1); files.Add(fileName2, file2); return ConvertFiles(files, options); }
public Task Cut(Video video, long jumpStartTime, string outRootPath) { return(Task.Run(() => { var inputFile = new MediaFile { Filename = video.Path }; var outFolder = Path.Combine(outRootPath, video.CreationDate.Year.ToString(), video.CreationDate.ToString("MMMM"), video.CreationDate.Day.ToString()); if (!Directory.Exists(outFolder)) { Directory.CreateDirectory(outFolder); } var planeOutputFile = new MediaFile { Filename = Path.Combine(outFolder, "plane-" + video.CreationDate.ToString("HH-mm") + Path.GetFileNameWithoutExtension(video.Path) + ".mp4") }; var jumpOutputFile = new MediaFile { Filename = Path.Combine(outFolder, "jump-" + video.CreationDate.ToString("HH-mm") + Path.GetFileNameWithoutExtension(video.Path) + ".mp4") }; using (var engine = new Engine()) { engine.GetMetadata(inputFile); var options = new ConversionOptions(); var duration = video.Duration - jumpStartTime; options.CutMedia(TimeSpan.FromSeconds(Convert.ToDouble(jumpStartTime)), TimeSpan.FromSeconds(Convert.ToDouble(duration))); _loadingService.AddLoadingStatus($"Creation de la vidéo {Path.GetFileNameWithoutExtension(jumpOutputFile.Filename)}..."); engine.ConversionCompleteEvent += (sender, args) => { _loadingService.RemoveLoadingStatus($"Creation de la vidéo {Path.GetFileNameWithoutExtension(jumpOutputFile.Filename)}..."); }; engine.Convert(inputFile, jumpOutputFile, options); } using (var engine = new Engine()) { engine.GetMetadata(inputFile); var options = new ConversionOptions(); options.CutMedia(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(Convert.ToDouble(jumpStartTime))); _loadingService.AddLoadingStatus($"Creation de la vidéo {Path.GetFileNameWithoutExtension(planeOutputFile.Filename)}..."); engine.ConversionCompleteEvent += (sender, args) => { _loadingService.RemoveLoadingStatus($"Creation de la vidéo {Path.GetFileNameWithoutExtension(planeOutputFile.Filename)}..."); }; engine.Convert(inputFile, planeOutputFile, options); } })); }
/// <summary> /// Converts the source using the options /// </summary> /// <param name="source"></param> /// <param name="options"></param> /// <returns></returns> public String[] Convert(String source, ConversionOptions options) { ConversionOptions temp = _options; SetConversionOptions(options); var result = Convert(source); SetConversionOptions(temp); return result; }
public VBToCSProjectContentsConverter(ConversionOptions conversionOptions, bool useProjectLevelWinformsAdjustments, IProgress <ConversionProgress> progress, CancellationToken cancellationToken) { _conversionOptions = conversionOptions; _useProjectLevelWinformsAdjustments = useProjectLevelWinformsAdjustments; _progress = progress; _cancellationToken = cancellationToken; OptionalOperations = new OptionalOperations(conversionOptions.AbandonOptionalTasksAfter, progress, cancellationToken); }
private static extern bool ConvertCrnInMemory( byte[] inBuff, long inBuffSize, ConversionOptions options, int levelSegmentCount, byte[] levelSegmentBytes, int levelSegmentBytesSize, out IntPtr outBuff, out long outBuffSize );
public IReadOnlyCollection <ITransformation> Transformations( ILogger logger, ConversionOptions conversionOptions) { return(new ITransformation[] { new NuGetPackageTransformation(), new AssemblyAttributeTransformation(logger, conversionOptions.KeepAssemblyInfo), }); }
public static void AdjustBitRate([NotNull] ConversionOptions conversion) { int defaultBitRate = conversion.VideoSize.Width * conversion.VideoSize.Height; int bitRate = Math.Max(defaultBitRate, conversion.VideoSize.BitRate); conversion.VideoBitRate = (int)(bitRate * 2.8); conversion.MinBitRate = (int)(bitRate * 2.0); conversion.MaxBitRate = (int)(bitRate * 3.5); conversion.BufferSize = conversion.MaxBitRate; }
static void ConvertWriteToByteArrayNoInputHtml() { //public static byte[] Convert(Uri uri, ConversionOptions conversionOptions = null); ConversionOptions conversionOptions = new ConversionOptions(PageSize.Tabloid, PageOrientation.Landscape, 28, 28); Uri document = new Uri("https://cnn.com"); byte[] output = Converter.Convert(document, conversionOptions); File.WriteAllBytes("./cnn-printiout.pdf", output); }
private void InitCommands() { SelectVideoCommand = new ActionCommand(() => { OpenFileDialog dialog = new OpenFileDialog { Multiselect = false, DefaultExt = ".mp4", Filter = "MP4 Files (*.mp4)|*.mp4" }; if (dialog.ShowDialog() != true) { return; } VideoPath = dialog.FileName; _video = new Video(dialog.FileName); AnalizeCommand.IsEnabled = true; }); AnalizeCommand = new ActionCommand(async() => { IsLoading = true; StartFrame = await _visionService.GetStartFrame(_video); StartTime = StartFrame / (double)_video.FrameRate; StartFound = StartTime.HasValue; CutCommand.IsEnabled = true; IsLoading = false; }, false); CutCommand = new ActionCommand(() => { var inputFile = new MediaFile { Filename = _videoPath }; var outputFile = new MediaFile { Filename = Path.Combine(Path.GetDirectoryName(_videoPath), "jump-" + Path.GetFileNameWithoutExtension(_videoPath) + ".mp4") }; using (var engine = new Engine()) { engine.GetMetadata(inputFile); var options = new ConversionOptions(); var duration = (_video.FrameCount / _video.FrameRate) - StartTime; options.CutMedia(TimeSpan.FromSeconds(Convert.ToDouble(StartTime)), TimeSpan.FromSeconds(Convert.ToDouble(duration))); engine.ConversionCompleteEvent += OnConversionCompleteEvent; engine.ConvertProgressEvent += OnConvertProgressEvent; engine.Convert(inputFile, outputFile, options); } }, false); }
private static int Main(string[] args) { try { ConversionOptions options = ConversionOptions.Default; if (System.Console.IsInputRedirected) { using (var convertor = new Convertor(System.Console.OpenStandardInput(255), options)) { WriteToStdOutput(convertor.ConvertToJson()); } } else { string fileName = GetInputFileName(args); using (var convertor = new Convertor(new FileStream(fileName, FileMode.Open), options)) { WriteToFile(GenerateOuputFileName(fileName), convertor.ConvertToJson()); } } return(Success); } catch (ConversionException e) { System.Console.Error.WriteLine(ErrorFormat, e.Message); #if DEBUG System.Console.WriteLine(); System.Console.WriteLine("Press <ENTER> for exit."); System.Console.ReadLine(); #endif return(Error); } catch (FileNotFoundException e) { System.Console.Error.WriteLine(ErrorFormat, e.Message); #if DEBUG System.Console.WriteLine(); System.Console.WriteLine("Press <ENTER> for exit."); System.Console.ReadLine(); #endif return(Error); } catch (Exception e) { System.Console.Error.WriteLine(ErrorFormat, e.Message); System.Console.Error.WriteLine($"***\t{e}"); #if DEBUG System.Console.WriteLine(); System.Console.WriteLine("Press <ENTER> for exit."); System.Console.ReadLine(); #endif return(Error); } }
public EngineParameters( ConversionOptions conversionOptions, MediaFile inputFile, MediaFile outputFile, FFmpegTask task) { ConversionOptions = conversionOptions; InputFile = inputFile; OutputFile = outputFile; Task = task; }
private static async Task TestConverter( string pageContent, string expectedMarkdown, ConversionOptions options = null, IReadOnlyList <ReferencedImage> expectedImages = null) { var results = await ExecuteConverter(pageContent, options); results.Documents.Single().Markdown.Should().Be(expectedMarkdown); results.Images.Should().BeEquivalentTo(expectedImages ?? Array.Empty <ReferencedImage>()); }
private static string GetThumbnail(MediaFile inputFile, ConversionOptions conversionOptions) { var commandBuilder = new StringBuilder(); commandBuilder.AppendFormat(CultureInfo.InvariantCulture, " -ss {0} ", conversionOptions.Seek.GetValueOrDefault(TimeSpan.FromSeconds(1)).TotalSeconds); commandBuilder.AppendFormat(" -i \"{0}\"", inputFile.Filename); commandBuilder.AppendFormat(" -vframes {0}", 1); commandBuilder.AppendFormat(" -f mjpeg pipe:1"); return(commandBuilder.ToString()); }
public static async Task TranscodeAudio(string ffmpegPath, string sourceFilePath, params string[] destinationPaths) { var config = @"akka.loglevel = DEBUG akka.actor.debug.receive = on akka.actor.debug.unhandled = on akka.actor.debug.event-stream = on akka.stdout-loglevel = Debug"; var actorSystem = ActorSystem.Create("transcoding-system", config); var transcodingOptions = new ConversionOptions { AudioBitRate = 320 }; var analysisOptions = new ConversionOptions(); var inputFile = new MediaFile(sourceFilePath); var transcoderManager = actorSystem.ActorOf(Props.Create(() => new TranscodingManager())); foreach (var path in destinationPaths) { var outputFile = new MediaFile(path); await Task.Delay(200); var transcodingCommand = new StartTranscoding(Guid.NewGuid(), inputFile, outputFile, transcodingOptions, ffmpegPath); var waveformCommand = new StartAnalysis(Guid.NewGuid(), inputFile, outputFile, analysisOptions, ffmpegPath); transcoderManager.Tell(transcodingCommand); //transcoderManager.Tell(waveformCommand); } Console.WriteLine("Done"); while (true) { Console.WriteLine("Return to Get Status"); //Console.ReadLine(); try { await Task.Delay(1000); var result = await transcoderManager.Ask <StatusResult>(new GetStatus(), TimeSpan.FromSeconds(5)); Console.WriteLine($"P{result.InProgress} - C{result.Completed} - F{result.Failed}"); } catch { } } }
protected override void InitializeSchema(XmlSchema schema, ConversionOptions options) { schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.AttributeFormDefault = XmlSchemaForm.Unqualified; if (!string.IsNullOrEmpty(options.XmlNamespace)) { schema.TargetNamespace = options.XmlNamespace; schema.Namespaces.Add("", options.XmlNamespace); } }
protected override void WriteSchemaFile(TypeScriptSchema schema, ConversionOptions opitons) { var fileName = Path.GetFileNameWithoutExtension(_ramlFile.FullPath) + "." + FileExtensions.TypeScript; string fullPath = Path.Combine(opitons.OutputDirectory, fileName); using (var streamWriter = new StreamWriter(fullPath)) { schema.Write(streamWriter); } }
public static void Run() { string dataDir = RunExamples.GetDataDir(); //ExStart: ConvertGeoJSONToShapeFileWithAttributeAdjustment ConversionOptions options = new ConversionOptions(); options.AttributesConverter = new AttributesConverterExample(); VectorLayer.Convert(dataDir + "input.json", Drivers.GeoJson, dataDir + "ConvertGeoJSONToShapeFileWithAttributeAdjustment_out.shp", Drivers.Shapefile, options); //ExEnd: ConvertGeoJSONToShapeFileWithAttributeAdjustment }
public Convertidor() { this.OpenFilePath = ""; this.Extension = ""; this.VideoFile = null; this.Duration = 0; this.NewExtension = ""; this.StartTimeCut = 0; this.DurationCut = 0; this.VideoEngine = new Engine(); this.Option = new ConversionOptions(); }
public void GetWaveform(MediaFile inputFile, MediaFile outputFile, ConversionOptions options = null) { var engineParams = new EngineParameters { InputFile = inputFile, OutputFile = outputFile, ConversionOptions = options, Task = FFmpegTask.GetWaveform }; this.FFmpegEngine(engineParams); }
/// <summary> /// <para> Converts media with conversion options</para> /// </summary> /// <param name="inputFile">Input file</param> /// <param name="outputFile">Output file. </param> /// <param name="options">Conversion options. </param> public void Convert(MediaFile inputFile, MediaFile outputFile, ConversionOptions options) { var engineParams = new EngineParameters { InputFile = inputFile, OutputFile = outputFile, ConversionOptions = options, Task = FFmpegTask.Convert }; this.FFmpegEngine(engineParams); }
Task UpdateMatAsync(string path, string outputDirectory, ConversionOptions options) { var inputFile = new FileInfo(path); var outputFile = new FileInfo(Path.Combine(outputDirectory, inputFile.BareName() + ".mat")); if (inputFile.Exists) { Directory.CreateDirectory(outputDirectory); return(Converter.ConvertAsync(options, outputFile, inputFile)); } return(null); }
public async Task <bool> SaveVideoAttachment(float Time, string Src, string fileName, string folderPath, string AWSAccessKeyID, string AWSSecretKey) { var FilePath = Path.Combine(_env.WebRootPath, @"thumbnail"); Attachment model = new Attachment(); bool result = false; try { if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } var thumbnailPath = FilePath + @"\" + fileName; //Create thumbnail from video Src = Regex.Replace(Src, @"\bhttps\b", "http"); var inputFile = new MediaFile { Filename = Src }; var outputFile = new MediaFile { Filename = thumbnailPath }; var webRoot = _env.WebRootPath; var file = System.IO.Path.Combine(webRoot, "fmpeg.exe"); using (var engine = new Engine(file)) { engine.GetMetadata(inputFile); var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(Time) }; engine.GetThumbnail(inputFile, outputFile, options); } byte[] imagebyte = File.ReadAllBytes(thumbnailPath); //upload to AWS bucket result = await _fileService.UploadFile(imagebyte, folderPath, AWSAccessKeyID, AWSSecretKey); //delete folder files after upload CleanFolder(FilePath); } catch (Exception ex) { _logger.Error("An error occurred with the message '{0}' when writing an object", ex.Message); result = false; } return(result); }
internal ConversionProgressEventArgs(ProgressData progressData, MediaFile input, MediaFile output, ConversionOptions options = null) { Input = input; Output = output; TotalDuration = progressData.TotalDuration; ProcessedDuration = progressData.ProcessedDuration; Frame = progressData.Frame; Fps = progressData.Fps; SizeKb = progressData.SizeKb; Bitrate = progressData.Bitrate; Options = options; }
private static string GetWaveform(MediaFile inputFile, MediaFile outputFile, ConversionOptions conversionOptions) { var commandBuilder = new StringBuilder(); commandBuilder.AppendFormat(" -i \"{0}\" ", inputFile.Filename); commandBuilder.AppendFormat( " -filter_complex \"aformat=channel_layouts=mono,showwavespic=s=4000x1000\" -frames:v 1 \"{0}\" ", outputFile.Filename); return(commandBuilder.ToString()); }
/// <summary> /// Read an ODF file. /// </summary> public override bool importOdfFile(string odfFileName) { try { bool isTemplate = Path.GetExtension(odfFileName).ToUpper().Equals(".OTT"); // create a temporary file string outputExtension = isTemplate ? ".dotx" : ".docx"; string outputFileName = this._addinLib.GetTempFileName(odfFileName, outputExtension); this._application.Invoke("System").SetInt32("Cursor", (int)WdCursorType.wdCursorWait); ConversionOptions options = new ConversionOptions(); options.InputFullName = odfFileName; options.OutputFullName = outputFileName; options.ConversionDirection = ConversionDirection.OdtToDocx; options.Generator = this.GetGenerator(); options.DocumentType = isTemplate ? DocumentType.Template : DocumentType.Document; options.ShowProgress = true; options.ShowUserInterface = true; this._addinLib.OdfToOox(odfFileName, outputFileName, options); this._application.Invoke("System").SetInt32("Cursor", (int)WdCursorType.wdCursorNormal); // open the document bool confirmConversions = false; bool readOnly = true; bool addToRecentFiles = false; bool isVisible = true; bool openAndRepair = false; // conversion may have been cancelled and file deleted. if (File.Exists((string)outputFileName)) { LateBindingObject doc = OpenDocument(outputFileName, confirmConversions, readOnly, addToRecentFiles, isVisible, openAndRepair); // update document fields //doc.Invoke("Fields").Invoke("Update"); // and activate it doc.Invoke("Activate"); doc.Invoke("Windows").Invoke("Item", 1).Invoke("Activate"); } return(true); } catch (Exception ex) { _application.Invoke("System").SetInt32("Cursor", (int)WdCursorType.wdCursorNormal); System.Diagnostics.Trace.WriteLine(ex.ToString()); System.Windows.Forms.MessageBox.Show(this._addinLib.GetString("OdfUnexpectedError"), DialogBoxTitle, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Stop); return(false); } }
/// ------------------------------------------------------------------------------------------------- /// <summary> Retrieve a thumbnail image from a video file. </summary> /// <param name="inputFile"> Video file. </param> /// <param name="outputFile"> Image file. </param> /// <param name="options"> Conversion options. </param> public void GetThumbnail(MediaFile inputFile, MediaFile outputFile, ConversionOptions options) { var engineParams = new EngineParameters { InputFile = inputFile, OutputFile = outputFile, ConversionOptions = options, Task = FFmpegTask.GetThumbnail }; FFmpegEngine(engineParams); }
static async Task Main() { string ffmpeg, output = string.Empty; if (new DirectoryInfo(path).Exists) { ffmpeg = Path.Combine(path, Program.ffmpeg); } else { ffmpeg = Program.ffmpeg; } var engine = new Engine(ffmpeg); var data = new List <MetaData>(); foreach (var file in Directory.GetFiles(Environment.CurrentDirectory, "*.mp4", SearchOption.AllDirectories)) { if (new FileInfo(file) is FileInfo info && info.Name is string name && name.StartsWith("._") is false) { data.Add(await engine.GetMetaDataAsync(new MediaFile(info))); } } var options = new ConversionOptions { VideoBitRate = data.Min(o => o.VideoData.BitRateKbs), VideoFps = (int)data.Min(o => o.VideoData.Fps), AudioBitRate = data.Find(o => o.AudioData is MetaData.Audio).AudioData.BitRateKbs }; foreach (var con in data) { var convert = await engine.ConvertAsync(new MediaFile(con.FileInfo), new MediaFile(con.FileInfo.FullName.Replace(".mp4", "r.mp4")), options); using (var sw = new StreamWriter(Path.Combine(convert.FileInfo.DirectoryName, list), true)) { sw.WriteLine($"file {convert.FileInfo.Name}"); if (string.IsNullOrEmpty(output)) { output = Path.Combine(convert.FileInfo.DirectoryName, Program.output); } } Console.WriteLine(await engine.GetMetaDataAsync(convert)); } if (string.IsNullOrEmpty(output) is false) { await engine.ExecuteAsync($"-f concat -i {output.Replace(Program.output, list)} -c copy {output}"); } }
public void LineEndingsLeftAlone() { var options = new ConversionOptions() { LineEndingStyle = LineEnding.Leave, Indentation = IndentationStyle.Spaces }; var contents = "Testing\nTesting\r\n"; var expectedContents = "Testing\nTesting\r\n"; var result = RunTest(options, contents); Assert.Equal(expectedContents, result); }
public void LineEndingsNormalizedToCrlf() { var options = new ConversionOptions() { LineEndingStyle = LineEnding.CRLF, Indentation = IndentationStyle.Spaces }; var contents = "Testing\nTesting\n"; var expectedContents = "Testing\r\nTesting\r\n"; var result = RunTest(options, contents); Assert.Equal(expectedContents, result); }
public static void Run() { // Create a conversion options class ConversionOptions conversionOptions = new ConversionOptions(PageSize.A4, PageOrientation.Portrait, 54.0f); // Create a simple HTML string string sampleHtml = "<html><body><p>This is a very simple HTML string including a Table below.</p>" + "<h4>Two rows and three columns:</h4><table border=\"1\"><tr><td>100</td><td>200</td>" + "<td>300</td></tr><tr><td>400</td><td>500</td><td>600</td></tr></table></body></html>"; // Asynchronously Convert HTML to PDF with the conversion options specified Converter.ConvertAsync(sampleHtml, "AsyncConversion.pdf"); }
public StartTranscoding( Guid transcodingId, MediaFile input, MediaFile output, ConversionOptions options, string ffmpegPath = @"C:\Workspace\FFMPEG\bin\ffmpeg.exe") { TranscodingId = transcodingId; Input = input; Output = output; ConversionOptions = options; _ffmpegPath = ffmpegPath; }
public static async void ThumbNailAsync() { var inputFile = new MediaFile(@"D:\one.mp4"); var outputFile = new MediaFile(@"D:\oneee.jpg"); var ffmpeg = new Engine("D:\\MediaToolkit\\ffmpeg.exe"); // Saves the frame located on the 15th second of the video. var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(3) }; await ffmpeg.GetThumbnailAsync(inputFile, outputFile, options); }
public ConversionJob( string inf, string outf, int index, ConversionOptions o ) { WindowsAutomation.IO.VerifyFileExists( inf ); this.InputFile = inf; this.OutputFile =outf; this.SequenceNumber=index; this.Options = o; System.IO.FileInfo fi = new System.IO.FileInfo( this.InputFile ); this.InputFilesize = fi.Length; }
public PedamorfResponse ConvertFiles(string directoryPath, ConversionOptions options) { Dictionary<string, byte[]> files = GetDirectoryFiles(directoryPath); return ConvertFiles(files, options); }
private static void AddKmlOptions(OptionSet optionSet, ConversionOptions options) { }
private static void ConvertKml(ConversionOptions options) { using (var outputWriter = new StreamWriter(options.OutputFileName)) { string extension = Path.GetExtension(options.InputFileName); if (".kml".Equals(extension, StringComparison.OrdinalIgnoreCase)) { using (var inputReader = new StreamReader(options.InputFileName)) KmlConverter.KmlToCesiumLanguage(inputReader, outputWriter, options.PrettyPrint); } else if (".kmz".Equals(extension, StringComparison.OrdinalIgnoreCase)) { using (var inputStream = new FileStream(options.InputFileName, FileMode.Open, FileAccess.Read)) KmlConverter.KmzToCesiumLanguage(inputStream, outputWriter, options.PrettyPrint); } } }
private static void AddWebGLGlobeJsonOptions(OptionSet optionSet, ConversionOptions options) { const string heightScalarParamDesc = "A scale factor for the height component of each coordinate. Defaults to 1."; optionSet.Add("webGLGlobeJsonHeightScalar=", heightScalarParamDesc, (double v) => options.WebGLGlobeJson.HeightScalar = v); }
/// <summary> /// Sets the conversionoptions /// </summary> /// <param name="options"></param> public void SetConversionOptions(ConversionOptions options) { _options = options; }
private void ProcessOneFile(string file, ConversionOptions opts) { var infmt = opts.DetectFileFormatForFileName(file).Value; var outfmt = opts.OutputFormat; VoxelModel model; try { switch (infmt) { case InputFormatSelection.Kv6: model = new Kv6VoxelModelLoader().LoadVoxelModel( System.IO.File.ReadAllBytes(file), null); break; case InputFormatSelection.Vxl: model = new VxlVoxelModelLoader().LoadVoxelModel( System.IO.File.ReadAllBytes(file), null); break; case InputFormatSelection.MagicaVoxel: model = new MagicaVoxelModelLoader().LoadVoxelModel( System.IO.File.ReadAllBytes(file), null); break; case InputFormatSelection.Auto: default: throw new InvalidOperationException(); } } catch (Exception ex) { throw new Exception("Failed to load the input file (I/O error or file type mismatch?).", ex); } var slices = new SimpleMeshSliceGenerator().GenerateSlices(model, null); System.Drawing.Bitmap bmp; new SimpleMeshTextureGenerator().GenerateTextureAndUV(model, slices, out bmp, null); var outpath = opts.GetOutputPathForInputPath(file); switch (outfmt) { case OutputFormatSelection.WavefrontObj: new ObjWriter().Save(slices, bmp, outpath, null); break; } }
public PedamorfResponse ConvertFile(string filePath, ConversionOptions options) { byte[] file = File.ReadAllBytes(filePath); return ConvertFile(file, Path.GetFileName(filePath), options); }
private static void ConvertWebGLGlobeJson(ConversionOptions options) { using (var inputReader = new StreamReader(options.InputFileName)) using (var outputWriter = new StreamWriter(options.OutputFileName)) { WebGLGlobeJsonConverter.WebGLGlobeJsonToCesiumLanguage(inputReader, outputWriter, options.PrettyPrint, options.WebGLGlobeJson.HeightScalar); } }
private static void Main(string[] args) { ConversionOptions options = new ConversionOptions(); bool showHelp = false; var optionSet = new OptionSet { { "h|?|help", s_helpParamDesc, v => showHelp = v != null }, { "o=|outputFile=", s_outputFileParamDesc, v => options.OutputFileName = v }, { "t=|type=", s_inputFileTypeParamDesc, v => options.InputFileType = v }, { "pretty", s_prettyPrintParamDesc, v => options.PrettyPrint = v != null }, { "<>", "", v => options.InputFileName = v }, }; AddKmlOptions(optionSet, options); AddWebGLGlobeJsonOptions(optionSet, options); try { optionSet.Parse(args); } catch (OptionException e) { Console.Error.Write("Invalid options: "); Console.Error.WriteLine(e.Message); Console.Error.WriteLine(); ShowHelpAndExit(optionSet); } if (showHelp || options.InputFileName == null) { ShowHelpAndExit(optionSet); } if (options.InputFileType == null) { string extension = Path.GetExtension(options.InputFileName); string inputFileType; if (!s_fileExtensionsToInputFileTypes.TryGetValue(extension, out inputFileType)) { Console.Error.Write("Unable to infer file type from extension {0}.", extension); Console.Error.WriteLine(); ShowHelpAndExit(optionSet); } options.InputFileType = inputFileType; } if (options.OutputFileName == null) { options.OutputFileName = Path.ChangeExtension(Path.GetFileName(options.InputFileName), "czml"); } Action<ConversionOptions> conversionMethod; if (!s_conversionMethods.TryGetValue(options.InputFileType, out conversionMethod)) { Console.Error.Write("Unknown file type: {0}", options.InputFileType); Console.Error.WriteLine(); ShowHelpAndExit(optionSet); } conversionMethod(options); Console.WriteLine("Wrote CZML output to {0}.", options.OutputFileName); }
public PedamorfResponse ConvertFile(Stream fileSteam, string fileName, ConversionOptions options) { byte[] file = GetStreamFile(fileSteam); return ConvertFile(file, fileName, options); }