Example #1
0
        public GMBackground(GMAssets _a, Stream _s)
        {
            switch (_s.ReadInteger())
            {
            case 543:
                Width       = _s.ReadInteger();
                Height      = _s.ReadInteger();
                Transparent = _s.ReadBoolean();
                Smooth      = _s.ReadBoolean();
                Preload     = _s.ReadBoolean();
                Tileset     = false;
                if (_s.ReadBoolean())
                {
                    Bitmap = new GMBitmap32(_s);
                }
                break;

            case 710:
                Bitmap = new GMBitmap32(_s);
                Width  = _s.ReadInteger();
                Height = _s.ReadInteger();
                Width  = Bitmap.Width;
                Height = Bitmap.Height;
                break;
            }
        }
Example #2
0
        public void SetAlphaFromBitmap(GMBitmap32 _other)
        {
            int num  = Math.Min(Width, _other.Width);
            int num2 = Math.Min(Height, _other.Height);

            for (int i = 0; i < num2; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    int num3 = j * 4 + i * _other.Width * 4;
                    int num4 = j * 4 + i * Width * 4;
                    int val  = (_other.Data[num4] + _other.Data[num4 + 1] + _other.Data[num4 + 2]) / 3;
                    Data[num3 + 3] = (byte)Math.Min(_other.Data[num4 + 3], val);
                }
            }
        }
Example #3
0
        protected void CopyBits(BitmapData _data, int _x, int _y, GMBitmap32 _bmp)
        {
            IntPtr intPtr = new IntPtr(_data.Scan0.ToInt64() + _y * _data.Stride + _x * 4);
            int    num    = 0;
            int    num2   = 0;

            while (num2 < _bmp.Height)
            {
                int    num3 = num;
                IntPtr ptr  = intPtr;
                int    num4 = 0;
                while (num4 < _bmp.Width)
                {
                    int val = _bmp.Data[num3] + (_bmp.Data[num3 + 1] << 8) + (_bmp.Data[num3 + 2] << 16) + ((0xFF | _bmp.Data[num3 + 3]) << 24);
                    Marshal.WriteInt32(ptr, val);
                    num4++;
                    num3 += 4;
                    ptr   = new IntPtr(ptr.ToInt64() + 4);
                }
                num2++;
                intPtr = new IntPtr(intPtr.ToInt64() + _data.Stride);
                num   += _bmp.Width * 4;
            }
        }
Example #4
0
        public GMSprite(GMAssets _a, Stream _s)
        {
            int num = _s.ReadInteger();

            switch (num)
            {
            case 542:
            {
                Width       = _s.ReadInteger();
                Height      = _s.ReadInteger();
                BBoxLeft    = _s.ReadInteger();
                BBoxRight   = _s.ReadInteger();
                BBoxBottom  = _s.ReadInteger();
                BBoxTop     = _s.ReadInteger();
                Transparent = _s.ReadBoolean();
                Smooth      = _s.ReadBoolean();
                Preload     = _s.ReadBoolean();
                BBoxMode    = _s.ReadInteger();
                ColCheck    = _s.ReadBoolean();
                XOrig       = _s.ReadInteger();
                YOrig       = _s.ReadInteger();
                Images      = new List <GMBitmap32>();
                int num3 = _s.ReadInteger();
                for (int k = 0; k < num3; k++)
                {
                    Images.Add(new GMBitmap32(_s));
                }
                Masks = CreateMask();
                break;
            }

            case 800:
            case 810:
            {
                BBoxLeft    = 99999999;
                BBoxTop     = 9999999;
                BBoxRight   = -9999999;
                BBoxBottom  = -9999999;
                Transparent = true;
                Preload     = true;
                ColCheck    = true;
                XOrig       = _s.ReadInteger();
                YOrig       = _s.ReadInteger();
                Images      = new List <GMBitmap32>();
                int num2 = _s.ReadInteger();
                for (int i = 0; i < num2; i++)
                {
                    GMBitmap32 gMBitmap = new GMBitmap32(_s);
                    Images.Add(gMBitmap);
                    Width  = gMBitmap.Width;
                    Height = gMBitmap.Height;
                }
                if (num == 810)
                {
                    switch (_s.ReadInteger())
                    {
                    case 0:
                    case 2:
                    case 3:
                        ColCheck = true;
                        break;

                    case 1:
                        ColCheck = false;
                        break;
                    }
                }
                Masks    = new List <byte[]>();
                SepMasks = _s.ReadBoolean();
                if (num2 <= 0)
                {
                    break;
                }
                if (SepMasks)
                {
                    for (int j = 0; j < num2; j++)
                    {
                        Masks.Add(LoadMaskFromStream(_s));
                    }
                }
                else
                {
                    Masks.Add(LoadMaskFromStream(_s));
                }
                break;
            }
            }
        }