/// <summary> /// Takes an Image sFileName and tries to load it into MP' graphics memory /// If the sFileName was already in memory, it will not be reloaded (basically it caches) /// </summary> /// <param name="sFileName">The sFileName of the image to load, fails silently if it cannot be loaded</param> /// <returns>memory identifier</returns> public static string buildMemoryImageFromFile(string sFileName, System.Drawing.Size size) { try { if (String.IsNullOrEmpty(sFileName) || !System.IO.File.Exists(sFileName)) { return(string.Empty); } string ident = buildIdentifier(sFileName); if (GUITextureManager.LoadFromMemory(null, ident, 0, size.Width, size.Height) > 0) { //BaseConfig.MyAnimeLog.Write("buildMemoryImageFromFile: Got from MEMORY: {0}", ident); return(ident); } else { //BaseConfig.MyAnimeLog.Write("buildMemoryImageFromFile: Got from DISK: {0}", ident); return(buildMemoryImage(LoadImageFastFromFile(sFileName), ident, size, false)); } } catch (Exception e) { BaseConfig.MyAnimeLog.Write("Unable to add to MP's Graphics memory: " + sFileName + " Error: " + e.Message); return(string.Empty); } }
/// <summary> /// Takes an Image sFileName and tries to load it into MP' graphics memory /// If the sFileName was already in memory, it will not be reloaded (basically it caches) /// </summary> /// <param name="sFileName">The sFileName of the image to load, fails silently if it cannot be loaded</param> /// <returns>memory identifier</returns> public static string buildMemoryImageFromFile(string sFileName, System.Drawing.Size size) { try { if (String.IsNullOrEmpty(sFileName) || !System.IO.File.Exists(sFileName)) { return(string.Empty); } string ident = buildIdentifier(sFileName); //MPTVSeriesLog.WriteMultiLine("AsyncImageResource LoadFromMemory - " + Environment.StackTrace, MPTVSeriesLog.LogLevel.Debug); if (GUITextureManager.LoadFromMemory(null, ident, 0, size.Width, size.Height) > 0) { return(ident); } else { return(buildMemoryImage(LoadImageFastFromFile(sFileName), ident, size, false)); } } catch (Exception e) { MPTVSeriesLog.Write("Unable to add to MP's Graphics memory: " + sFileName + " Error: " + e.Message); return(string.Empty); } }
/// <summary> /// Loads an Image from memory into a facade item /// </summary> /// <param name="imageFilePath">Filename of image</param> protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // determine the overlays to add to poster var mainOverlay = MainOverlayImage.None; if (Season.IsWatchlisted(Show)) { mainOverlay = MainOverlayImage.Watchlist; } else if (Season.IsWatched(Show)) { mainOverlay = MainOverlayImage.Seenit; } // add additional overlay if applicable if (Season.IsCollected(Show)) { mainOverlay |= MainOverlayImage.Library; } RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(Season.UserRating(Show)); // get a reference to a MediaPortal Texture Identifier string suffix = Enum.GetName(typeof(MainOverlayImage), mainOverlay) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image Image memoryImage = null; if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected(WindowID, ItemId); }
protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } string texture = GetTextureFromFile(imageFilePath); if (GUITextureManager.LoadFromMemory(ImageFast.FromFile(imageFilePath), texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } // if selected and GUIActors is current window force an update of thumbnail GUIActors actorWindow = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow) as GUIActors; if (actorWindow != null) { GUIListItem selectedItem = GUIControl.GetSelectedListItem(9816, 50); if (selectedItem == this) { GUIWindowManager.SendThreadMessage(new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECT, GUIWindowManager.ActiveWindow, 0, 50, ItemId, 0, null)); } } }
public void RevertSkin() { //int ActiveWindowID = GUIWindowManager.ActiveWindow; // Change skin back to OutdatedSkinName GUIGraphicsContext.Skin = _userSkin; GUITextureManager.Clear(); GUITextureManager.Init(); SkinSettings.Load(); GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml")); GUIFontManager.InitializeDeviceObjects(); GUIExpressionManager.ClearExpressionCache(); GUIControlFactory.ClearReferences(); GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml")); GUIWindowManager.OnResize(); //GUIWindowManager.ActivateWindow(ActiveWindowID); using (Settings xmlreader = new MPSettings()) { xmlreader.SetValue("general", "skinobsoletecount", 0); if (!GUIGraphicsContext.Fullscreen) { try { GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height); } catch (Exception ex) { Log.Error("OnSkinChanged exception:{0}", ex.ToString()); Log.Error(ex); } } } }
private void OnSkinChanged() { // Backup the buttons, needed later BackupButtons(); // Set the skin to the selected skin and reload GUI GUIGraphicsContext.Skin = _btnSkin.Label; SaveSettings(); GUITextureManager.Clear(); GUITextureManager.Init(); SkinSettings.Load(); GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml")); GUIFontManager.InitializeDeviceObjects(); GUIExpressionManager.ClearExpressionCache(); GUIControlFactory.ClearReferences(); GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml")); GUIWindowManager.OnResize(); GUIWindowManager.ActivateWindow(GetID); GUIControl.FocusControl(GetID, _btnSkin.GetID); // Apply the selected buttons again, since they are cleared when we reload RestoreButtons(); using (Settings xmlreader = new MPSettings()) { xmlreader.SetValue("general", "skinobsoletecount", 0); if (!GUIGraphicsContext.Fullscreen) { try { var border = new Size(GUIGraphicsContext.form.Width - GUIGraphicsContext.form.ClientSize.Width, GUIGraphicsContext.form.Height - GUIGraphicsContext.form.ClientSize.Height); if (GUIGraphicsContext.SkinSize.Width + border.Width <= GUIGraphicsContext.currentScreen.WorkingArea.Width && GUIGraphicsContext.SkinSize.Height + border.Height <= GUIGraphicsContext.currentScreen.WorkingArea.Height) { GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height); } else { double ratio = Math.Min((double)(GUIGraphicsContext.currentScreen.WorkingArea.Width - border.Width) / GUIGraphicsContext.SkinSize.Width, (double)(GUIGraphicsContext.currentScreen.WorkingArea.Height - border.Height) / GUIGraphicsContext.SkinSize.Height); GUIGraphicsContext.form.ClientSize = new Size((int)(GUIGraphicsContext.SkinSize.Width * ratio), (int)(GUIGraphicsContext.SkinSize.Height * ratio)); } } catch (Exception ex) { Log.Error("OnSkinChanged exception:{0}", ex.ToString()); Log.Error(ex); } } } if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null) { BassMusicPlayer.Player.VisualizationWindow.Reinit(); } // Send a message that the skin has changed. var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SKIN_CHANGED, 0, 0, 0, 0, 0, null); GUIGraphicsContext.SendMessage(msg); }
private string loadResourceSafe(string filename) { if (filename == null || filename.Trim().Length == 0) { return(null); } // try to load with new persistent load feature try { if (loadResource(filename)) { return(filename); } } catch (MissingMethodException) { if (!warned) { //logger.Warn("Cannot preform asynchronous loading with this version of MediaPortal. Please upgrade for improved performance."); warned = true; } } // if not available load image ourselves and pass to MediaPortal. Much slower but this still // gives us asynchronous loading. Image image = LoadImageFastFromFile(filename); if (GUITextureManager.LoadFromMemory(image, getIdentifier(filename), 0, 0, 0) > 0) { return(getIdentifier(filename)); } return(null); }
private static void Flush(string sTextureName) { if (Utils.SpectrumDebug) { logger.Debug("Images: Flush {0}", sTextureName); } GUITextureManager.ReleaseTexture(sTextureName); }
/// <summary> /// Loads an Image from memory into a facade item /// </summary> /// <param name="imageFilePath">Filename of image</param> protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // determine the main overlay to add to poster TraktMovie movie = TVTag as TraktMovie; MainOverlayImage mainOverlay = MainOverlayImage.None; if (movie.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } if (movie.InCollection) { mainOverlay |= MainOverlayImage.Library; } // we never show rating movies in Recommendations RatingOverlayImage ratingOverlay = RatingOverlayImage.None; // get a reference to a MediaPortal Texture Identifier string suffix = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image Image memoryImage = null; if (mainOverlay != MainOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected((int)TraktGUIWindows.RecommendationsMovies, ItemId); }
/// <summary> /// Loads an Image from memory into a facade item /// </summary> /// <param name="imageFilePath">Filename of image</param> protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // check if this user item is a shout // we may need to apply a rating overlay to the avatar if (TVTag is TraktComment) { var shout = TVTag as TraktComment; // add a rating overlay if user has rated item var ratingOverlay = GUIImageHandler.GetRatingOverlay(shout.UserRating); // get a reference to a MediaPortal Texture Identifier string suffix = Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image, resize avatar as they come in different sizes sometimes Image memoryImage = null; if (ratingOverlay != RatingOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnAvatar(imageFilePath, ratingOverlay, new Size(140, 140)); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected(WindowID, ItemId); }
/// <summary> /// If previously loaded, unloads the resource from memory and removes it /// from the MediaPortal GUITextureManager. /// </summary> private void unloadResource(string filename) { if (filename == null) { return; } // double duty since we dont know if we loaded via new fast way or old // slow way GUITextureManager.ReleaseTexture(getIdentifier(filename)); GUITextureManager.ReleaseTexture(filename); }
/// <summary> /// Loads an Image from memory into a facade item /// </summary> /// <param name="imageFilePath">Filename of image</param> protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // determine the overlays to add to poster TraktShow show = TVTag as TraktShow; MainOverlayImage mainOverlay = MainOverlayImage.None; if (show.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } //else if (show.Watched) // mainOverlay = MainOverlayImage.Seenit; RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(show.RatingAdvanced); // get a reference to a MediaPortal Texture Identifier string suffix = Enum.GetName(typeof(MainOverlayImage), mainOverlay) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image Image memoryImage = null; if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected((int)TraktGUIWindows.RelatedShows, ItemId); }
void setCover() { if (isAudioPlaying && nextCover != null) { GUIPropertyManager.SetProperty("#Play.Current.Thumb", nextCover); if (!string.IsNullOrEmpty(currentCover)) { GUITextureManager.ReleaseTexture(currentCover); } currentCover = nextCover; nextCover = null; } }
private void OnSkinChanged() { // Backup the buttons, needed later BackupButtons(); // Set the skin to the selected skin and reload GUI GUIGraphicsContext.Skin = btnSkin.Label; SaveSettings(); GUITextureManager.Clear(); GUITextureManager.Init(); SkinSettings.Load(); GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml")); GUIFontManager.InitializeDeviceObjects(); GUIExpressionManager.ClearExpressionCache(); GUIControlFactory.ClearReferences(); GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml")); GUIWindowManager.OnResize(); GUIWindowManager.ActivateWindow(GetID); GUIControl.FocusControl(GetID, btnSkin.GetID); // Apply the selected buttons again, since they are cleared when we reload RestoreButtons(); using (Settings xmlreader = new MPSettings()) { xmlreader.SetValue("general", "skinobsoletecount", 0); bool autosize = xmlreader.GetValueAsBool("gui", "autosize", true); if (autosize && !GUIGraphicsContext.Fullscreen) { try { GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height); //Form.ActiveForm.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height); } catch (Exception ex) { Log.Error("OnSkinChanged exception:{0}", ex.ToString()); Log.Error(ex); } } } if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null) { BassMusicPlayer.Player.VisualizationWindow.Reinit(); } // Send a message that the skin has changed. GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SKIN_CHANGED, 0, 0, 0, 0, 0, null); GUIGraphicsContext.SendMessage(msg); }
void airtunesServer_ArtworkChanged(object sender, ArtwokChangedEventArgs e) { string newCover = saveCover(e.ImageData); invoke(delegate() { //we've previously loaded an image but never displayed it if (!string.IsNullOrEmpty(nextCover)) { GUITextureManager.ReleaseTexture(nextCover); } nextCover = newCover; setCover(); }, false); }
public static string BuildConcatSpectrumImage(List <int> spectrum, List <int> spectrumpeak, int bars, int spacing, int min, int max) { if (spectrum == null) { return(string.Empty); } if (!Utils.SpectrumImageFound) { return(string.Empty); } try { if (spectrum.Count > 0) { string spectrumLine = string.Empty; string spectrumPeakLine = string.Empty; bool skeepPeak = !Utils.SpectrumPeakEnabled || !Utils.SpectrumPeakImageFound || (spectrum.Count != spectrumpeak.Count); for (int i = 0; i < spectrum.Count; i++) { spectrumLine += spectrum[i].ToString("000"); if (!skeepPeak) { spectrumPeakLine += spectrumpeak[i].ToString("000"); } } // string sFile = @"skin\s" + spectrumLine + (!skeepPeak ? "p" + spectrumPeakLine : string.Empty); string sFile = @"skin\s" + spectrumLine.GetHashCode().ToString("x") + (!skeepPeak ? "p" + spectrumPeakLine.GetHashCode().ToString("x") : string.Empty); sFile = "[" + (Utils.SpectrumDebug ? "" : "NoLog:") + "SpectrumImage:" + sFile + "]"; if (SpectrumImages.Contains(sFile) && GUITextureManager.LoadFromMemory(null, sFile, 0, 0, 0) > 0) // Name already exists in MP cache { return(sFile); } else { return(BuildSpectrumImage(spectrum, spectrumpeak, bars, spacing, min, max, sFile, bSpectrumVertical)); } } } catch (Exception ex) { logger.Error("BuildConcatImage: The Logo Building Engine generated an error: " + ex.Message); } return(string.Empty); }
/// <summary> /// Loads the given file into memory and registers it with MediaPortal. /// </summary> /// <param name="filename">The image file to be loaded.</param> private bool loadResource(string filename) { if (!_active || filename == null || !File.Exists(filename)) { return(false); } try { if (GUITextureManager.Load(filename, 0, 0, 0, true) > 0) { return(true); } } catch { } return(false); }
static bool loadImage(string identifier, byte[] imageData) { try { using (MemoryStream ms = new MemoryStream(imageData)) { if (GUITextureManager.LoadFromMemory(System.Drawing.Image.FromStream(ms), identifier, 0, 0, 0) > 0) { return(true); } } } catch (Exception ex) { Logger.Instance.Error("Airplayer: Error loading image to TextureManager -", ex); } return(false); }
string loadImageFromBuffer(string filename, byte[] buffer) { try { using (MemoryStream ms = new MemoryStream(buffer)) { Image image = Image.FromStream(ms); if (GUITextureManager.LoadFromMemory(image, getIdentifier(filename), 0, 0, 0) > 0) { return(getIdentifier(filename)); } } } catch (Exception ex) { Logger.Instance.Error("AsyncImageResource: Error loading image from buffer -", ex); } return(null); }
/// <summary> /// Loads the given file into memory and registers it with MediaPortal. /// </summary> /// <param name="filename">The image file to be loaded.</param> private bool loadResource(string filename) { if (!_active || filename == null || !File.Exists(filename)) { return(false); } try { if (GUITextureManager.Load(filename, 0, 0, 0, true) > 0) { return(true); } } catch (Exception) { logger.Error("MediaPortal failed to load artwork: " + filename); } return(false); }
public static string BuildConcatVUMeterImage(List <int> vumeter, List <int> vumeterpeak, int spacing, int min, int max) { if (!Utils.VUMeterImageFound) { return(string.Empty); } try { if (vumeter.Count > 0) { string vumeterLine = string.Empty; string vumeterPeakLine = string.Empty; bool skeepPeak = !Utils.VUMeterPeakImageFound || (vumeter.Count != vumeterpeak.Count); for (int i = 0; i < vumeter.Count; i++) { vumeterLine += vumeter[i].ToString("000"); if (!skeepPeak) { vumeterPeakLine += vumeterpeak[i].ToString("000"); } } string sFile = @"skin\s" + vumeterLine.GetHashCode().ToString("x") + (!skeepPeak ? "p" + vumeterPeakLine.GetHashCode().ToString("x") : string.Empty); sFile = "[" + (Utils.SpectrumDebug ? "" : "NoLog:") + "VUMeterImage:" + sFile + "]"; if (VUMeterImages.Contains(sFile) && GUITextureManager.LoadFromMemory(null, sFile, 0, 0, 0) > 0) // Name already exists in MP cache { return(sFile); } else { return(BuildVUMeterImage(vumeter, vumeterpeak, 2, spacing, min, max, sFile, bVUMeterVertical)); } } } catch (Exception ex) { logger.Error("BuildConcatImage: The Logo Building Engine generated an error: " + ex.Message); } return(string.Empty); }
/// <summary> /// Redraws the images /// </summary> protected void Redraw() { Log.Info("dvb-teletext redraw()"); if (bmpTeletextPage != null) { try { // First update the foreground image. Step 1 make it invisible _updatingForegroundImage = true; imgTeletextForeground.IsVisible = false; // Clear the old image Image img = (Image)bmpTeletextPage.Clone(); imgTeletextForeground.FileName = ""; GUITextureManager.ReleaseTexture("[teletextpage]"); // Set the new image and make the image visible again imgTeletextForeground.MemoryImage = img; imgTeletextForeground.FileName = "[teletextpage]"; imgTeletextForeground.KeepAspectRatio = false; imgTeletextForeground.IsVisible = true; _updatingForegroundImage = false; // Update the background image now. Therefor make image invisible _updatingBackgroundImage = true; imgTeletextBackground.IsVisible = false; // Clear the old image Image img2 = (Image)bmpTeletextPage.Clone(); imgTeletextBackground.FileName = ""; GUITextureManager.ReleaseTexture("[teletextpage2]"); // Set the new image and make the image visible again imgTeletextBackground.MemoryImage = img2; imgTeletextBackground.FileName = "[teletextpage2]"; imgTeletextBackground.KeepAspectRatio = false; imgTeletextBackground.IsVisible = true; _updatingBackgroundImage = false; } catch (Exception ex) { Log.Error(ex); } } }
/// <summary> /// Takes an Image and tries to load it into MP' graphics memory /// If the sFileName was already in memory, it will not be reloaded (basically it caches) /// </summary> /// <param name="image">The System.Drawing.Bitmap to be loaded</param> /// <param name="identifier">A unique identifier for the image so it can be retrieved later on</param> /// <returns>memory identifier</returns> public static string buildMemoryImage(Image image, string identifier, System.Drawing.Size size, bool buildIdentifier) { string name = buildIdentifier ? ImageAllocator.buildIdentifier(identifier) : identifier; try { // we don't have to try first, if name already exists mp will not do anything with the image if (size.Height > 0 && (size.Height != image.Size.Height || size.Width != image.Size.Width)) //resize { image = Resize(image, size); } //PerfWatcher.GetNamedWatch("add to TextureManager").Start(); GUITextureManager.LoadFromMemory(image, name, 0, size.Width, size.Height); //PerfWatcher.GetNamedWatch("add to TextureManager").Stop(); } catch (Exception) { //MPTVSeriesLog.Write("Unable to add to MP's Graphics memory: " + identifier); return(string.Empty); } return(name); }
public void RevertSkin() { //int ActiveWindowID = GUIWindowManager.ActiveWindow; // Change skin back to OutdatedSkinName GUIGraphicsContext.Skin = _userSkin; GUITextureManager.Clear(); GUITextureManager.Init(); GUIFontManager.LoadFonts(GUIGraphicsContext.Skin + @"\fonts.xml"); GUIFontManager.InitializeDeviceObjects(); GUIExpressionManager.ClearExpressionCache(); GUIControlFactory.ClearReferences(); GUIControlFactory.LoadReferences(GUIGraphicsContext.Skin + @"\references.xml"); GUIWindowManager.OnResize(); //GUIWindowManager.ActivateWindow(ActiveWindowID); using (Settings xmlreader = new MPSettings()) { xmlreader.SetValue("general", "skinobsoletecount", 0); bool autosize = xmlreader.GetValueAsBool("gui", "autosize", true); if (autosize && !GUIGraphicsContext.Fullscreen) { try { GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height); //Form.ActiveForm.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height); } catch (Exception ex) { Log.Error("OnSkinChanged exception:{0}", ex.ToString()); Log.Error(ex); } } } if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null) { BassMusicPlayer.Player.VisualizationWindow.Reinit(); } }
private string loadResourceSafe(string filename) { if (filename == null || filename.Trim().Length == 0) { return(null); } // try to load with new persistent load feature try { if (loadResource(filename)) { return(filename); } } catch (MissingMethodException) { if (!warned) { BaseConfig.MyAnimeLog.Write("AsyncImageResource: Cannot preform asynchronous loading with this version of MediaPortal. Please upgrade for improved performance."); warned = true; } } // if not available load image ourselves and pass to MediaPortal. Much slower but this still // gives us asynchronous loading. Image image = LoadImageFastFromFile(filename); //MPTVSeriesLog.WriteMultiLine("AsyncImageResource LoadFromMemory - " + Environment.StackTrace, MPTVSeriesLog.LogLevel.Debug); if (GUITextureManager.LoadFromMemory(image, getIdentifier(filename), 0, 0, 0) > 0) { return(getIdentifier(filename)); } return(null); }
public static void Flush(string sTextureName) { GUITextureManager.ReleaseTexture(sTextureName); }
/// <summary> /// Loads an Image from memory into a facade item /// </summary> /// <param name="imageFilePath">Filename of image</param> protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // determine the overlay to add to poster var movie = TVTag as TraktMovie; var mainOverlay = MainOverlayImage.None; // don't show watchlist overlay in personal watchlist window if (WindowID == (int)TraktGUIWindows.WatchedListMovies) { if ((GUIWatchListMovies.CurrentUser != TraktSettings.Username) && movie.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } else if (movie.Watched) { mainOverlay = MainOverlayImage.Seenit; } } else { if (movie.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } else if (movie.Watched) { mainOverlay = MainOverlayImage.Seenit; } } // add additional overlay if applicable if (movie.InCollection) { mainOverlay |= MainOverlayImage.Library; } RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(movie.RatingAdvanced); // get a reference to a MediaPortal Texture Identifier string suffix = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image Image memoryImage = null; if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected(WindowID, ItemId); }
/// <summary> /// Loads an Image from memory into a facade item /// </summary> /// <param name="imageFilePath">Filename of image</param> protected void SetImageToGui(string imageFilePath) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // determine the overlay to add to poster TraktEpisode episode = TVTag as TraktEpisode; MainOverlayImage mainOverlay = MainOverlayImage.None; if (episode.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } else if (episode.Watched) { mainOverlay = MainOverlayImage.Seenit; } // add additional overlay if applicable if (episode.InCollection) { mainOverlay |= MainOverlayImage.Library; } RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(episode.RatingAdvanced); // get a reference to a MediaPortal Texture Identifier string suffix = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image, resize thumbnail incase its a fanart Image memoryImage = null; if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnEpisodeThumb(imageFilePath, mainOverlay, ratingOverlay, new Size(400, 225)); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected((int)TraktGUIWindows.SeasonEpisodes, ItemId); }
static string BuildVUMeterImage(List <int> vumeter, List <int> vumeterpeak, int bars, int spacing, int min, int max, string sFileName, bool Vertical) { // step zero: prepare images int cropSteps = (max - min) + 1; if (cropSteps <= 0) { return(string.Empty); } InitVUMeterImages(); if (vumeterImage == null) { return(string.Empty); } // step one: get result sizes if (Vertical) { iVUMeterWidth = vumeterImage.Width * bars + spacing * (bars - 1); iVUMeterHeight = vumeterImage.Height; } else { iVUMeterWidth = vumeterImage.Width; iVUMeterHeight = vumeterImage.Height * bars + spacing * (bars - 1); } // step one: get all images bool skeepPeak = !Utils.VUMeterPeakImageFound || (vumeter.Count != vumeterpeak.Count) || (vumeterPeak == null); List <Image> imgs = new List <Image>(); List <Image> imgspeak = new List <Image>(); Image single = null; for (int i = 0; i < vumeter.Count; i++) { try { int cropWidth = Vertical ? 0 : (vumeterImage.Width / cropSteps) * vumeter[i]; int cropHeight = Vertical ? (vumeterImage.Height / cropSteps) * vumeter[i] : 0; single = CropImage(vumeterImage, cropWidth, cropHeight, bVUMeterVertical); if (single == null) { continue; } } catch (Exception) { logger.Error("Skip: Could not crop Image for " + vumeter[i]); continue; } imgs.Add(single); if (!skeepPeak) { try { int barWidth = Vertical ? vumeterImage.Width : (vumeterImage.Width / cropSteps) * vumeterpeak[i]; int barHeight = Vertical ? (vumeterImage.Height / cropSteps) * vumeterpeak[i] : vumeterImage.Height; single = MakePeakImage(vumeterPeak, barWidth, barHeight, bVUMeterVertical); if (single == null) { continue; } } catch (Exception) { logger.Error("Skip: Could not makePeak Image for " + vumeter[i] + " - " + vumeterpeak[i]); continue; } imgspeak.Add(single); } } // step two: finally draw them skeepPeak = imgs.Count != imgspeak.Count; Bitmap b = new Bitmap(iVUMeterWidth, iVUMeterHeight); Image img = b; Graphics g = Graphics.FromImage(img); try { int x_pos = 0; int y_pos = 0; for (int i = 0; i < imgs.Count; i++) { if (Vertical) { g.DrawImage(imgs[i], x_pos, iVUMeterHeight - imgs[i].Height, imgs[i].Width, imgs[i].Height); if (!skeepPeak) { g.DrawImage(imgspeak[i], x_pos, iVUMeterHeight - imgspeak[i].Height, imgspeak[i].Width, imgspeak[i].Height); } x_pos += imgs[i].Width + spacing; } else { g.DrawImage(imgs[i], iVUMeterWidth - imgs[i].Width, y_pos, imgs[i].Width, imgs[i].Height); if (!skeepPeak) { g.DrawImage(imgspeak[i], iVUMeterWidth - imgspeak[i].Width, y_pos, imgspeak[i].Width, imgspeak[i].Height); } y_pos += imgs[i].Height + spacing; } } } finally { g.Dispose(); } // step three: build image in memory string name = sFileName; try { // we don't have to try first, if name already exists mp will not do anything with the image GUITextureManager.LoadFromMemory(b, name, 0, iVUMeterWidth, iVUMeterHeight); if (!string.IsNullOrEmpty(name) && !VUMeterImages.Contains(name)) { AddVUMeterImage(name); } } catch (Exception) { logger.Error("BuildImages: Unable to add to MP's Graphics memory: " + name); return(string.Empty); } return(name); }
protected void SetImageToGui(string imageFilePath, Size size) { if (string.IsNullOrEmpty(imageFilePath)) { return; } // determine the overlay to add to poster var mainOverlay = MainOverlayImage.None; var ratingOverlay = RatingOverlayImage.None; if (TVTag is TraktUserListItem) { var listItem = TVTag as TraktUserListItem; if (listItem == null) { return; } if (listItem.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } else if (listItem.Watched) { mainOverlay = MainOverlayImage.Seenit; } // add additional overlay if applicable if (listItem.InCollection) { mainOverlay |= MainOverlayImage.Library; } ratingOverlay = GUIImageHandler.GetRatingOverlay(listItem.RatingAdvanced); } else if (TVTag is TraktActivity.Activity) { var activity = TVTag as TraktActivity.Activity; if (activity == null) { return; } var movie = activity.Movie; var show = activity.Show; if (movie != null && movie.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } else if (show != null && show.InWatchList) { mainOverlay = MainOverlayImage.Watchlist; } else if (movie != null && movie.Watched) { mainOverlay = MainOverlayImage.Seenit; } // add additional overlay if applicable if (movie != null && movie.InCollection) { mainOverlay |= MainOverlayImage.Library; } if (movie != null) { ratingOverlay = GUIImageHandler.GetRatingOverlay(movie.RatingAdvanced); } else { ratingOverlay = GUIImageHandler.GetRatingOverlay(show.RatingAdvanced); } } // get a reference to a MediaPortal Texture Identifier string suffix = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay); string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix); // build memory image Image memoryImage = null; if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None) { memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay, size); if (memoryImage == null) { return; } // load texture into facade item if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0) { ThumbnailImage = texture; IconImage = texture; IconImageBig = texture; } } else { ThumbnailImage = imageFilePath; IconImage = imageFilePath; IconImageBig = imageFilePath; } // if selected and is current window force an update of thumbnail this.UpdateItemIfSelected(WindowID, ItemId); }