Exemplo n.º 1
0
        public static byte[] /*****/ HC_CropImage(byte[] rawInput, int imageW, int imageH, int ptX, int ptY, int cropW, int cropH)
        {
            byte[] rawCrop = new byte[cropW * cropH];

            if (CRect.IsIntersectRect(new RectangleF(0, 0, imageW, imageH), new RectangleF(ptX, ptY, cropW, cropH)) == true)
            {
                for (int y = ptY, copyLine = 0; y < ptY + cropH; y++)
                {
                    Buffer.BlockCopy(rawInput, y * imageW + ptX, rawCrop, cropW * copyLine++, cropW);
                }
            }

            return(rawCrop);
        }
Exemplo n.º 2
0
        public static byte[] /*****/ HC_CropImage(byte[] rawInput, int imageW, int imageH, RectangleF rc)
        {
            int nLength  = (int)rc.Width * (int)rc.Height;
            int toHeight = (int)rc.Y + (int)rc.Height;
            int toWidth  = (int)rc.Width;
            int px       = (int)rc.X;

            byte[] rawCrop = new byte[nLength];

            if (CRect.IsIntersectRect(new RectangleF(0, 0, imageW, imageH), rc) == true)
            {
                for (int y = (int)rc.Y, copyLine = 0; y < toHeight; y++)
                {
                    Buffer.BlockCopy(rawInput, y * imageW + px, rawCrop, toWidth * copyLine++, toWidth);
                }
            }
            return(rawCrop);
        }
Exemplo n.º 3
0
        public static byte[] /*****/ HC_CropImage_Center(byte[] rawInput, int imageW, int imageH, RectangleF rc, PointF ptCenter)
        {
            PointF ptDist = CPoint.GetDistancePoint(CRect.GetCenter(rc), ptCenter);

            rc.Offset(ptDist);

            int nLength  = (int)rc.Width * (int)rc.Height;
            int toHeight = (int)rc.Y + (int)rc.Height;
            int toWidth  = (int)rc.Width;
            int px       = (int)rc.X;

            byte[] rawCrop = new byte[nLength];

            if (CRect.IsIntersectRect(new RectangleF(0, 0, imageW, imageH), rc) == true)
            {
                for (int y = (int)rc.Y, copyLine = 0; y < toHeight; y++)
                {
                    Buffer.BlockCopy(rawInput, y * imageW + px, rawCrop, toWidth * copyLine++, toWidth);
                }
            }
            return(rawCrop);
        }