Exemplo n.º 1
0
        public static BitmapTexture FromBitmap(System.Drawing.Bitmap bitmap, int xOffset, int yOffset)
        {
            var texture = new BitmapTexture()
            {
                _bitmap  = bitmap,
                _xOffset = xOffset,
                _yOffset = yOffset
            };

            return(texture);
        }
Exemplo n.º 2
0
        public static List <BitmapTexture[, ]> FromBitmap(System.Drawing.Bitmap bitmap, bool includeScroll = false)
        {
            int offsetScroll = includeScroll ? 0 : 1;

            var frames = new List <BitmapTexture[, ]>();

            for (int xFramePixel = 0; xFramePixel < bitmap.Width; xFramePixel += FramePixelWidth)
            {
                var bitmapTextures = new BitmapTexture[Frame.Height, Frame.Width];

                foreach (var vec3 in ArrayUtility.ForEach(Frame.Height - offsetScroll, Frame.Width - offsetScroll))
                {
                    var xPixelOffset = xFramePixel + (vec3.x * BitmapTexture.WidthPx);
                    var yPixelOffset = (vec3.y * BitmapTexture.WidthPx);

                    bitmapTextures[vec3.y, vec3.x] = BitmapTexture.FromBitmap(bitmap, xPixelOffset, yPixelOffset);
                }

                frames.Add(bitmapTextures);
            }

            return(frames);
        }