Exemplo n.º 1
0
		public bool SetClippingBox(int x1, int y1, int x2, int y2)
		{
			RectangleInt cb = new RectangleInt(x1, y1, x2, y2);
			cb.normalize();
			if (cb.clip(new RectangleInt(0, 0, (int)Width - 1, (int)Height - 1)))
			{
				m_ClippingRect = cb;
				return true;
			}
			m_ClippingRect.Left = 1;
			m_ClippingRect.Bottom = 1;
			m_ClippingRect.Right = 0;
			m_ClippingRect.Top = 0;
			return false;
		}
Exemplo n.º 2
0
        public bool SetClippingBox(int x1, int y1, int x2, int y2)
        {
            RectangleInt cb = new RectangleInt(x1, y1, x2, y2);

            cb.normalize();
            if (cb.clip(new RectangleInt(0, 0, (int)Width - 1, (int)Height - 1)))
            {
                m_ClippingRect = cb;
                return(true);
            }
            m_ClippingRect.Left   = 1;
            m_ClippingRect.Bottom = 1;
            m_ClippingRect.Right  = 0;
            m_ClippingRect.Top    = 0;
            return(false);
        }
Exemplo n.º 3
0
        public bool Attach(IImageByte sourceImage, int x1, int y1, int x2, int y2)
        {
            m_ByteBuffer = null;
            DettachBuffer();

            if (x1 > x2 || y1 > y2)
            {
                throw new Exception("You need to have your x1 and y1 be the lower left corner of your sub image.");
            }
            RectangleInt boundsRect = new RectangleInt(x1, y1, x2, y2);

            if (boundsRect.clip(new RectangleInt(0, 0, (int)sourceImage.Width - 1, (int)sourceImage.Height - 1)))
            {
                SetDimmensionAndFormat(boundsRect.Width, boundsRect.Height, sourceImage.StrideInBytes(), sourceImage.BitDepth, sourceImage.GetBytesBetweenPixelsInclusive(), false);
                int    bufferOffset = sourceImage.GetBufferOffsetXY(boundsRect.Left, boundsRect.Bottom);
                byte[] buffer       = sourceImage.GetBuffer();
                SetBuffer(buffer, bufferOffset);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
		public bool Attach(IImageByte sourceImage, int x1, int y1, int x2, int y2)
		{
			m_ByteBuffer = null;
			DettachBuffer();

			if (x1 > x2 || y1 > y2)
			{
				throw new Exception("You need to have your x1 and y1 be the lower left corner of your sub image.");
			}
			RectangleInt boundsRect = new RectangleInt(x1, y1, x2, y2);
			if (boundsRect.clip(new RectangleInt(0, 0, (int)sourceImage.Width - 1, (int)sourceImage.Height - 1)))
			{
				SetDimmensionAndFormat(boundsRect.Width, boundsRect.Height, sourceImage.StrideInBytes(), sourceImage.BitDepth, sourceImage.GetBytesBetweenPixelsInclusive(), false);
				int bufferOffset = sourceImage.GetBufferOffsetXY(boundsRect.Left, boundsRect.Bottom);
				byte[] buffer = sourceImage.GetBuffer();
				SetBuffer(buffer, bufferOffset);
				return true;
			}

			return false;
		}