public HImage Process(HImage image)
        {
            var domainWidth  = image.GetDomain().GetWidth();
            var domainHeight = image.GetDomain().GetHeight();

            var finalHeight = Math.Abs(MaskHeight) < 0.000001 ? domainHeight : MaskHeight;
            var finalWidth  = Math.Abs(MaskWidth) < 0.000001 ? domainWidth : MaskWidth;

            return(image.GrayOpeningShape(finalHeight, finalWidth, MaskShape.ToHalconString()));
        }
Esempio n. 2
0
        public static string ToHalconString(this MaskShape maskShape)
        {
            switch (maskShape)
            {
            case MaskShape.Octagon:
                return("octagon");

            case MaskShape.Rectangle:
                return("rectangle");

            case MaskShape.Rhombus:
                return("rhombus");

            default:
                throw new InvalidOperationException("MaskShape cannot convert to string: " + maskShape);
            }
        }
Esempio n. 3
0
        public GMSprite(BinaryReader binaryReader, GMWAD w)
        {
            Name        = new GMString(binaryReader);
            Width       = binaryReader.ReadInt32();
            Height      = binaryReader.ReadInt32();
            BBoxLeft    = binaryReader.ReadInt32();
            BBoxRight   = binaryReader.ReadInt32();
            BBoxBottom  = binaryReader.ReadInt32();
            BBoxTop     = binaryReader.ReadInt32();
            Transparent = ReadBool(binaryReader);
            Smooth      = ReadBool(binaryReader);
            Preload     = ReadBool(binaryReader);
            int mode = binaryReader.ReadInt32();

            BBoxMode   = (MaskShape)mode;
            ColCheck   = ReadBool(binaryReader);
            XOrigin    = binaryReader.ReadInt32();
            YOrigin    = binaryReader.ReadInt32();
            ImageCount = binaryReader.ReadInt32();
            if (ImageCount != 0)
            {
                ImageTextures = new List <GMTPAGEntry>(ImageCount);
                for (int img = 0; img < ImageCount; img++)
                {
                    uint addr = binaryReader.ReadUInt32();
                    if (addr != 0)
                    {
                        long prev_addr = binaryReader.BaseStream.Position;
                        binaryReader.BaseStream.Position = addr;
                        var item = new GMTPAGEntry(binaryReader, w);
                        binaryReader.BaseStream.Position = prev_addr;
                        ImageTextures.Add(item);
                    }
                    else
                    {
                        ImageTextures.Add(null);
                    }
                }
            }
            else
            {
                ImageTextures = null;
            }
            MasksCount = binaryReader.ReadInt32();
            if (MasksCount != 0)
            {
                MaskData = new List <byte[]>(MasksCount);
                for (int msk = 0; msk < MasksCount; msk++)
                {
                    int    size = CalculateMaskSize(Width, Height);
                    byte[] data = binaryReader.ReadBytes(size);
                    MaskData.Add(data);
                }
            }
            else
            {
                MaskData = null;
            }

            // this is happening in Karoshi...
            if (ImageCount != MasksCount)
            {
                Output.Print($"Sprite {Name}'s ImageCount and MaskCount do not match. {ImageCount} | {MasksCount}");
            }
        }
Esempio n. 4
0
 public ExitButton()
 {
     Mask.Shape = MaskShape.Rectangle(0, 0, 40, 40);
 }