This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Problem with image being cropped and/or not being resized (both) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with image being cropped and/or not being resized (both)" Watch "Problem with image being cropped and/or not being resized (both)" New topic
Author

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

M Ramirez
Greenhorn

Joined: Dec 29, 2013
Posts: 2
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

Joined: Aug 07, 2007
Posts: 2300
    
  49
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

Joined: Aug 07, 2007
Posts: 2300
    
  49
And Welcome to the Ranch.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2191
    
    7
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.
 
GeeCON Prague 2014
 
subject: Problem with image being cropped and/or not being resized (both)