示例#1
0
        /// <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++;
                    }
                }
            }
        }
示例#2
0
        /// <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);
        }
示例#3
0
        public void ApplyDirtyRegion(Bound2di box)
        {
            INativeObject nobj   = this.As <INativeObject>();
            IntPtr        argPtr = new IntPtr(&box);
            IntPtr        retVal = IntPtr.Zero;

            nobj.InvokeFunction("ApplyDirtyRegion", argPtr, out retVal);
            Dirty = true;
        }
示例#4
0
        /// <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; }
示例#5
0
 /// <summary>
 /// Construct TerrainOp with the give target and bound</summary>
 public TerrainOp(ITerrainSurface target, Bound2di bound)
 {
     m_target = target;
     m_bound  = bound;
     Perform();
 }