rotate_and_flip.go 391 B

1234567891011121314151617181920212223
  1. package processing
  2. func rotateAndFlip(ctx *Context) error {
  3. if ctx.Angle%360 == 0 && ctx.PO.Rotate%360 == 0 && !ctx.Flip {
  4. return nil
  5. }
  6. if err := ctx.Img.CopyMemory(); err != nil {
  7. return err
  8. }
  9. if err := ctx.Img.Rotate(ctx.Angle); err != nil {
  10. return err
  11. }
  12. if ctx.Flip {
  13. if err := ctx.Img.Flip(); err != nil {
  14. return err
  15. }
  16. }
  17. return ctx.Img.Rotate(ctx.PO.Rotate)
  18. }