当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Need help on flippingHorizontal assignment

问题描述:

I am trying to flip a square image inside a picture with user input variables. After running the code nothing happens at all. In other attempts I was able to make a small thin rectangle appear. How do I fix this?

 public void flipHorizontal (int x, int y, int size)

{

int half = size / 2;

int x1 = x - half;

int y1 = y - half;

int x2 = x + half;

int y2 = y + half;

Pixel sourcePixel = getPixel (x1,y1);

Pixel targetPixel = getPixel (x1, y1 + half);

//loop through columns

for (x = x; x < x2; x++)

{

//loop from 0 to before mirror point

for (y = y; y < y2 + half; y++)

{

Color friend = sourcePixel.getColor();

sourcePixel = getPixel (x1,y1);

targetPixel = getPixel (x1, y1 + half);

targetPixel.setColor (friend);

}

}

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: