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)); } }