Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't this image rotate a code example

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
0
0
GB
public void rotateImage(double theta)
{
System.out.println("********1*******");
imageGraphics.rotate(theta*RADCONVERTOR); //This should be in radians.
System.out.println("********2*******");
myWritableRaster = (WritableRaster)imageInfo.getData();
System.out.println("********3*******");
int transferType = myWritableRaster.getTransferType();
int numOfElements = myWritableRaster.getNumDataElements();
System.out.println("********4*******");
height = imageInfo.getHeight();
width = imageInfo.getWidth();
System.out.println("********5*******");
imageArray = new byte[width*height*numOfElements];
System.out.println("********6*******");
myWritableRaster.getDataElements(0,0, width, height, imageArray);
System.out.println("********7*******");
changeArrayToTwo();
System.out.println("********8*******");
threshold();
}

A buffered image has been drawn onto the imageGraphics object previously.

It compiles it runs but it doesn't rotate the image.

Thanks if anyone reads or if anyone can help

Chris
 
you should notice that many objects methods
does not alter the state of the object...
for example look at this example with the BigDecimal
Code:
BigDecimal num1 = new BigDecimal( 1.0 );
System.out.println( num1 ); // the output is 1.0
num1.add( new BigDecimal( 1.0 ) );
System.out.println( num1 ); // the output is 1.0 again
                       // and we expected 2.0
The reason is that the add method what really does is
to return a BigDecimal value that is the result of adding
the paremeter to the object, but does not alter the object!!
The right code would be...
Code:
BigDecimal num1 = new BigDecimal( 1.0 );
System.out.println( num1 ); // the output is 1.0
num1 = num1.add( new BigDecimal( 1.0 ) );
System.out.println( num1 ); // the output is 2.0 
                       // as we expected



 
The rotate method is void so it doesn' return anything.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top