/// <inheritdoc /> protected override void Dispose(bool disposing) { if (_disposed) { return; } foreach (var rtv in RtvArraySlices) { rtv.Dispose(); } foreach (var srv in SrvArraySlices) { srv.Dispose(); } foreach (var dsv in DsvArraySlices) { dsv.Dispose(); } NativeTexture?.Dispose(); RtvArraySlices.Clear(); SrvArraySlices.Clear(); DsvArraySlices.Clear(); _disposed = true; }
protected override void TryLoadImage(Stream fileData) { NativeTexture = Texture.FromStream(device.NativeDevice, fileData, Usage.None, Pool.Managed); WarnAboutWrongAlphaFormat(NativeTexture.GetLevelDescription(0).Format == Format.A8R8G8B8); var textureSize = new Size(NativeTexture.GetLevelDescription(0).Width, NativeTexture.GetLevelDescription(0).Height); CompareActualSizeMetadataSize(textureSize); }
protected override void DisposeData() { if (NativeResourceView != null) { NativeResourceView.Dispose(); } if (NativeTexture != null) { NativeTexture.Dispose(); } }
void OnGUI() { if (GUILayout.Button("TakeSnap", GUILayout.Height(150), GUILayout.Width(150))) { Debug.Log("TakeSnap " + imgpath); TakeScreenShotFromScreenSize(tex => { SaveTexture(tex, imgpath); }); } if (GUILayout.Button("LoadByCS", GUILayout.Height(150), GUILayout.Width(150))) { Debug.Log("Load By CS " + imgpath); if (!File.Exists(imgpath)) { Debug.LogError(imgpath + " not exist!!!"); } var bytes = File.ReadAllBytes(imgpath); Texture2D texture = new Texture2D(1280, 800); texture.LoadImage(bytes); img.texture = texture; } if (GUILayout.Button("Load", GUILayout.Height(150), GUILayout.Width(150))) { Debug.Log("Load " + imgpath); if (!File.Exists(imgpath)) { Debug.LogError(imgpath + " not exist!!!"); } currentRawTexture = new NativeTexture(imgpath); img.texture = currentRawTexture.Tex; } if (GUILayout.Button("LoadFromStreamingAssets", GUILayout.Height(150), GUILayout.Width(150))) { Debug.Log("LoadFromStreamingAssets " + "test.png"); currentRawTexture = new NativeTexture("test.png", true); img.texture = currentRawTexture.Tex; } if (GUILayout.Button("UnLoad", GUILayout.Height(150), GUILayout.Width(150))) { Debug.Log("UnLoad"); currentRawTexture.Dispose(); } }
internal T QueryInterface <T>() where T : ComObject { return(NativeTexture.QueryInterface <T>()); }