Question: //in Picture.java public Picture copyRegionToNew(int xSource, int ySource, int xTarget, int yTarget ) { Picture newCanvas = new Picture(); Pixel sPixel, tPixel = null; for
//in Picture.java
public Picture copyRegionToNew(int xSource, int ySource, int xTarget, int yTarget )
{
Picture newCanvas = new Picture();
Pixel sPixel, tPixel = null;
for (int sX = xSource, tX = xTarget; sX < 100+xSource; sX++, tX++)
{
for (int sY = ySource, tY = yTarget; sY < 100+ySource; sY++, tY++)
{
sPixel = this.getPixel(sX,sY);
tPixel = newCanvas.getPixel(tX,tY);
tPixel.setColor(sPixel.getColor());
}
}
return newCanvas;
}
//in main
Picture fish = new Picture( "fish.jpg" );
fish.copyRegionToNew(10, 30, 50, 50);
newCanvas.show();
----------------------------------------------------------------------------------------------------------------------------------------------------
Describe what this code will do. Describe why.
please, help me! Thanks in advance! (JAVA PROGRAMMING)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
