Beispiel #1
0
        public RectangleInt GetBoundingRect()
        {
            RectangleInt boundingRect = new RectangleInt(0, 0, Width, Height);

            boundingRect.Offset((int)OriginOffset.x, (int)OriginOffset.y);
            return(boundingRect);
        }
Beispiel #2
0
        public override void Render(IImageByte source,
                                    double x, double y,
                                    double angleRadians,
                                    double scaleX, double scaleY)
        {
#if true
            Affine transform = GetTransform();
            if (!transform.is_identity())
            {
                if (scaleX != 1 || scaleY != 1)                // || angleDegrees != 0)
                {
                    throw new NotImplementedException();
                }
                // TODO: <BUG> make this do rotation and scaling
                transform.transform(ref x, ref y);
                scaleX *= transform.sx;
                scaleY *= transform.sy;
            }
#endif

#if true
            // TODO: <BUG> make this do rotation and scaling
            RectangleInt sourceBounds = source.GetBounds();
            sourceBounds.Offset((int)x, (int)y);
            RectangleInt destBounds = new RectangleInt((int)cachedClipRect.Left, (int)cachedClipRect.Bottom, (int)cachedClipRect.Right, (int)cachedClipRect.Top);

            if (!RectangleInt.DoIntersect(sourceBounds, destBounds))
            {
                if (scaleX != 1 || scaleY != 1)                // || angleDegrees != 0)
                {
                    //throw new NotImplementedException();
                }
                //return;
            }
#endif

            ImageBuffer   sourceAsImageBuffer = (ImageBuffer)source;
            ImageGlPlugin glPlugin            = ImageGlPlugin.GetImageGlPlugin(sourceAsImageBuffer, false);

            // Prepare openGL for rendering
            PushOrthoProjection();
            GL.Disable(EnableCap.Lighting);
            GL.Enable(EnableCap.Texture2D);
            GL.Disable(EnableCap.DepthTest);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.Translate(x, y, 0);
            GL.Rotate(MathHelper.RadiansToDegrees(angleRadians), 0, 0, 1);
            GL.Scale(scaleX, scaleY, 1);

            RGBA_Bytes color = RGBA_Bytes.White;
            GL.Color4((byte)color.Red0To255, (byte)color.Green0To255, (byte)color.Blue0To255, (byte)color.Alpha0To255);

            glPlugin.DrawToGL();

            //Restore openGL state
            PopOrthoProjection();
        }
Beispiel #3
0
        public override void CopyFrom(IImageByte sourceImage,
                                      RectangleInt sourceImageRect,
                                      int destXOffset,
                                      int destYOffset)
        {
            RectangleInt destRect = sourceImageRect;

            destRect.Offset(destXOffset, destYOffset);

            RectangleInt clippedSourceRect = new RectangleInt();

            if (clippedSourceRect.IntersectRectangles(destRect, m_ClippingRect))
            {
                // move it back relative to the source
                clippedSourceRect.Offset(-destXOffset, -destYOffset);

                base.CopyFrom(sourceImage, clippedSourceRect, destXOffset, destYOffset);
            }
        }
Beispiel #4
0
        public void CopyFrom(IImageByte sourceImage, RectangleInt sourceImageRect, int destXOffset, int destYOffset)
        {
            RectangleInt sourceImageBounds      = sourceImage.GetBounds();
            RectangleInt clippedSourceImageRect = new RectangleInt();

            if (clippedSourceImageRect.IntersectRectangles(sourceImageRect, sourceImageBounds))
            {
                RectangleInt destImageRect = clippedSourceImageRect;
                destImageRect.Offset(destXOffset, destYOffset);
                RectangleInt destImageBounds      = GetBounds();
                RectangleInt clippedDestImageRect = new RectangleInt();
                if (clippedDestImageRect.IntersectRectangles(destImageRect, destImageBounds))
                {
                    // we need to make sure the source is also clipped to the dest. So, we'll copy this back to source and offset it.
                    clippedSourceImageRect = clippedDestImageRect;
                    clippedSourceImageRect.Offset(-destXOffset, -destYOffset);
                    CopyFromNoClipping(sourceImage, clippedSourceImageRect, destXOffset, destYOffset);
                }
            }
        }
Beispiel #5
0
		public void CopyFrom(IImageByte sourceImage, RectangleInt sourceImageRect, int destXOffset, int destYOffset)
		{
			RectangleInt sourceImageBounds = sourceImage.GetBounds();
			RectangleInt clippedSourceImageRect = new RectangleInt();
			if (clippedSourceImageRect.IntersectRectangles(sourceImageRect, sourceImageBounds))
			{
				RectangleInt destImageRect = clippedSourceImageRect;
				destImageRect.Offset(destXOffset, destYOffset);
				RectangleInt destImageBounds = GetBounds();
				RectangleInt clippedDestImageRect = new RectangleInt();
				if (clippedDestImageRect.IntersectRectangles(destImageRect, destImageBounds))
				{
					// we need to make sure the source is also clipped to the dest. So, we'll copy this back to source and offset it.
					clippedSourceImageRect = clippedDestImageRect;
					clippedSourceImageRect.Offset(-destXOffset, -destYOffset);
					CopyFromNoClipping(sourceImage, clippedSourceImageRect, destXOffset, destYOffset);
				}
			}
		}
Beispiel #6
0
		public RectangleInt GetBoundingRect()
		{
			RectangleInt boundingRect = new RectangleInt(0, 0, Width, Height);
			boundingRect.Offset((int)OriginOffset.x, (int)OriginOffset.y);
			return boundingRect;
		}
Beispiel #7
0
		public override void CopyFrom(IImageFloat sourceImage,
					   RectangleInt sourceImageRect,
					   int destXOffset,
					   int destYOffset)
		{
			RectangleInt destRect = sourceImageRect;
			destRect.Offset(destXOffset, destYOffset);

			RectangleInt clippedSourceRect = new RectangleInt();
			if (clippedSourceRect.IntersectRectangles(destRect, m_ClippingRect))
			{
				// move it back relative to the source
				clippedSourceRect.Offset(-destXOffset, -destYOffset);

				base.CopyFrom(sourceImage, clippedSourceRect, destXOffset, destYOffset);
			}
		}