Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
PlatformGraphics: Add missing DirectGraphics transform modes
Browse files Browse the repository at this point in the history
This commit is largely based on digitalgust@ad30ad7

Only with some minor adjustments

Co-Authored-by: digitalgust
  • Loading branch information
AShiningRay committed Nov 23, 2023
1 parent 5758a3d commit e23f8dd
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions src/org/recompile/mobile/PlatformGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -642,26 +642,49 @@ private short colorToShortPixel(int c, int format)

private BufferedImage manipulateImage(BufferedImage image, int manipulation)
{
/*
* Both DirectGraphics and Sprite's rotations are counter-clockwise, flipping
* an image vertically or horizontally is done by multiplying its height or width scale
* by -1 respectively.
*/
final int HV = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.FLIP_VERTICAL;
final int H90 = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.ROTATE_90;
final int HV90 = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.FLIP_VERTICAL | DirectGraphics.ROTATE_90;
final int HV180 = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.FLIP_VERTICAL | DirectGraphics.ROTATE_180;
final int HV270 = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.FLIP_VERTICAL | DirectGraphics.ROTATE_270;
final int H90 = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.ROTATE_90;
final int H180 = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.ROTATE_180;
final int H270 = DirectGraphics.FLIP_HORIZONTAL | DirectGraphics.ROTATE_270;
final int V90 = DirectGraphics.FLIP_VERTICAL | DirectGraphics.ROTATE_90;
final int V180 = DirectGraphics.FLIP_VERTICAL | DirectGraphics.ROTATE_180;
final int V270 = DirectGraphics.FLIP_VERTICAL | DirectGraphics.ROTATE_270;
switch(manipulation)
{
case DirectGraphics.FLIP_HORIZONTAL:
return PlatformImage.transformImage(image, Sprite.TRANS_MIRROR);
case DirectGraphics.FLIP_VERTICAL:
return PlatformImage.transformImage(image, Sprite.TRANS_MIRROR_ROT180);
case DirectGraphics.ROTATE_90:
return PlatformImage.transformImage(image, Sprite.TRANS_ROT270);
case DirectGraphics.ROTATE_180:
return PlatformImage.transformImage(image, Sprite.TRANS_ROT180);
case DirectGraphics.ROTATE_270:
return PlatformImage.transformImage(image, Sprite.TRANS_ROT90);
case V180:
case DirectGraphics.FLIP_HORIZONTAL:
return PlatformImage.transformImage(image, Sprite.TRANS_MIRROR);
case H180:
case DirectGraphics.FLIP_VERTICAL:
return PlatformImage.transformImage(image, Sprite.TRANS_MIRROR_ROT180);
case HV270:
case DirectGraphics.ROTATE_90:
return PlatformImage.transformImage(image, Sprite.TRANS_ROT270);
case HV:
return PlatformImage.transformImage(image, Sprite.TRANS_ROT180);
case H90:
return PlatformImage.transformImage(PlatformImage.transformImage(image, Sprite.TRANS_MIRROR), Sprite.TRANS_ROT270);
case 0: /* No Manipulation */ break;
default:
case DirectGraphics.ROTATE_180:
return PlatformImage.transformImage(image, Sprite.TRANS_ROT180);
case HV90:
case DirectGraphics.ROTATE_270:
return PlatformImage.transformImage(image, Sprite.TRANS_ROT90);
case V270:
case H90:
//return PlatformImage.transformImage(PlatformImage.transformImage(image, Sprite.TRANS_MIRROR), Sprite.TRANS_ROT270);
return PlatformImage.transformImage(image, Sprite.TRANS_MIRROR_ROT270);
case V90:
case H270:
return PlatformImage.transformImage(image, Sprite.TRANS_MIRROR_ROT90);
case 0: /* No Manipulation */
case HV180:
break;
default:
System.out.println("manipulateImage "+manipulation+" not defined");
}
return image;
Expand Down

0 comments on commit e23f8dd

Please sign in to comment.