Beispiel #1
0
        /// <summary>
        /// Initializes a new instance for the given FreeImage bitmap.
        /// </summary>
        /// <param name="dib">Handle to a FreeImage bitmap.</param>
        /// <exception cref="ArgumentNullException"><paramref name="dib" /> is null.</exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="dib" /> is not
        /// <see cref="FREE_IMAGE_TYPE.FIT_BITMAP" />
        /// <para />
        /// -or-
        /// <para />
        /// <paramref name="dib" /> has more than 8bpp.
        /// </exception>
        public Palette(FIBITMAP dib)
            : base(FreeImage.GetPalette(dib), (int)FreeImage.GetColorsUsed(dib))
        {
            if (dib.IsNull)
            {
                throw new ArgumentNullException("dib");
            }

            if (FreeImage.GetImageType(dib) != FREE_IMAGE_TYPE.FIT_BITMAP)
            {
                throw new ArgumentException("dib");
            }

            if (FreeImage.GetBPP(dib) > 8u)
            {
                throw new ArgumentException("dib");
            }
        }