Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. /* Perform Cut Paste operations on the image*/
  2. IMAGE* CutPaste( IMAGE *image,
  3. unsigned int startX,
  4. unsigned int startY,
  5. unsigned int x_width,
  6. unsigned int y_width, unsigned int pasteNumber)
  7.  
  8. {
  9. unsigned char baseR[image->Width][image->Height];
  10. unsigned char baseG[image->Width][image->Height];
  11. unsigned char baseB[image->Width][image->Height];
  12.  
  13. int x, y, n;
  14. for(x = startX ; x < startX + image->Width ; x++){
  15. for(y = startY ; y < startY + image->Height ; y++){
  16. baseR[x-startX][y-startY] = GetPixelR(image,x,y);
  17. baseG[x-startX][y-startY] = GetPixelG(image,x,y);
  18. baseB[x-startX][y-startY] = GetPixelB(image,x,y);
  19. }
  20. }
  21.  
  22. for( n = 1; n <= pasteNumber ; n++){
  23. unsigned int pasteX, pasteY;
  24. #ifdef DEBUG
  25. switch(n)
  26. {
  27. case 1:
  28. pasteX = 341;
  29. pasteY = 19;
  30. break;
  31. case 2:
  32. pasteX = 315;
  33. pasteY = 18;
  34. break;
  35. case 3:
  36. pasteX = 288;
  37. pasteY = 16;
  38. break;
  39. default:
  40. break;
  41. }
  42. #else
  43. printf("Please input start x and y coordinates for paste no %d: ", n);
  44. scanf("%u %u", &pasteX, &pasteY);
  45. #endif /* DEBUG */
  46.  
  47. for(x = 0 ; x < image->Width ; x++){
  48. for(y = 0 ; y < image->Height ; y++){
  49. SetPixelR(image,x+pasteX,y+pasteY,baseR[x][y]);
  50. SetPixelG(image,x+pasteX,y+pasteY,baseG[x][y]);
  51. SetPixelB(image,x+pasteX,y+pasteY,baseB[x][y]);
  52. }
  53. }
  54.  
  55. }
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement