Ejemplo n.º 1
0
        [return : NotNullIfNotNull("images")] public static Icon?Combine(Bitmap[]?images, Color[]?transparentColors, bool forceUncompressedResult)
        {
            int imageCount = images?.Length ?? 0;

            int colorCount = transparentColors?.Length ?? 0;

            if (imageCount != colorCount)
            {
                throw new ArgumentException(Res.IconExtensionsImagesColorsDifferentLength);
            }

            if (images == null || transparentColors == null || imageCount == 0)
            {
                return(null);
            }

            using (var rawIcon = new RawIcon())
            {
                for (int i = 0; i < imageCount; i++)
                {
                    rawIcon.Add(images[i], transparentColors[i]);
                }

                return(rawIcon.ToIcon(forceUncompressedResult) !);
            }
        }
Ejemplo n.º 2
0
        [SecurityCritical] // GetHicon
        private static Icon FromBitmap(Bitmap bmp)
        {
            if (OSUtils.IsWindows)
            {
                return(Icon.FromHandle(bmp.GetHicon()).ToManagedIcon());
            }

            using (var rawIcon = new RawIcon())
            {
                rawIcon.Add(bmp);
                return(rawIcon.ToIcon(true) !);
            }
        }
Ejemplo n.º 3
0
        [return : NotNullIfNotNull("images")] public static Icon?Combine(bool forceUncompressedResult, IEnumerable <Bitmap>?images)
        {
            if (images == null)
            {
                return(null);
            }

            using (var rawIcon = new RawIcon())
            {
                foreach (Bitmap image in images)
                {
                    rawIcon.Add(image);
                }

                return(rawIcon.ToIcon(forceUncompressedResult) !);
            }
        }
Ejemplo n.º 4
0
        [return : NotNullIfNotNull("icons")] public static Icon?Combine(bool forceUncompressedResult, IEnumerable <Icon>?icons)
        {
            if (icons == null)
            {
                return(null);
            }

            using (var rawIcon = new RawIcon())
            {
                foreach (Icon icon in icons)
                {
                    rawIcon.Add(icon);
                }

                return(rawIcon.ToIcon(forceUncompressedResult) !);
            }
        }
Ejemplo n.º 5
0
        public static Icon Combine(bool forceUncompressedResult, IEnumerable <Bitmap> images)
        {
            if (images == null)
            {
                return(null);
            }

            using (RawIcon rawIcon = new RawIcon())
            {
                foreach (Bitmap image in images)
                {
                    rawIcon.Add(image);
                }

                return(rawIcon.ToIcon(forceUncompressedResult));
            }
        }
Ejemplo n.º 6
0
        public static Icon Combine(bool forceUncompressedResult, IEnumerable <Icon> icons)
        {
            if (icons == null)
            {
                return(null);
            }

            using (RawIcon rawIcon = new RawIcon())
            {
                foreach (Icon icon in icons)
                {
                    rawIcon.Add(icon);
                }

                return(rawIcon.ToIcon(forceUncompressedResult));
            }
        }
Ejemplo n.º 7
0
 public static Icon?FromStream(Stream stream, bool forceUncompressedResult)
 {
     using (var rawIcon = new RawIcon(stream))
         return(rawIcon.ToIcon(forceUncompressedResult));
 }