Advertisement
matbiz01

Untitled

May 17th, 2021
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. void* by_number(void *arg){
  2.     pthread_t id = pthread_self();
  3.     for(int i = 0; i < height; i++){
  4.         for(int j = 0; j < width; j++){
  5.             for(int x = 0; x < thread_count; x++){
  6.                 if(pthread_equal(id,tid[x])){
  7.                     if(can_change(x, numbers[i][j]) == 1){
  8.                         numbers[i][j] = 255 - numbers[i][j];
  9.                     }
  10.                 }
  11.             }
  12.         }
  13.     }
  14. }
  15.  
  16. int can_change(int thread_num, int number){
  17.     int step = 256 / thread_count;
  18.     if(thread_num * step <= number && number < (thread_num + 1) * step) return 1;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement