Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Shuffle(unsigned char R[WIDTH][HEIGHT], unsigned char G[WIDTH][HEIGHT], unsigned char B[WIDTH][HEIGHT])
- {
- srand (time(NULL));
- int x, y;
- int r_temp, g_temp, b_temp;
- int x_block, y_block;
- int x_temp, y_temp;
- for (y = 0; y < (HEIGHT/SHUFF_HEIGHT_DIV - 1); y++)
- {
- for (x = 0; x < (WIDTH/SHUFF_WIDTH_DIV - 1); x++)
- {
- if ((x == 0) && (y == 0))
- {
- x_block = (rand () % 4) + 1;
- y_block = (rand () % 4) + 1;
- } /*end randomizing if block*/
- for (y_temp = y_block*(HEIGHT/SHUFF_HEIGHT_DIV); y_temp < ((y_block + 1)*(HEIGHT/SHUFF_HEIGHT_DIV)) - 1; y_temp++)
- {
- for (x_temp = x_block*(WIDTH/SHUFF_WIDTH_DIV); x_temp < ((x_block + 1)*(WIDTH/SHUFF_WIDTH_DIV)) - 1; x_temp++)
- {
- r_temp = R[x][y];
- g_temp = G[x][y];
- b_temp = B[x][y];
- R[x][y] = R[x_temp][y_temp];
- G[x][y] = G[x_temp][y_temp];
- B[x][y] = B[x_temp][y_temp];
- R[x_temp][y_temp] = r_temp;
- G[x_temp][y_temp] = g_temp;
- B[x_temp][y_temp] = b_temp;
- }/*end x_temp counting block*/
- }/*end y_temp block*/
- } /*end x counting block*/
- } /*end y counting block*/
- for (y = HEIGHT/SHUFF_HEIGHT_DIV; y < 2*(HEIGHT/SHUFF_HEIGHT_DIV) - 1; y++)
- {
- for (x = WIDTH/SHUFF_WIDTH_DIV; x < 2*(WIDTH/SHUFF_WIDTH_DIV) - 1; x++)
- {
- if ((x == WIDTH/SHUFF_WIDTH_DIV) && (y == HEIGHT/SHUFF_HEIGHT_DIV))
- {
- x_block = (rand () % 4) + 1;
- y_block = (rand () % 4) + 1;
- } /*end randomizing if block*/
- for (y_temp = y_block*(HEIGHT/SHUFF_HEIGHT_DIV); y_temp < ((y_block + 1)*(HEIGHT/SHUFF_HEIGHT_DIV)) - 1; y_temp++)
- {
- for (x_temp = x_block*(WIDTH/SHUFF_WIDTH_DIV); x_temp < ((x_block + 1)*(WIDTH/SHUFF_WIDTH_DIV)) - 1; x_temp++)
- {
- r_temp = R[x][y];
- g_temp = G[x][y];
- b_temp = B[x][y];
- R[x][y] = R[x_temp][y_temp];
- G[x][y] = G[x_temp][y_temp];
- B[x][y] = B[x_temp][y_temp];
- R[x_temp][y_temp] = r_temp;
- G[x_temp][y_temp] = g_temp;
- B[x_temp][y_temp] = b_temp;
- }/*end x_temp counting block*/
- }/*end y_temp block*/
- } /*end x counting block*/
- } /*end y counting block*/
- for (y = 2*(HEIGHT/SHUFF_HEIGHT_DIV); y < 3*(HEIGHT/SHUFF_HEIGHT_DIV) - 1; y++)
- {
- for (x = 2*(WIDTH/SHUFF_WIDTH_DIV); x < 3*(WIDTH/SHUFF_WIDTH_DIV) - 1; x++)
- {
- if ((x == 2*(WIDTH/SHUFF_WIDTH_DIV)) && (y == 2*(HEIGHT/SHUFF_HEIGHT_DIV)))
- {
- x_block = (rand () % 4) + 1;
- y_block = (rand () % 4) + 1;
- } /*end randomizing if block*/
- for (y_temp = y_block*(HEIGHT/SHUFF_HEIGHT_DIV); y_temp < ((y_block + 1)*(HEIGHT/SHUFF_HEIGHT_DIV)) - 1; y_temp++)
- {
- for (x_temp = x_block*(WIDTH/SHUFF_WIDTH_DIV); x_temp < ((x_block + 1)*(WIDTH/SHUFF_WIDTH_DIV)) - 1; x_temp++)
- {
- r_temp = R[x][y];
- g_temp = G[x][y];
- b_temp = B[x][y];
- R[x][y] = R[x_temp][y_temp];
- G[x][y] = G[x_temp][y_temp];
- B[x][y] = B[x_temp][y_temp];
- R[x_temp][y_temp] = r_temp;
- G[x_temp][y_temp] = g_temp;
- B[x_temp][y_temp] = b_temp;
- }/*end x_temp counting block*/
- }/*end y_temp block*/
- } /*end x counting block*/
- } /*end y counting block*/
- for (y = 3*(HEIGHT/SHUFF_HEIGHT_DIV); y < HEIGHT; y++)
- {
- for (x = 3*(WIDTH/SHUFF_WIDTH_DIV); x < WIDTH; x++)
- {
- if ((x == 3*(WIDTH/SHUFF_WIDTH_DIV)) && (y == 3*(HEIGHT/SHUFF_HEIGHT_DIV)))
- {
- x_block = (rand () % 4) + 1;
- y_block = (rand () % 4) + 1;
- } /*end randomizing if block*/
- for (y_temp = y_block*(HEIGHT/SHUFF_HEIGHT_DIV); y_temp < ((y_block + 1)*(HEIGHT/SHUFF_HEIGHT_DIV)) - 1; y_temp++)
- {
- for (x_temp = x_block*(WIDTH/SHUFF_WIDTH_DIV); x_temp < ((x_block + 1)*(WIDTH/SHUFF_WIDTH_DIV)) - 1; x_temp++)
- {
- r_temp = R[x][y];
- g_temp = G[x][y];
- b_temp = B[x][y];
- R[x][y] = R[x_temp][y_temp];
- G[x][y] = G[x_temp][y_temp];
- B[x][y] = B[x_temp][y_temp];
- R[x_temp][y_temp] = r_temp;
- G[x_temp][y_temp] = g_temp;
- B[x_temp][y_temp] = b_temp;
- }/*end x_temp counting block*/
- }/*end y_temp block*/
- } /*end x counting block*/
- } /*end y counting block*/
- printf("Shuffle is done!\n");
- }/*end of Shuffle operation*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement