/**
 * @fileOverview 图片操作, 负责预览图片和上传前压缩图片
 */
define([
    '../base',
    '../uploader',
    '../lib/md5',
    './widget'
], function( Base, Uploader, Md5 ) {

    return Uploader.register({
        'md5-file': 'md5Blob'
    }, {


        /**
         * 计算文件 md5 值，返回一个 promise 对象，可以监听 progress 进度。
         *
         *
         * @method md5File
         * @grammar md5File( file ) => promise
         * @for Uploader
         * @example
         *
         * uploader.on( 'fileQueued', function( file ) {
         *     var $li = ...;
         *
         *     uploader.md5File( file )
         *
         *         // 及时显示进度
         *         .progress(function(percentage) {
         *             console.log('Percentage:', percentage);
         *         })
         *
         *         // 完成
         *         .then(function(val) {
         *             console.log('md5 result:', val);
         *         });
         *
         * });
         */
        md5Blob: function( file ) {
            var md5 = new Md5(),
                deferred = Base.Deferred();

            md5.on( 'progress load', function( e ) {
                e = e || {};
                deferred.notify( e.total ? e.loaded / e.total : 1 );
            });

            md5.on( 'complete', function() {
                deferred.resolve( md5.getResult() );
            });

            md5.on( 'error', function( reason ) {
                deferred.reject( reason );
            });

            md5.loadFromBlob( file.source );

            return deferred.promise();
        }
    });
});
@@ -100,16 +100,35 @@
 b/md5',%0A
+    '../lib/blob',%0A
     './w
@@ -166,16 +166,22 @@
 der, Md5
+, Blob
  ) %7B%0A%0A  
@@ -400,16 +400,32 @@
 le( file
+%5B, start%5B, end%5D%5D
  ) =%3E pr
@@ -1018,32 +1018,44 @@
 : function( file
+, start, end
  ) %7B%0A           
@@ -1118,16 +1118,107 @@
 ferred()
+,%0A                blob = (file instanceof Blob) ? file : file.source;%0A%0A            debugger
 ;%0A%0A     
@@ -1597,32 +1597,314 @@
            %7D);%0A%0A
+            if ( arguments.length %3E 1 ) %7B%0A                start = start %7C%7C 0;%0A                end = end %7C%7C 0;%0A                start %3C 0 && (start = blob.size + start);%0A                end %3C 0 && (end = blob.size + end);%0A                blob = blob.slice(start, end);%0A            %7D%0A%0A
             md5.
@@ -1917,27 +1917,20 @@
 omBlob( 
-file.source
+blob
  );%0A%0A   

优化 md5File 支持指定位置