private void OnLoaded(object sender, RoutedEventArgs e) { if (HwndControl.Hwnd != IntPtr.Zero && renderer == IntPtr.Zero) { WindowAPI.InitRenderer(HwndControl.Hwnd, out renderer); CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); var spr = FindResource("WhitePixel") as BitmapImage; WindowAPI.RegisterTexture(renderer, "roaam_zone", System.AppDomain.CurrentDomain.BaseDirectory + spr.UriSource.LocalPath, 1, out var texture); LoadedImages["roaam_zone"] = new TexData(true, texture, WindowAPI.BitmapImageToBitmap(spr)); } }
public TexData LoadImage(string name) { // Check if the sprite is loaded if (!LoadedImages.ContainsKey(name)) { // If spritename is set, attempt to load sprite bool hasSprite = false; hasSprite = WindowAPI.LoadImage(name, renderer, out TexData data); LoadedImages.Add(name, data); // If no sprite is found, use EmptyImage for this article if (!hasSprite) { BitmapImage overrideSpr = FindResource("EmptyImage") as BitmapImage; WindowAPI.RegisterTexture(renderer, name, AppDomain.CurrentDomain.BaseDirectory + overrideSpr.UriSource.LocalPath, 1, out int texture); LoadedImages[name] = new TexData(false, texture, null); } } return(LoadedImages[name]); }