private CurveCollection GetCurves() { if (!string.IsNullOrEmpty(PhotoshopCurvesFileName)) { return(PhotoshopCurvesReader.ReadPhotoshopCurvesFile(FileSourceHelper.ResolveFileName(PhotoshopCurvesFileName))); } return(Curves); }
private CurveCollection GetCurves(ImageGenerationContext context) { if (!string.IsNullOrEmpty(PhotoshopCurvesFileName)) { return(PhotoshopCurvesReader.ReadPhotoshopCurvesFile(FileSourceHelper.ResolveFileName(context, PhotoshopCurvesFileName))); } return(Curves); }
public override Scene GetScene(ImageGenerationContext context) { string resolvedFileName = FileSourceHelper.ResolveFileName(context, FileName); if (File.Exists(resolvedFileName)) { return(MeshellatorLoader.ImportFromFile(resolvedFileName)); } return(null); }
public FontDescription GetFontDescription(ImageGenerationContext context) { FontFamily fontFamily; if (!string.IsNullOrEmpty(CustomFontFile)) { string fontFileName = FileSourceHelper.ResolveFileName(context, CustomFontFile); fontFamily = new FontFamily(fontFileName + "#" + Name); } else { fontFamily = new FontFamily(Name); } Typeface typeface = new Typeface(fontFamily, GetStyle(), GetWeight(), FontStretches.Normal); return(new FontDescription(typeface, GetTextDecorations(), Size)); }
protected override void CreateImage() { GhostscriptUtil.EnsureDll(); string outputFileName = Path.GetTempFileName(); try { string filename = FileSourceHelper.ResolveFileName(SourceFileName); GhostscriptWrapper.GeneratePageThumb(filename, outputFileName, PageNumber, 96, 96); Bitmap = new FastBitmap(File.ReadAllBytes(outputFileName)); } finally { File.Delete(outputFileName); } }
protected override void CreateImage() { string filename = FileSourceHelper.ResolveFileName(SourceFileName); MediaPlayer mediaPlayer = new MediaPlayer { ScrubbingEnabled = true }; object monitorObject = new object(); mediaPlayer.MediaOpened += (sender, e) => Monitor.Exit(monitorObject); Monitor.Enter(monitorObject); mediaPlayer.Open(new Uri(filename)); Monitor.Wait(monitorObject, 1000); int width = mediaPlayer.NaturalVideoWidth; int height = mediaPlayer.NaturalVideoHeight; // Seek to specified time. mediaPlayer.BufferingEnded += (sender, e) => Monitor.Exit(monitorObject); Monitor.Enter(monitorObject); mediaPlayer.Position = SnapshotTime; Monitor.Wait(monitorObject, 1000); DrawingVisual dv = new DrawingVisual(); DrawingContext dc = dv.RenderOpen(); dc.DrawVideo(mediaPlayer, new System.Windows.Rect(0, 0, width, height)); dc.Close(); RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(width, height); rtb.Render(dv); Bitmap = new FastBitmap(rtb); mediaPlayer.Close(); }
public override Scene GetScene(ImageGenerationContext context) { Scene scene = new Scene(); foreach (Mesh mesh in Meshes) { Meshellator.Mesh meshellatorMesh = new Meshellator.Mesh(); scene.Meshes.Add(meshellatorMesh); meshellatorMesh.Positions.AddRange(mesh.Positions.Select(p => new Nexus.Point3D(p.X, p.Y, p.Z))); meshellatorMesh.TextureCoordinates.AddRange(mesh.TextureCoordinates.Select(p => new Nexus.Point3D(p.X, p.Y, 0))); MeshUtility.CalculateNormals(meshellatorMesh, false); meshellatorMesh.Indices.AddRange(mesh.Indices.Select(i => i.Value)); Meshellator.Material meshellatorMaterial = new Meshellator.Material(); meshellatorMaterial.DiffuseColor = ConversionUtility.ToNexusColorRgbF(mesh.Material.DiffuseColor); if (!string.IsNullOrEmpty(mesh.Material.TextureFileName)) { string textureFileName = FileSourceHelper.ResolveFileName(context, mesh.Material.TextureFileName); if (!File.Exists(textureFileName)) { throw new DynamicImageException("Could not find texture '" + mesh.Material.TextureFileName + "'."); } meshellatorMaterial.DiffuseTextureName = textureFileName; } meshellatorMaterial.Shininess = mesh.Material.Shininess; meshellatorMaterial.SpecularColor = ConversionUtility.ToNexusColorRgbF(mesh.Material.SpecularColor); meshellatorMaterial.Transparency = mesh.Material.Transparency; meshellatorMesh.Material = meshellatorMaterial; scene.Materials.Add(meshellatorMaterial); } return(scene); }