/// <summary> /// Translates a panel's local drawing coordinate into view space, taking offsets into account. /// </summary> public static void Translate(Point renderOffset, ref Rectangle rect) { rect.X = TranslateX(renderOffset, rect.X); rect.Y = TranslateY(renderOffset, rect.Y); //rect.Width = Util.Ceil(rect.Width * Scale); //rect.Height = Util.Ceil(rect.Height * Scale); rect.Width = (int)System.Math.Ceiling(rect.Width); rect.Height = (int)System.Math.Ceiling(rect.Height); }
static ITexture CropTexture(ITexture texture, Rectangle bounds, string name) { IRenderTexture renderTexture = DriverManager.ActiveDriver.ResourceManager.CreateRenderTexture(bounds.Width, bounds.Height); renderTexture.DrawStretched(texture, new Rectangle(0, 0, bounds.Width, bounds.Height), bounds); renderTexture.Display(); string elementPath = Path.Combine(DriverManager.ActiveDriver.ResourceManager.ResourceDirectory, "Skins", "DefaultSkin", "Elements", name + ".png"); if (Directory.Exists(Path.GetDirectoryName(elementPath)) == false) { Directory.CreateDirectory(Path.GetDirectoryName(elementPath)); } renderTexture.Texture.Save(elementPath); return renderTexture.Texture; }