/// <summary> /// Rafraichi l'animation /// </summary> /// <param name="pContainer">Containeur de l'animation</param> /// <param name="pCurrentSprite">Sprite courant</param> /// <returns>Surface</returns> public Image RefreshAnimation(Rectangle container, Rectangle currentSprite) { //Chargement background if (_BackgroundAnimPreview == null) { _BackgroundAnimPreview = new VO_BackgroundSerial(new Size(container.Width, container.Height), EditorSettings.Instance.TransparentBlockSize); ImageManager.CreateNewImageBackground(_BackgroundAnimPreview); } //Preview Image sprite = new Bitmap(currentSprite.Width, currentSprite.Height); Graphics graphicsSprite = Graphics.FromImage(sprite); graphicsSprite.DrawImage(ImageManager.GetImageResource(_ResourceOriginal), new Rectangle(new Point(0, 0), new Size(currentSprite.Width, currentSprite.Height)), new Rectangle(new Point(currentSprite.X, currentSprite.Y), new Size(currentSprite.Width, currentSprite.Height)), GraphicsUnit.Pixel); Image mainSurface = FormsTools.GetImageReducedAndCentered(sprite, ImageManager.GetImageBackground(_BackgroundAnimPreview), container, new Rectangle(new Point(0, 0), new Size(currentSprite.Width, currentSprite.Height)), false); graphicsSprite.Dispose(); sprite.Dispose(); return(mainSurface); }
/// <summary> /// Rafraichi la ressource /// </summary> /// <param name="pContainer">Containeur de l'animation</param> /// <param name="pCurrentSprite">Sprite courant</param> /// <param name="pFull">False si la ressource est redimmensionnée, sinon true</param> /// <returns>Surface</returns> public Image RefreshRessource(Rectangle container, Rectangle currentSprite, bool full) { //Chargement background if (_BackgroundResource == null) { _BackgroundResource = new VO_BackgroundSerial(new Size(container.Width, container.Height), EditorSettings.Instance.TransparentBlockSize); ImageManager.CreateNewImageBackground(_BackgroundAnimPreview); } //Ressource Image resourceInSurfaceControl; Image resource = (Image)ImageManager.GetImageResource(_ResourceOriginal).Clone(); Graphics resourceGraphics = Graphics.FromImage(resource); Image highlighted = new Bitmap(currentSprite.Width, currentSprite.Height); Graphics highlightGraphics = Graphics.FromImage(highlighted); highlightGraphics.FillRectangle(EditorSettings.Instance.HighlightningBrush, new Rectangle(new Point(0, 0), new Size(highlighted.Width, highlighted.Height))); resourceGraphics.DrawImage(highlighted, new Rectangle(currentSprite.Location, new Size(resource.Width, resource.Height)), 0, 0, resource.Width, resource.Height, GraphicsUnit.Pixel, _ImageTransparency); if (!full) { resourceInSurfaceControl = FormsTools.GetImageReducedAndCentered(resource, ImageManager.GetImageBackground(_BackgroundResource), container, new Rectangle(new Point(0, 0), ImageManager.GetImageResource(_ResourceOriginal).Size), full); } else { resourceInSurfaceControl = FormsTools.GetImageReducedAndCentered(resource, ImageManager.GetImageBackground(_BackgroundResource), container, container, full); } resource.Dispose(); resourceGraphics.Dispose(); highlighted.Dispose(); highlightGraphics.Dispose(); return(resourceInSurfaceControl); }