Modify Program 29 in this chapter to take the source picture to rotate and to create a new picture of just the needed size. Return the new picture.

What will be an ideal response?

```
public P i c t u r e r o t a t e L e f t ( )
{
P i c t u r e t a r g e t = new P i c t u r e ( t h i s . g e t H e i g h t ( ) ,
t h i s . getWidth ( ) ) ;
P i x e l s o u r c e P i x e l = n u l l ; P i x e l t a r g e t P i x e l = n u l l ;

// l o o p t h r o u g h t h e columns
f o r ( i n t so urc e X = 0 ;
so urc e X < t h i s . getWidth ( ) ; so urc e X++)
{
// l o o p t h r o u g h t h e rows
f o r ( i n t so urc e Y = 0 ;
so urc e Y < t h i s . g e t H e i g h t ( ) ; so urc e Y++)
{
// s e t t h e t a r g e t p i x e l c o l o r t o t h e s o u r c e p i x e l c o l o r s o u r c e P i x e l = t h i s . g e t P i x e l ( sourceX , so urc e Y ) ; t a r g e t P i x e l = t a r g e t . g e t P i x e l ( sourceY ,
t h i s . getWidth ( ) ? 1 ? so urc e X ) ; t a r g e t P i x e l . s e t C o l o r ( s o u r c e P i x e l . g e t C o l o r ( ) ) ;
}
}
return t a r g e t ;
}
```

Computer Science & Information Technology

You might also like to view...

Captions for images and tables can be automatically generated in Word 2010

Indicate whether the statement is true or false

Computer Science & Information Technology

Users usually need at least a basic understanding of a computer's operation before they can become skills users of technology.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology