private void DestroyBitmapResources() { if (this.wheelBackgroundDeviceBitmap != null) { this.wheelBackgroundDeviceBitmap.BitmapSource = null; this.wheelBackgroundDeviceBitmap = null; } DisposableUtil.Free <ISurface <ColorBgra> >(ref this.wheelBackgroundSurface); }
private void CreateBitmapResources() { DisposableUtil.Free <ISurface <ColorBgra> >(ref this.wheelBackgroundSurface); this.wheelBackgroundSurface = new Surface(base.ClientRectangle.Size.ToSizeInt32()); this.DrawWheelSurface(this.wheelBackgroundSurface); if (!base.Enabled) { DisabledRendering.ConvertToDisabled(this.wheelBackgroundSurface); } this.wheelBackgroundBitmap = this.wheelBackgroundSurface.CreateAliasedImagingBitmap(PixelFormats.Bgra32); this.wheelBackgroundDeviceBitmap = new DeviceBitmap(this.wheelBackgroundBitmap); }
protected SettingsDialogSection(PaintDotNet.Settings.App.AppSettings appSettings, string displayName, Image icon) { Validate.Begin().IsNotNull <PaintDotNet.Settings.App.AppSettings>(appSettings, "appSettings").IsNotNullOrWhiteSpace(displayName, "displayName").IsNotNull <Image>(icon, "icon").Check(); this.appSettings = appSettings; this.displayName = displayName; this.icon = icon; Surface cleanupObject = Surface.CopyFromGdipImage(this.icon); this.bitmapIcon = new BitmapProxy(cleanupObject.CreateAliasedImagingBitmap(), ObjectRefProxyOptions.AssumeOwnership); this.bitmapIcon.AddCleanupObject(cleanupObject); this.deviceIcon = new DeviceBitmap(this.bitmapIcon); this.sectionSettings = new HashSet <Setting>(); }
static CheckerboardCanvasLayer() { ColorBgra white = ColorBgra.White; ColorBgra color = ColorBgra.FromUInt32(0xffbfbfbf); checkerboardSurface = new Surface(0x10, 0x10); checkerboardSurface.Clear(white); checkerboardSurface.Clear(new RectInt32(0, 0, 8, 8), color); checkerboardSurface.Clear(new RectInt32(8, 8, 8, 8), color); checkerboardBitmap = checkerboardSurface.CreateAliasedImagingBitmap(PixelFormats.Bgr32); checkerboardDeviceBitmap = new DeviceBitmap(checkerboardBitmap); checkerboardDeviceBitmap.IsShareable = true; checkerboardDeviceBitmap.Freeze(); }
public Item(System.Drawing.Image image, string name, bool selected) { this.image = image; this.name = name; this.selected = selected; if (image != null) { Surface cleanupObject = Surface.CopyFromGdipImage(this.image); using (BitmapProxy proxy = new BitmapProxy(cleanupObject.CreateAliasedImagingBitmap(), ObjectRefProxyOptions.AssumeOwnership)) { proxy.AddCleanupObject(cleanupObject); this.deviceImage = new DeviceBitmap(proxy); } } }
static PixelGridCanvasLayer() { ColorBgra white = ColorBgra.White; ColorBgra black = ColorBgra.Black; for (int i = 0; i < stippleSurface.Height; i++) { for (int j = 0; j < stippleSurface.Width; j++) { stippleSurface[j, i] = (((j + i) & 1) == 0) ? white : black; } } stippleBitmap = stippleSurface.CreateAliasedImagingBitmap(PixelFormats.Pbgra32); stippleDeviceBitmap = new DeviceBitmap(stippleBitmap); stippleDeviceBitmap.Freeze(); }