Example #1
0
        /// <summary>
        /// Loads image from a file.
        /// </summary>
        /// <param name="fileName">Name of file with image.</param>
        /// <returns><see cref="CodedImage"/> instance with pixels data initialized from loaded file.</returns>
        protected override CodedImage LoadImageCore(string fileName)
        {
            var bitmap       = new Bitmap(fileName);
            var indexedImage = IndexedImageExtensions.FromBitmap(bitmap);
            var codedImage   = CodedImage.FromIndexedImage(indexedImage);

            return(codedImage);
        }
Example #2
0
        /// <summary>
        /// Creates custom cursor.
        /// </summary>
        /// <param name="cursorType">Cursor type.</param>
        /// <param name="cursorArgb">Cursor color.</param>
        /// <returns>Custom cursor of specified type and color.</returns>
        /// <remarks>Returns Cursors.Default if required resources have not been found.</remarks>
        public static Cursor GetCursor(CursorType cursorType, int cursorArgb)
        {
            var resourceName = GetCursorResourceName(cursorType);

            if (resourceName != null)
            {
                using (var stream = SAEResources.GetRawResourceStream(resourceName))
                {
                    if (stream != null)
                    {
                        var image = IndexedImageExtensions.FromBitmap(new Bitmap(stream));
                        if (image != null)
                        {
                            //ColorCursorImage(image, cursorArgb);
                            return(BitmapToCursor(image.ToBitmap()));
                        }
                    }
                }
            }

            return(Cursors.Default);
        }