swing - Draw a portion of a rotated image in Java -


i trying draw portion of circular game board. board rotates, i'd keep constant viewport. plan create bufferedimage of full board, rotate it, draw centered portion graphics paint method. however, graphics not have rotate, , graphics2d not have way draw portion of image.

any thoughts?

"graphics2d not have way draw portion of image."

that's not true. graphics2d inherits graphics this method. allows drawing portions of image. see example usage here

public abstract boolean drawimage(image img,                               int dx1,                               int dy1,                               int dx2,                               int dy2,                               int sx1,                               int sy1,                               int sx2,                               int sy2,                               imageobserver observer) 

draws of specified area of specified image available, scaling on fly fit inside specified area of destination drawable surface. transparent pixels not affect whatever pixels there.

parameters:

  • img - specified image drawn. method nothing if img null.
  • dx1 - x coordinate of first corner of destination rectangle.
  • dy1 - y coordinate of first corner of destination rectangle.
  • dx2 - x coordinate of second corner of destination rectangle.
  • dy2 - y coordinate of second corner of destination rectangle.
  • sx1 - x coordinate of first corner of source rectangle.
  • sy1 - y coordinate of first corner of source rectangle.
  • sx2 - x coordinate of second corner of source rectangle.
  • sy2 - y coordinate of second corner of source rectangle.
  • observer - object notified more of image scaled , converted.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -