Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with image being cropped and/or not being resized (both)

 
M Ramirez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i've been trying for over a day to solve this issue and i'm about to cry lol (ok maybe not that dramatic but close enough).

I'm trying to rotate an image but everytime i try no matter the method or it either truncates or it doesn't resize.

This is what i'm doing in general:

i have an image wich is (let say) 150 x 300 then when i draw it i resize to about 55% of its original size.

but on double click i have to rotate it 90 degrees (goes back and forth to 90 degrees, -horizontal and vertical position-)

and i have tried 2 methods but i get undesired behavior:

this is one:

cardImage is the original full-sized card.
flippedCardImage is where i store the flipped version of cardImage.



with that code i get the image but it is shrinked.

and with this:


with that when i draw it it draws like if i cropped the 55% sized rectangle off the full sized image and draw that instead of resize it.

how do i do rotate and resize it properly can someone please help me? T_T
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the Java Tutorial on transforming images? see http://docs.oracle.com/javase/tutorial/2d/advanced/transforming.html.
You could also look at this thread http://www.coderanch.com/t/485958/GUI/java/Rotating-buffered-image
 
Tony Docherty
Bartender
Posts: 2957
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Welcome to the Ranch.
 
Rob Camick
Ranch Hand
Posts: 2580
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE that demonstrates the problem.

The first example looks reasonable, but I don't know the context of how you invoke the and use the resulting image.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic