Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Divide image to 9 parts
  2. ImageProcessor.getDataImagePart = function(image, section_code){
  3.     mod_width = image.width%3;
  4.     mod_height = image.height%3;
  5.     box_width = (image.width- mod_width)/3;
  6.     box_height = (image.height - mod_height)/3;
  7.  
  8.     IP = ImageProcessor;
  9.     IP.context.drawImage(image, 0, 0);
  10.     switch(section_code){
  11.         case 1:
  12.             return IP.context.getImageData(0, 0, box_width, box_height);
  13.             break;
  14.         case 2:
  15.             return IP.context.getImageData(box_width, 0, box_width, box_height);
  16.             break;
  17.         case 3:
  18.             return IP.context.getImageData(box_width*2, 0, box_width+mod_width, box_height);
  19.             break;
  20.         case 4:
  21.             return IP.context.getImageData(0, box_height, box_width, box_height);
  22.             break;
  23.         case 5:
  24.             return IP.context.getImageData(box_width, box_height, box_width, box_height);
  25.             break;
  26.         case 6:
  27.             return IP.context.getImageData(box_width*2, box_height, box_width+mod_width, box_height);
  28.             break;
  29.         case 7:
  30.             return IP.context.getImageData(0, box_height*2, box_width, box_height+mod_height);
  31.             break;
  32.         case 8:
  33.             return IP.context.getImageData(box_width, box_height*2, box_width, box_height+mod_height);
  34.             break;
  35.         case 9:
  36.             return IP.context.getImageData(box_width*2, box_height*2, box_width+mod_width, box_height+mod_height);
  37.             break;
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement