Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Divide image to 9 parts
- ImageProcessor.getDataImagePart = function(image, section_code){
- mod_width = image.width%3;
- mod_height = image.height%3;
- box_width = (image.width- mod_width)/3;
- box_height = (image.height - mod_height)/3;
- IP = ImageProcessor;
- IP.context.drawImage(image, 0, 0);
- switch(section_code){
- case 1:
- return IP.context.getImageData(0, 0, box_width, box_height);
- break;
- case 2:
- return IP.context.getImageData(box_width, 0, box_width, box_height);
- break;
- case 3:
- return IP.context.getImageData(box_width*2, 0, box_width+mod_width, box_height);
- break;
- case 4:
- return IP.context.getImageData(0, box_height, box_width, box_height);
- break;
- case 5:
- return IP.context.getImageData(box_width, box_height, box_width, box_height);
- break;
- case 6:
- return IP.context.getImageData(box_width*2, box_height, box_width+mod_width, box_height);
- break;
- case 7:
- return IP.context.getImageData(0, box_height*2, box_width, box_height+mod_height);
- break;
- case 8:
- return IP.context.getImageData(box_width, box_height*2, box_width, box_height+mod_height);
- break;
- case 9:
- return IP.context.getImageData(box_width*2, box_height*2, box_width+mod_width, box_height+mod_height);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement