[Test] public void RequestContent() { // Create a test resource and save it somewhere to be retrieved later Pixmap resource = new Pixmap(); string path = PathOp.Combine(DualityApp.DataDirectory, "Test" + Resource.GetFileExtByType <Pixmap>()); resource.Save(path, false); resource.Dispose(); resource = null; // Request the resource from its path and expect it to be valid Assert.IsNotNull(ContentProvider.RequestContent <Pixmap>(path).Res); Assert.IsNotNull(ContentProvider.RequestContent(path).Res); Assert.IsTrue(ContentProvider.HasContent(path)); CollectionAssert.Contains(ContentProvider.GetLoadedContent <Pixmap>(), new ContentRef <Pixmap>(null, path)); CollectionAssert.Contains(ContentProvider.GetAvailableContent <Pixmap>(), new ContentRef <Pixmap>(null, path)); // Request the resource multiple times and expect the same instance to be returned ContentRef <Pixmap> requestA = ContentProvider.RequestContent <Pixmap>(path); ContentRef <Pixmap> requestB = ContentProvider.RequestContent <Pixmap>(path); Assert.AreEqual(requestA, requestB); Assert.AreSame(requestA.Res, requestB.Res); // Dispose the resource and expect an automatic reload on access Pixmap oldResource = requestA.Res; oldResource.Dispose(); Assert.IsNotNull(requestA.Res); Assert.IsNotNull(requestB.Res); Assert.AreEqual(requestA, requestB); Assert.AreSame(requestA.Res, requestB.Res); }
void ShapeWindow() { Layout(); var bitmap = new Pixmap(GdkWindow, Allocation.Width, Allocation.Height, 1); Context g = CairoHelper.Create(bitmap); DrawShape(g, Allocation.Width, Allocation.Height); g.Dispose(); if (use_shape_ext) { ShapeCombineMask(bitmap, 0, 0); } else { Context rgba = CairoHelper.Create(GdkWindow); DrawShape(rgba, Allocation.Width, Allocation.Height); rgba.Dispose(); try { CompositeUtils.InputShapeCombineMask(this, bitmap, 0, 0); } catch (EntryPointNotFoundException) { Log.Warning("gtk+ version doesn't support input shapping"); } } bitmap.Dispose(); }
public void SaveScreenShot(string path, int width, int height, int pitch, IntPtr data, int size, bool flipVertical) { var pixmap = new Pixmap(data, width, height); pixmap.SaveToFile(path); pixmap.Dispose(); }
void DestroyBgBuffer() { if (curUpdate != null) { curUpdate.RemoveHandler(); } if (backgroundPixbuf != null) { backgroundPixbuf.Dispose(); backgroundBuffer.Dispose(); backgroundPixbuf = backgroundBuffer = null; curWidth = curHeight = -1; } }
private byte[] ProcessImageFile(FileInfo file, out int imageWidth, out int imageHeight) { Pixmap pixmap = AssetLoader.LoadPixmap(file.FullName); imageWidth = pixmap.Width; imageHeight = pixmap.Height; var data = new byte[pixmap.ByteArray.Length]; pixmap.ByteArray.CopyTo(data, 0); pixmap.Dispose(); return(data); }
[Test] public void DisposeRemovesContent() { Pixmap resource = new Pixmap(); string alias = "Foo"; // Register the new resource with the provider ContentProvider.AddContent(alias, resource); // Dispose the resource resource.Dispose(); // Expect the resource to be disposed and no longer show up in API calls Assert.IsTrue(resource.Disposed); Assert.IsFalse(ContentProvider.HasContent(alias)); Assert.IsNull(ContentProvider.RequestContent <Pixmap>(alias).Res); Assert.IsNull(ContentProvider.RequestContent(alias).Res); CollectionAssert.DoesNotContain(ContentProvider.GetLoadedContent <Pixmap>(), (ContentRef <Pixmap>)resource); // Expect the resource path to remain unchanged, in order to allow reload-recovery Assert.AreEqual(alias, resource.Path); }
void ShapeWindow() { Layout (); var bitmap = new Pixmap (GdkWindow, Allocation.Width, Allocation.Height, 1); Context g = CairoHelper.Create (bitmap); DrawShape (g, Allocation.Width, Allocation.Height); g.Dispose (); if (use_shape_ext) ShapeCombineMask (bitmap, 0, 0); else { Context rgba = CairoHelper.Create (GdkWindow); DrawShape (rgba, Allocation.Width, Allocation.Height); rgba.Dispose (); try { CompositeUtils.InputShapeCombineMask (this, bitmap, 0,0); } catch (EntryPointNotFoundException) { Log.Warning ("gtk+ version doesn't support input shapping"); } } bitmap.Dispose (); }