コード例 #1
0
ファイル: TerrainBrush.cs プロジェクト: JanDeHud/LevelEditor
        /// <summary>
        /// Computes brush bound in imgdata space.</summary>        
        protected void ComputeBound(ImageData imgData,
                    int x,
                    int y,                    
                    out Bound2di outRect)
        {
            outRect.x1 = 0;
            outRect.x2 = 0;
            outRect.y1 = 0;
            outRect.y2 = 0;

            bool valid = imgData != null && imgData.IsValid;
            System.Diagnostics.Debug.Assert(valid);
            if (!valid) return;


            Bound2di kernelRect;

            kernelRect.x1 = x - Radius;
            kernelRect.y1 = y - Radius;
            kernelRect.x2 = x + Radius + 1;
            kernelRect.y2 = y + Radius + 1;

            Bound2di destRect;
            destRect.x1 = 0;
            destRect.y1 = 0;
            destRect.x2 = imgData.Width;
            destRect.y2 = imgData.Height;
            Bound2di.Intersect(kernelRect, destRect, out outRect);
        }         
コード例 #2
0
ファイル: LayerMap.cs プロジェクト: arsaccol/LevelEditor
 public void ApplyDirtyRegion(Bound2di box)
 {
     unsafe
     {
         INativeObject nobj = this.As<INativeObject>();
         IntPtr argPtr = new IntPtr(&box);
         IntPtr retVal = IntPtr.Zero;
         nobj.InvokeFunction("ApplyDirtyRegion", argPtr, out retVal);
         Dirty = true;
     }
 }
コード例 #3
0
ファイル: Bound2di.cs プロジェクト: ldh9451/XLE
        public static bool Intersect(Bound2di r1, Bound2di r2, out Bound2di rout)
        {
            // early reject.
            if (r1.x2 <= r2.x1
                || r1.x1 >= r2.x2
                || r1.y1 >= r2.y2
                || r1.y2 <= r2.y1)
            {
                rout.x1 = 0;
                rout.x2 = 0;
                rout.y1 = 0;
                rout.y2 = 0;
                return false;
            }

            // find intersection rect.
            rout.x1 = Math.Max(r1.x1, r2.x1);
            rout.x2 = Math.Min(r1.x2, r2.x2);
            rout.y1 = Math.Max(r1.y1, r2.y1);
            rout.y2 = Math.Min(r1.y2, r2.y2);
            return true;
        }
コード例 #4
0
        public static bool Intersect(Bound2di r1, Bound2di r2, out Bound2di rout)
        {
            // early reject.
            if (r1.x2 <= r2.x1 ||
                r1.x1 >= r2.x2 ||
                r1.y1 >= r2.y2 ||
                r1.y2 <= r2.y1)
            {
                rout.x1 = 0;
                rout.x2 = 0;
                rout.y1 = 0;
                rout.y2 = 0;
                return(false);
            }

            // find intersection rect.
            rout.x1 = Math.Max(r1.x1, r2.x1);
            rout.x2 = Math.Min(r1.x2, r2.x2);
            rout.y1 = Math.Max(r1.y1, r2.y1);
            rout.y2 = Math.Min(r1.y2, r2.y2);
            return(true);
        }
コード例 #5
0
ファイル: ImageData.cs プロジェクト: arsaccol/LevelEditor
        /// <summary>
        /// Copy region to outData</summary>
        /// <param name="bound">The region to be copied</param>
        /// <param name="outData">copy to outData</param>
        public void CopyRegion(Bound2di bound, byte[] outData)
        {
            int dataSize = bound.Width * bound.Height * BytesPerPixel;
            bool valid = bound.isValid
                && bound.x1 >= 0
                && bound.x2 <= Width
                && bound.y1 >= 0
                && bound.y2 <= Height
                && outData != null
                && outData.Length == dataSize;
            Debug.Assert(valid);
            if (!valid) return;

            int rowPitch = bound.Width * BytesPerPixel;
            fixed (byte* dest = outData)
            {
                byte* ds = dest;
                for (int cy = bound.y1; cy < bound.y2; cy++)
                {
                    byte* scrPtr = GetPixel(bound.x1, cy);
                    for (int i = 0; i < rowPitch; i++)
                        *ds++ = *scrPtr++;
                }
            }
        }
コード例 #6
0
ファイル: ImageData.cs プロジェクト: arsaccol/LevelEditor
        /// <summary>
        /// Apply the data to the given bound</summary>
        /// <param name="bound"></param>
        /// <param name="data">data to be applied</param>
        public void ApplyRegion(Bound2di bound, byte[] data)
        {
            int dataSize = bound.Width * bound.Height * BytesPerPixel;
            bool valid = bound.isValid
                && bound.x1 >= 0
                && bound.x2 <= Width
                && bound.y1 >= 0
                && bound.y2 <= Height
                && data != null
                && data.Length == dataSize;
            Debug.Assert(valid);
            if (!valid) return;

            // restore 
            int rowPitch = bound.Width * BytesPerPixel;
            fixed (byte* srcptr = data)
            {
                byte* src = srcptr;
                for (int cy = bound.y1; cy < bound.y2; cy++)
                {
                    byte* destPtr = GetPixel(bound.x1, cy);
                    for (int i = 0; i < rowPitch; i++)
                        *destPtr++ = *src++;
                }
            }

        }
コード例 #7
0
ファイル: TerrainBrush.cs プロジェクト: JanDeHud/LevelEditor
 /// <summary>
 /// Construct TerrainOp with the give target and bound</summary>        
 public TerrainOp(ITerrainSurface target, Bound2di bound)
 {
     m_target = target;
     m_bound = bound;
     Perform();
 }