/// <inheritdoc /> public override void OnThumbnailDrawBegin(ThumbnailRequest request, ContainerControl guiRoot, GPUContext context) { var asset = FlaxEngine.Content.Load <FontAsset>(request.Item.Path); guiRoot.AddChild(new Label(Vector2.Zero, guiRoot.Size) { Text = asset.FamilyName, Wrapping = TextWrapping.WrapWords }); }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new SimpleTexturePreview(); _preview.Size = new Vector2(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize); } // TODO: disable streaming for asset during thumbnail rendering (and restore it after) }
/// <summary> /// Called when thumbnail drawing begins. Proxy should setup scene GUI for guiRoot. /// </summary> /// <param name="request">The request to render thumbnail.</param> /// <param name="guiRoot">The GUI root container control.</param> /// <param name="context">GPU context.</param> public virtual void OnThumbnailDrawBegin(ThumbnailRequest request, ContainerControl guiRoot, GPUContext context) { guiRoot.AddChild(new Label { Text = Name, Offsets = Margin.Zero, AnchorPreset = AnchorPresets.StretchAll, Wrapping = TextWrapping.WrapWords }); }
public CreateOrUpdateThumbnailUseCaseTests() { _request = new ThumbnailRequest() { NewsId = Guid.NewGuid(), FileName = "image.jpg", FileLocalPath = "app/uploads/image.jpg", FileLength = 3 * 1024 * 104 }; }
/// <inheritdoc /> public override void OnThumbnailDrawEnd(ThumbnailRequest request, ContainerControl guiRoot) { if (_warmupRequest == request) { _warmupRequest = null; } _preview.System = null; _preview.Parent = null; }
/// <inheritdoc /> public override void OnThumbnailDrawBegin(ThumbnailRequest request, ContainerControl guiRoot, GPUContext context) { guiRoot.AddChild(new Label { Text = Path.GetFileNameWithoutExtension(request.Asset.Path), Offsets = Margin.Zero, AnchorPreset = AnchorPresets.StretchAll, Wrapping = TextWrapping.WrapWords }); }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new CubeTexturePreview(false); InitAssetPreview(_preview); } // TODO: disable streaming for asset during thumbnail rendering (and restore it after) }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new ParticleEmitterPreview(false); InitAssetPreview(_preview); } // Mark for initial warmup request.Tag = 0; }
/// <inheritdoc /> public override bool CanDrawThumbnail(ThumbnailRequest request) { if (!_preview.HasLoadedAssets) { return(false); } // Check if all mip maps are streamed var asset = (CubeTexture)request.Asset; return(asset.ResidentMipLevels >= Mathf.Max(1, (int)(asset.MipLevels * ThumbnailsModule.MinimumRequiredResourcesQuality))); }
/// <inheritdoc /> public override void OnThumbnailDrawBegin(ThumbnailRequest request, ContainerControl guiRoot, GPUContext context) { var asset = FlaxEngine.Content.LoadAsync <FontAsset>(request.Item.ID); guiRoot.AddChild(new Label { Text = asset.FamilyName, AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, Wrapping = TextWrapping.WrapWords }); }
/// <inheritdoc /> public override bool CanDrawThumbnail(ThumbnailRequest request) { if (!_preview.HasLoadedAssets) { return(false); } // Check if asset is streamed enough var asset = (Prefab)request.Asset; return(asset.IsLoaded); }
/// <inheritdoc /> public override bool CanDrawThumbnail(ThumbnailRequest request) { if (!_preview.HasLoadedAssets) { return(false); } // Check if asset is streamed enough var asset = (Model)request.Asset; return(asset.LoadedLODs >= Mathf.Max(1, (int)(asset.LODs.Length * ThumbnailsModule.MinimumRequriedResourcesQuality))); }
private void Update() { if (!waitingForResponse && queue.Count > 0) { ThumbnailRequest thumbnailRequest = queue.Peek(); if (thumbnailRequest != null) { waitingForResponse = true; CSNetManager.Instance.Sock.SendCS_DOWNLOAD_THUMBNAIL_REQ(thumbnailRequest.IsUserMap, thumbnailRequest.Id); } } }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new IESProfilePreview { AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, }; } // TODO: disable streaming for asset during thumbnail rendering (and restore it after) }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new MaterialPreview(false); _preview.RenderOnlyWithWindow = false; _preview.Task.Enabled = false; _preview.Size = new Vector2(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize); _preview.SyncBackbufferSize(); } // TODO: disable streaming for dependant assets during thumbnail rendering (and restore it after) }
/// <inheritdoc /> public override void OnThumbnailDrawCleanup(ThumbnailRequest request) { // Unlink asset var preview = (AudioClipPreview)request.Tag; preview.Asset = null; // Return the preview control back to the pool if (_previews == null) { _previews = new List <AudioClipPreview>(8); } _previews.Add(preview); }
public async Task <IActionResult> Get(string NewsID, string Size, string ImageName) { string str = ""; bool isSeek = false; var req = new ThumbnailRequest(); //req.RequestedPath = ImageName; req.ThumbnailSize = ParseSize(Size); req.SourceImagePath = GetPhysicalPath(NewsID + "/" + ImageName); if (IsSourceImageExists(req)) { using (Image img = Image.FromFile(req.SourceImagePath)) { try { Image file = null; str = "Width: " + req.ThumbnailSize.Value.Width + " Height: " + req.ThumbnailSize.Value.Height; if (req.ThumbnailSize.Value.Height >= req.ThumbnailSize.Value.Width) { file = ImageResize.ScaleByHeight(img, req.ThumbnailSize.Value.Height); } str = "2 Width: " + req.ThumbnailSize.Value.Width + " Height: " + req.ThumbnailSize.Value.Height; if (req.ThumbnailSize.Value.Width > req.ThumbnailSize.Value.Height) { file = ImageResize.ScaleByWidth(img, req.ThumbnailSize.Value.Width); } str = "3 Width: " + req.ThumbnailSize.Value.Width + " Height: " + req.ThumbnailSize.Value.Height; file = ImageResize.ScaleAndCrop(file, req.ThumbnailSize.Value.Width, req.ThumbnailSize.Value.Height, TargetSpot.Center); str = "4 Width: " + req.ThumbnailSize.Value.Width + " Height: " + req.ThumbnailSize.Value.Height; Stream outputStream = new MemoryStream(); file.Save(outputStream, System.Drawing.Imaging.ImageFormat.Jpeg); outputStream.Seek(0, SeekOrigin.Begin); str = "5 Width: " + req.ThumbnailSize.Value.Width + " Height: " + req.ThumbnailSize.Value.Height; return(this.File(outputStream, "image/png")); } catch (Exception ex) { return(NotFound(str + " " + ex.Message + " inner " + Convert.ToString(ex.InnerException))); } } } return(NotFound()); }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new PrefabPreview(false); _preview.RenderOnlyWithWindow = false; _preview.Task.Enabled = false; _preview.PostFxVolume.Settings.Eye_Technique = EyeAdaptationTechnique.None; _preview.PostFxVolume.Settings.Eye_Exposure = 0.1f; _preview.PostFxVolume.Settings.data.Flags4 |= 0b1001; _preview.Size = new Vector2(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize); _preview.SyncBackbufferSize(); } // TODO: disable streaming for asset during thumbnail rendering (and restore it after) }
public async Task <IActionResult> Get(string NewsID, string ImageName) { var req = new ThumbnailRequest(); req.SourceImagePath = GetPhysicalPath(NewsID + "/" + ImageName); if (IsSourceImageExists(req)) { using (Image img = Image.FromFile(req.SourceImagePath)) { Stream outputStream = new MemoryStream(); img.Save(outputStream, System.Drawing.Imaging.ImageFormat.Jpeg); outputStream.Seek(0, SeekOrigin.Begin); return(this.File(outputStream, "image/png")); } } return(NotFound()); }
/// <inheritdoc /> public override bool CanDrawThumbnail(ThumbnailRequest request) { var state = (int)request.Tag; if (state == 2) { return(true); } // Allow only one request at once during warmup time if (_warmupRequest != null && _warmupRequest != request) { return(false); } // Ensure assets are ready to be used if (!_preview.HasLoadedAssets) { return(false); } var asset = (ParticleEmitter)request.Asset; if (!asset.IsLoaded) { return(false); } if (state == 0) { // Start the warmup _warmupRequest = request; request.Tag = 1; _preview.Emitter = asset; } else if (_preview.PreviewActor.Time >= 0.6f) { // End the warmup request.Tag = 2; _preview.FitIntoView(); return(true); } // Handle warmup time for the preview _preview.PreviewActor.UpdateSimulation(); return(false); }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new ParticleEmitterPreview(false); _preview.RenderOnlyWithWindow = false; _preview.Task.Enabled = false; _preview.PostFxVolume.Settings.Eye_Technique = EyeAdaptationTechnique.None; _preview.PostFxVolume.Settings.Eye_Exposure = 0.1f; _preview.PostFxVolume.Settings.data.Flags4 |= 0b1001; _preview.Size = new Vector2(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize); _preview.SyncBackbufferSize(); } // Mark for initial warmup request.Tag = 0; }
public void Validate_WhenError(string fileName, long fileLength, string errorCode) { var fullPath = Path.GetFullPath(fileName); var request = new ThumbnailRequest { NewsId = Guid.NewGuid(), FileLength = fileLength, FileLocalPath = fullPath, FileName = fileName, }; var validator = new ThumbnailRequestValidation(); var validate = validator.Validate(request); validate.IsValid.Should().BeFalse(); validate.Errors.Should().Contain(x => x.ErrorCode == errorCode); }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new ModelPreview(false); _preview.RenderOnlyWithWindow = false; _preview.Task.Enabled = false; var eyeAdaptation = _preview.PostFxVolume.EyeAdaptation; eyeAdaptation.Mode = EyeAdaptationMode.None; eyeAdaptation.OverrideFlags |= EyeAdaptationSettings.Override.Mode; _preview.PostFxVolume.EyeAdaptation = eyeAdaptation; _preview.Size = new Vector2(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize); _preview.SyncBackbufferSize(); } // TODO: disable streaming for asset during thumbnail rendering (and restore it after) }
/// <inheritdoc /> public override void OnThumbnailDrawBegin(ThumbnailRequest request, ContainerControl guiRoot, GPUContext context) { _preview.Prefab = (Prefab)request.Asset; _preview.Parent = guiRoot; _preview.Scale = Vector2.One; _preview.ShowDefaultSceneActors = true; // Special case for UI prefabs if (_preview.Instance is UIControl uiControl && uiControl.HasControl) { // Ensure to place UI in a proper way uiControl.Control.Location = Vector2.Zero; uiControl.Control.Scale *= PreviewsCache.AssetIconSize / uiControl.Control.Size.MaxValue; uiControl.Control.DockStyle = DockStyle.None; uiControl.Control.AnchorStyle = AnchorStyle.Center; // Tweak preview _preview.ShowDefaultSceneActors = false; }
public void Validate_WhenSuccess() { var fileName = "image.jpg"; var fullPath = Path.GetFullPath(fileName); File.Exists(fullPath).Should().BeTrue(); var request = new ThumbnailRequest { NewsId = Guid.NewGuid(), FileLength = 3 * 1024 * 1024, FileLocalPath = fullPath, FileName = fileName, }; var validator = new ThumbnailRequestValidation(); var validate = validator.Validate(request); validate.IsValid.Should().BeTrue(); }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new MaterialPreview(false) { RenderOnlyWithWindow = false, AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, }; _preview.Task.Enabled = false; var eyeAdaptation = _preview.PostFxVolume.EyeAdaptation; eyeAdaptation.Mode = EyeAdaptationMode.None; eyeAdaptation.OverrideFlags |= EyeAdaptationSettingsOverride.Mode; _preview.PostFxVolume.EyeAdaptation = eyeAdaptation; } // TODO: disable streaming for dependant assets during thumbnail rendering (and restore it after) }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new ParticleEmitterPreview(false); _preview.RenderOnlyWithWindow = false; _preview.Task.Enabled = false; var eyeAdaptation = _preview.PostFxVolume.EyeAdaptation; eyeAdaptation.Mode = EyeAdaptationMode.None; eyeAdaptation.OverrideFlags |= EyeAdaptationSettings.Override.Mode; _preview.PostFxVolume.EyeAdaptation = eyeAdaptation; _preview.Size = new Vector2(PreviewsCache.AssetIconSize, PreviewsCache.AssetIconSize); _preview.SyncBackbufferSize(); } // Mark for initial warmup request.Tag = 0; }
/// <inheritdoc /> public override void OnThumbnailDrawBegin(ThumbnailRequest request, ContainerControl guiRoot, GPUContext context) { _preview.Prefab = (Prefab)request.Asset; _preview.Parent = guiRoot; // Update some actors data (some actor types update bounds/data later but its required to be done before rendering) Prepare(_preview.Instance); // Auto fit float targetSize = 30.0f; BoundingBox bounds; Editor.GetActorEditorBox(_preview.Instance, out bounds); float maxSize = Mathf.Max(0.001f, bounds.Size.MaxValue); _preview.Instance.Scale = new Vector3(targetSize / maxSize); _preview.Instance.Position = Vector3.Zero; _preview.Task.Internal_Render(context); }
private void GenerateThumbnails() { ThumbnailRequest req; while (true) { lock (in_queue) { if (in_queue.Count == 0) { thread = null; return; } req = ThumbnailRequest.Select(in_queue); in_queue.Remove(req); } Gdk.Pixbuf icon = factory.GenerateThumbnail(req.Hit.EscapedUri, req.Hit.MimeType); if (icon == null) { if (req.Hit.FileInfo != null) { factory.CreateFailedThumbnail(req.Hit.EscapedUri, req.Hit.FileInfo.LastWriteTime); } } else { factory.SaveThumbnail(icon, req.Hit.EscapedUri, DateTime.Now); if (File.Exists(req.ThumbnailFile)) { req.Succeeded = true; } } lock (out_queue) out_queue.Add(req); GLib.Idle.Add(FinishSetThumbnail); } }
/// <inheritdoc /> public override void OnThumbnailDrawPrepare(ThumbnailRequest request) { if (_preview == null) { _preview = new ParticleEmitterPreview(false) { RenderOnlyWithWindow = false, AnchorPreset = AnchorPresets.StretchAll, Offsets = Margin.Zero, }; _preview.Task.Enabled = false; var eyeAdaptation = _preview.PostFxVolume.EyeAdaptation; eyeAdaptation.Mode = EyeAdaptationMode.None; eyeAdaptation.OverrideFlags |= EyeAdaptationSettingsOverride.Mode; _preview.PostFxVolume.EyeAdaptation = eyeAdaptation; } // Mark for initial warmup request.Tag = 0; }