Results 1 to 2 of 2
- 02-22-2012, 01:58 AM #1
Graphics2D.drawImage(...) always blits from top left?
I'm using Graphics2D to copy a portion of an image onto itself. This works fine when the source rectangle and the target rectangle do not overlap, or when applying a transform with a negative Y translation. But if the rectangles overlap and the Y translation is positive, then a portion of the source image is copied repeatedly. It seems that drawImage(...) always blits from the top left to the bottom right. This remains true even if I use the drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) version and reverse the coordinates.
My solution was to test for overlapping negative translations and copy to a temp image and then back to the main image. But I'm just wondering if there's something I'm missing, some obscure trick to make drawImage(...) blit from the bottom right to the top left.Get in the habit of using standard Java naming conventions!
- 02-22-2012, 09:48 AM #2
Re: Graphics2D.drawImage(...) always blits from top left?My solution was to test for overlapping negative translations and copy to a temp image and then back to the main image.
IMO any code to reverse the blit would (1) be cumbersome to maintain, being so to speak contra-instinctive for the average 2D programmer but more important (2) wouldn't you just be transferring the same problem to the top left corner?
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- By Jaeela in forum New To JavaReplies: 5Last Post: 10-05-2011, 02:36 AM
- By mrhid6 in forum AWT / SwingReplies: 2Last Post: 10-01-2011, 11:58 PM
- By pseudohawtcakes in forum New To JavaReplies: 3Last Post: 05-17-2011, 08:07 PM
- By gurpreet.singh in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 05-05-2011, 01:49 PM
- By natdizzle in forum AWT / SwingReplies: 3Last Post: 02-04-2011, 06:20 PM