示例#1
0
        /// <summary>
        /// Gets the image.
        /// For uncompressed palette images, this returns the XOR part of the entry.
        /// For 32bit images and compressed images, this returns a bitmap with
        /// alpha transparency.
        /// </summary>
        public Bitmap GetImage()
        {
            Stream data = GetImageData();

            if (IsCompressed || ColorDepth != 32)
            {
                return(new Bitmap(data));
            }
            else
            {
                // new Bitmap() does not work with alpha-transparent .bmp's
                // Therefore, we have to use our own little bitmap loader
                return(AlphaTransparentBitmap.LoadAlphaTransparentBitmap(data));
            }
        }
示例#2
0
 /// <summary>
 /// Exports the image as ARGB bitmap.
 /// Note: if the bitmap is using the classic style (AND/XOR maps), any pixel
 /// where the AND map isn't 0 is set to fully transparent.
 /// </summary>
 public Bitmap ExportArgbBitmap()
 {
     if (colorDepth == 32)
     {
         return(GetImage());
     }
     else if (isCompressed)
     {
         using (Bitmap image = GetImage()) {
             return(image.Clone(new Rectangle(0, 0, width, height), PixelFormat.Format32bppArgb));
         }
     }
     else
     {
         using (Bitmap mask = GetMaskImage(), image = GetImage()) {
             return(AlphaTransparentBitmap.ConvertToAlphaTransparentBitmap(mask, image));
         }
     }
 }