섞는 거
n = 0;
for (int y = height - 1; y >= 0; y--)
{
for (int x = 0; x < width; x++)
{
srand(n++);
int index = (x * PIXEL_SIZE) + (y * (width * PIXEL_SIZE)) + (padding * y);
int x2 = rand() % width;
int y2 = rand() % height;
int index2 = (x2 * PIXEL_SIZE) + (y2 * (width * PIXEL_SIZE)) + (padding * y2);
RGBTRIPLE* temp = (RGBTRIPLE*)&image[index];
*(RGBTRIPLE*)&image[index] = *(RGBTRIPLE*)&image[index2];
*(RGBTRIPLE*)&image[index2] = *temp;
}
}
복구하는 거
n = height * width - 1;
for (int y = 0; y < height; y++)
{
for (int x = width - 1; x >= 0; x--)
{
srand(n--);
int index = (x * PIXEL_SIZE) + (y * (width * PIXEL_SIZE)) + (padding * y);
int x2 = rand() % width;
int y2 = rand() % height;
int index2 = (x2 * PIXEL_SIZE) + (y2 * (width * PIXEL_SIZE)) + (padding * y2);
RGBTRIPLE* temp = (RGBTRIPLE*)&image[index2];
*(RGBTRIPLE*)&image[index2] = *(RGBTRIPLE*)&image[index];
*(RGBTRIPLE*)&image[index] = *temp;
}
}
픽셀 섞었다가 다시 원래대로 돌리는 건데 결과가 어물쩡 함
원래 이미지
뒤섞은 이미지
복구한 이미지?
뭐지?
느낌있네 - dc App