дÔÚÇ°Ãæ
AlloyCrop Õâ¸öÏîÄ¿ÊÇ8¸öÔÂÇ°·¢²¼µÄ£¬×÷ΪAlloyFinger µÄµäÐÍ°¸Àý£¬·¢²¼Ö®ºó±»BATµÈÆäËû¹«Ë¾¹ã·ºÊ¹Óᣵ«ÊÇ·¢²¼Ö®ºó£¬ÓÐÁ½¸öÎÊÌâһֱûÓгé³öʱ¼äÈ¥½â¾ö:
ÏÖÔںܸßÐ˵ظæËß´ó¼Ò£¬AlloyCrop ÒѾÍêÈ«¸ã¶¨ÁËÉÏÃæÁ½¸öÎÊÌ⣬±¾ÎĽ«½âÊÍа汾µÄ±ä»¯ºÍAlloyCrop±³ºóµÄÔÀí¡£µ±È»AlloyFingerµÄÔÀíÕâÀï¾Í²»ÔÙ²ûÊö£¬ÒÔÇ°ÓзÖÏí¹ý ³¬Ð¡WebÊÖÊÆ¿âAlloyFingerÔÀí
ÏÈ¿´È«ÐµÄAPI±ä»¯¡£
API(base64() );
²ÎÊý ÊÇ·ñ±ØÌî ÒâÒå
image_src ±ØÐë ÐèÒª²Ã¼ôͼƬµÄsrcµØÖ·
circle ²»±ØÐ룬ĬÈÏÊÇfalse ´ú±íÑ¡È¡µÄÊÇ·ñÊÇÔ²Ðλ¹ÊǾØÐΣ¬Ä¬ÈÏÊǾØÐΣ¬×¢Òâ:Ô²ÐÎÑ¡È¡²Ã¼ô³öÀ´µÄÒ²ÊÇÕý·½ÐÎͼƬ
width ±ØÐë Ñ¡ÇøµÄ¿í
height ±ØÐë Ñ¡ÇøµÄ¸ß
output ±ØÐë Êä³öµÄ±¶ÂÊ¡£±ÈÈçÈç¹ûoutputΪ2£¬Ñ¡ÇøµÄ¿í300£¬Ñ¡ÇøµÄ¸ß100£¬Êä³öµÄͼÏñµÄ·Ö±æÂÊΪ (2¡Á300£¬2¡Á100£©
ok ±ØÐë µã»÷ok°´Å¥µÄ»Øµ÷
cancel ±ØÐë µã»÷cancel°´Å¥µÄ»Øµ÷
ok_text ²»±ØÐ룬ĬÈÏÊÇok ok°´Å¥µÄÎı¾
cancel_text ²»±ØÐ룬ĬÈÏÊÇcancel cancel°´Å¥µÄÎı¾
Óë֮ǰ°æ±¾×îÖ÷ÒªµÄ±ä»¯¾ÍÊÇÐÂÔöÁË output Ö§³Ö×Ô¶¨Ò屶ÂÊ·Ö±æÂʵÄͼÏñÊä³ö¡£
outputÔÀícrop.....canvas.height); },
ÆäÖÐ this.calculateRect() ÊǼÆËãÑ¡È¡ºÍͼƬÖصþÔÚÒ»ÆðµÄ¾ØÐÎÇøÓò£¬drawImage ÊǰѲüôµÄÇøÓò»æÖƵ½ canvas ÉÏ¡£×¢Òâ canvas µÄ¿í¸ßÊǶàÉÙ£¿ÇÒ¿´:
.....output;
ËùÒԾʹﵽÁË×Ô¶¨Ò屶ÂÊ·Ö±æÂʵÄÄ¿µÄ¡£µ±È»ÕâÀïͼƬµÄʧÕæÓÖ»òÕß³¬·Ö±æ£¬¶¼È¡¾öÓÚ drawImage ²åÖµ¹ý³Ì¡£¹ØÓÚ²åÖµ£¬ÒÔÇ°ÌØÒâ¶Ô±È¹ý£¬Ê¹ÓÃÈý´Î¾í»ý²åÖµÍ걬ÁËÆäËû¼¸¸ö,µ«ÊÇÈý´Î¾í»ý²åÖµËÙ¶ÈÒ²ÊÇ×îÂý£¬ËùÒÔä¯ÀÀÆ÷ÄÚºËҪȨºâЧÂʺͲåÖµ½á¹ûȥʵÏÖ drawImage¡£
calculateRect¼ÆËã²Ã¼ôÇøÓòÒòΪÎÒÃÇÐèÒª°ÑͼƬµÄij¸öÇøÓò»æÖƵ½Õû¸öcanvasÉÏ¡£ËùÒÔdrawImageµÄºóËĸö²ÎÊýΪ£¨0, 0, this.canvas.width, this.canvas.height£©£¬È»ºóÎÒÃÇÐèҪȥ¼ÆËãͼƬ²Ã¼ôµÄÇøÓò¡£
´ó¸Å¾Í·ÖÉÏÃæÁ½ÖÖÇé¿ö£¬Ò»ÖÖÊÇÍêÈ«°üº¬£¬Ò»ÖÖ²¿·ÖÏཻ¡£
ÒòΪͼƬ»á±»·Å´ó»òÕßËõС(scale)£¬ËùÒÔÇé¿ö»á±äµÃÉÔ΢¸´ÔÓÒ»µãµã¡£Çó³öÏཻµÄ¾ØÐÎÇøÓòºó£¬Òª¶ÔͼƬscale½øÐÐУÕý£¬Ð£Õý»Øµ½1µÄ±ÈÀý£¬²ÅÄÜÓÃÓÚdrawImage¡£¾ßÌå´úÂë²Î¼û
pinch Ëõ·ÅÓÅ»¯Ê¹ÓÃAlloyCropÊÇ¿ÉÒÔ·Å´ó»òÕßËõСÔÙ½øÐвüô£¬Ôõô»ùÓÚ pinch µÄÁ½¸öÊÖÖ¸µÄÖмä½øÐзŴóÄØ£¿ËùÒÔµÄÃØÃܶ¼ÔÚÕâ¸ömultipointStartÀï¡£
(evt) centerX .centerY .cr img_centerX .img_centerY .offX preOriginX preOriginY ........(evt) ...(evt) ....);
This content is released under the MIT License.
¡¡