示例#1
0
        public static unsafe IGraphics FlippedCopy(this IGraphics surface, RendererFlip flipMode)
        {
            var       w      = surface.Width;
            var       h      = surface.Height;
            var       p      = (int *)surface.Pixels;
            var       i      = 0;
            IGraphics result = null;

            if (flipMode == RendererFlip.Horizontal)
            {
                result = surface.ToPen(w, h) as IGraphics;
                var rp = (int *)result.Pixels;
                for (var y = h - 1; y >= 0; y--)
                {
                    for (var x = 0; x < w; x++)
                    {
                        var srcInd = y * w + x;
                        rp[i] = p[srcInd];
                        i++;
                    }
                }
            }
            else if (flipMode == RendererFlip.Vertical)
            {
                result = surface.ToPen(w, h) as IGraphics;
                var rp = (int *)result.Pixels;
                for (var y = 0; y < h; y++)
                {
                    for (var x = w - 1; x >= 0; x--)
                    {
                        var srcInd = y * w + x;
                        rp[i] = p[srcInd];
                        i++;
                    }
                }
            }
            return(result);
        }
示例#2
0
 public static extern int RenderCopyEx(Renderer renderer, Texture texture, Rect *srcrect, Rect *dstrect, double angle, Point *center, RendererFlip flip);
示例#3
0
        /// <summary>
        ///   Use this function to copy a portion of the texture to the current rendering target, optionally
        ///   rotating it by angle around the given center and also flipping it top-bottom and/or left-right.
        /// </summary>
        /// <param name="texture">The source texture.</param>
        /// <param name="srcRect">The source Rect structure or Rect.Zero for the entire texture.</param>
        /// <param name="dstRect">The destination Rect structure or Rect.Zero for the entire rendering target.</param>
        /// <param name="angle">An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction.</param>
        /// <param name="centerPoint">A point indicating the point around which dstrect will be rotated (if Point.Zero, rotation will be done around dstrect.w/2, dstrect.h/2)</param>
        /// <param name="rendererFlip">A SDL_RendererFlip value stating which flipping actions should be performed on the texture.</param>
        public void CopyEx(Texture texture, Rect srcRect, Rect dstRect, double angle, Point?centerPoint = null, RendererFlip rendererFlip = RendererFlip.FlipNone)
        {
            // TODO: Also handle Rect.Null being passed into here
            var src = new SDL.SDL_Rect()
            {
                x = srcRect.X, y = srcRect.Y, w = srcRect.W, h = srcRect.H
            };
            var dst = new SDL.SDL_Rect()
            {
                x = dstRect.X, y = dstRect.Y, w = dstRect.W, h = dstRect.H
            };

            SDL.SDL_RenderCopyEx(_sdlRenderer, texture.SdlTexture, ref src, ref dst, angle, IntPtr.Zero, (SDL.SDL_RendererFlip)rendererFlip);
        }