Beispiel #1
0
 public void DisposeAll()
 {
     if (AvaloniaBitmap != null)
     {
         AvaloniaBitmap.Dispose();
         AvaloniaBitmap = null;
     }
     for (int i = 0; i < SystemBitmaps.Length; ++i)
     {
         if (SystemBitmaps[i] != null)
         {
             SystemBitmaps[i].Dispose();
             SystemBitmaps[i] = null;
         }
     }
 }
Beispiel #2
0
        public static bool EnsureBitmapSize(ref AI.WriteableBitmap avaloniaBitmap, PixelSize size)
        {
            bool invalid = avaloniaBitmap != null && avaloniaBitmap.PixelSize != size;
            bool create  = avaloniaBitmap == null || invalid;

            if (invalid)
            {
                avaloniaBitmap.Dispose();
                avaloniaBitmap = null;
            }
            if (create)
            {
                avaloniaBitmap = new AI.WriteableBitmap(
                    size,
                    new Vector(1, 1),                      // DPI scale ?
                    //Avalonia.Platform.PixelFormat.Rgba8888
                    Avalonia.Platform.PixelFormat.Bgra8888 // seems faster for me! // like System.Drawing.Imaging.PixelFormat.Format32bppArgb
                    );
            }
            return(create);
        }