Пример #1
0
        public override void MergeInto(uint x, uint y, OneBppBitmap sourceBitmap, MergeMode mergeMode)
        {
            if (sourceBitmap.ByteDirection != ByteDirectionSpec.TopToBottomLsbFirst ||
                sourceBitmap.ByteDirection != ByteDirectionSpec.TopToBottomMsbFirst)
            {
                throw new NotImplementedException("MergeInto with different ByteDirections in not implemented yet");
            }

            var from      = sourceBitmap as OneBppBitmapWithPages;
            var fromWidth = x + from.Width < this.Width
                                ? from.Width
                                : from.Width - (this.Width - (x + from.Width));

            var yPage = y / 8;
            var yBits = y % 8;

            if (yBits != 0)
            {
                throw new NotImplementedException("MergeInto with y not on byte boundry not implemented yet");
            }

            bool flipByte = this.ByteDirection != from.ByteDirection;

            for (int yByte = 0; yByte < from.HeightInBytes; yByte++)
            {
                if (yPage + yByte < this.HeightInBytes)
                {
                    var destinationMemory = this.Buffer.Slice(( int )(this.Width * (yPage + yByte)), ( int )this.Width);
                    var sourceMemory      = from.Buffer.Slice(( int )(from.Width * yByte), ( int )fromWidth);

                    OneBppBitmapWithPages.MergeInto(sourceMemory, destinationMemory, mergeMode);
                }
            }
        }
Пример #2
0
        public static OneBppBitmap FromBitmap(uint width, uint height, OneBppBitmap bitmap)
        {
            OneBppBitmap result = null;

            switch (bitmap.ByteDirection)
            {
            case ByteDirectionSpec.LeftToRightLsbFirst:
            case ByteDirectionSpec.LeftToRightMsbFirst:
                throw new NotImplementedException();

            case ByteDirectionSpec.TopToBottomLsbFirst:
                result = new OneBppBitmapWithPages(width, height, false);
                result.ByteDirection = bitmap.ByteDirection;
                break;

            case ByteDirectionSpec.TopToBottomMsbFirst:
                result = new OneBppBitmapWithPages(width, height, true);
                result.ByteDirection = bitmap.ByteDirection;
                break;
            }

            return(result);
        }