Skip to content
  • Rate limit · GitHub

    Access has been restricted

    You have triggered a rate limit.

    Please wait a few minutes before you try again;
    in some cases this may take up to an hour.

  • Notifications You must be signed in to change notification settings
  • Fork 854

Using Clip + Flip seems to use the data outside of the clip region, how do I avoid that? #2597

Open
@JimBobSquarePants

Description

Discussed in #2573

Originally posted by Thraka October 26, 2023
I'm trying to flip some sprites contained within a sprite sheet, but it doesn't seem to work as expected. I'm doing these things:

  1. get the path rectangle of where my sprite is located
  2. clip the context to that rectangle
  3. apply a flip to the clip context

It seems that flip is restricted to the clip for the output of the flip operation, but it's using the entire image as the input. How do I restrict flip to use the clip region as the source and target of the operation?

texture.Mutate(context =>
{
    var options = context.Configuration.GetGraphicsOptions();
    options.Antialias = false;
    context.Configuration.SetGraphicsOptions(options);


    // Rectangle from other library I'm using
    var fontGlyphRect = font.GetGlyphSourceRectangle(1);

    // Transform into SixLabors rectangle
    RectangleF rect = new(fontGlyphRect.X, fontGlyphRect.Y, fontGlyphRect.Width, fontGlyphRect.Height);

    // Convert rect to IPath to clip, then flip that clipped area
    context.Clip(new RectangularPolygon(rect), context2 => context2.Flip(FlipMode.Vertical));
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Using Clip + Flip seems to use the data outside of the clip region, how do I avoid that? · Issue #2597 · SixLabors/ImageSharp