//来自插件   在缩放图片的同时能平滑处理 避免锯齿 

var scaleImgAA;    //AA: Antialias抗锯齿


 
	function t(t, a, i, r) {
		function h() {
			B = "object" == typeof i ? i : a.src || r ? u : document.createElement("canvas"),
				B.width = s,
				B.height = f,
				G = B.getContext("2d")
		}
		function n(t) {
			if (t) {
				var e, a = G.getImageData(0, 0, s, f), i = a.data;
				for (e = 0; at > e; e += 4)
					i[e] = t[e] * it | 0,
						i[e + 1] = t[e + 1] * it | 0,
						i[e + 2] = t[e + 2] * it | 0,
						i[e + 3] = t[e + 3] * it | 0;
				/* return delete t,
					a */
					return a
			}
			return G.getImageData(0, 0, s, f)
		}
		function o(t, e, a, i, r) {
			return .5 * (i - e + (2 * e - 5 * a + 4 * i - r + (3 * (a - i) + r - e) * t) * t) * t + a
		}
		a || (a = t.input,
			i = t.output,
			r = t.inputRemovable,
			t.scale && (t = t.scale));
		var u, d;
		if (a.src)
			if (u = document.createElement("canvas"),
				null != a.naturalWidth)
				u.width = a.naturalWidth,
					u.height = a.naturalHeight;
			else if (null != a.runtimeStyle) {
				var l = a.runtimeStyle
					, c = l.width
					, g = l.height;
				l.width = "auto",
					l.height = "auto",
					u.width = a.width,
					u.height = a.height,
					l.width = c,
					l.height = g
			} else {
				var c = a.width
					, g = a.height;
				a.removeAttribute && (a.removeAttribute("width"),
					a.removeAttribute("height")),
					u.width = a.width,
					u.height = a.height,
					a.width = c,
					a.height = g
			}
		else
			u = a;
		d = u.getContext("2d"),
			a.src && d.drawImage(a, 0, 0);
		var s, f, m = u.width, w = u.height, p = d.getImageData(0, 0, m, w).data;
		if (!m || !w)
			return !1;
		(a.src || r) && u.clearRect(0, 0, m, w),
			"object" == typeof t ? t.width ? (s = t.width + .5 | 0,
				f = t.height + .5 | 0) : (s = m * t.scaleX + .5 | 0,
					f = w * t.scaleY + .5 | 0) : (s = t * m + .5 | 0,
						f = t * w + .5 | 0);
		var v, b, y, x, D, I, A, j, R, k, C, E, F, L, S, U, W, H, alpha, X, Y, q, z, B, G, J, K, M, N, O, P, Q, T, V, Z, $ = s << 2, _ = m << 2, tt = 0, et = 0, at = $ * f, it = 255.99 / 255, rt = s / m, ht = f / w, nt = rt * ht;
		if (rt > 1 || ht > 1)
			for (h(),
				J = n(),
				K = J.data,
				x = 0; f > x; x++)
				for (b = x / ht,
					R = 0 | b,
					q = b - R,
					N = R * _,
					M = 1 > R ? N : N - _,
					w - 2 > R ? (O = N + _,
						P = (R + 2) * _) : O = P = R > w - 2 ? N : N + _,
					y = 0; s > y; y++ ,
					et += 4)
					v = y / rt,
						j = 0 | v,
						z = v - j,
						T = j << 2,
						Q = 1 > j ? T : T - 4,
						m - 2 > j ? (V = T + 4,
							Z = T + 8) : V = Z = j > m - 2 ? T : T + 4,
						H = o(q, o(z, p[M + Q], p[M + T], p[M + V], p[M + Z]), o(z, p[N + Q], p[N + T], p[N + V], p[N + Z]), o(z, p[O + Q], p[O + T], p[O + V], p[O + Z]), o(z, p[P + Q], p[P + T], p[P + V], p[P + Z])) * it | 0,
						++Q,
						++T,
						++V,
						++Z,
						X = o(q, o(z, p[M + Q], p[M + T], p[M + V], p[M + Z]), o(z, p[N + Q], p[N + T], p[N + V], p[N + Z]), o(z, p[O + Q], p[O + T], p[O + V], p[O + Z]), o(z, p[P + Q], p[P + T], p[P + V], p[P + Z])) * it | 0,
						++Q,
						++T,
						++V,
						++Z,
						Y = o(q, o(z, p[M + Q], p[M + T], p[M + V], p[M + Z]), o(z, p[N + Q], p[N + T], p[N + V], p[N + Z]), o(z, p[O + Q], p[O + T], p[O + V], p[O + Z]), o(z, p[P + Q], p[P + T], p[P + V], p[P + Z])) * it | 0,
						++Q,
						++T,
						++V,
						++Z,
						alpha = o(q, o(z, p[M + Q], p[M + T], p[M + V], p[M + Z]), o(z, p[N + Q], p[N + T], p[N + V], p[N + Z]), o(z, p[O + Q], p[O + T], p[O + V], p[O + Z]), o(z, p[P + Q], p[P + T], p[P + V], p[P + Z])) * it | 0,
						K[et] = H >= 0 ? 256 > H ? H : 255 : 0,
						K[et + 1] = X >= 0 ? 256 > X ? X : 255 : 0,
						K[et + 2] = Y >= 0 ? 256 > Y ? Y : 255 : 0,
						K[et + 3] = alpha >= 0 ? 256 > alpha ? alpha : 255 : 0;
		else {
			if (e.Float32Array)
				W = new Float32Array(at);
			else
				for (W = [],
					et = 0; at > et; ++et)
					W[et] = 0;
			for (b = 0; w > b; b++)
				for (x = b * ht,
					A = 0 | x,
					D = A * $,
					U = !!((A - (x + ht | 0)) * (w - 1 - b)) << 1,
					U && (F = A + 1 - x,
						L = x + ht - A - 1),
					v = 0; m > v; v++ ,
					tt += 4)
					switch (y = v * rt,
					I = 0 | y,
					et = D + (I << 2),
					S = !!((I - (y + rt | 0)) * (m - 1 - v)),
					S && (C = I + 1 - y,
						E = y + rt - I - 1),
					H = p[tt],
					X = p[tt + 1],
					Y = p[tt + 2],
					alpha = p[tt + 3],
					S + U) {
						case 0:
							W[et] += H * nt,
								W[et + 1] += X * nt,
								W[et + 2] += Y * nt,
								W[et + 3] += alpha * nt;
							break;
						case 1:
							k = C * ht,
								W[et] += H * k,
								W[et + 1] += X * k,
								W[et + 2] += Y * k,
								W[et + 3] += alpha * k,
								k = E * ht,
								W[et + 4] += H * k,
								W[et + 5] += X * k,
								W[et + 6] += Y * k,
								W[et + 7] += alpha * k;
							break;
						case 2:
							k = rt * F,
								W[et] += H * k,
								W[et + 1] += X * k,
								W[et + 2] += Y * k,
								W[et + 3] += alpha * k,
								k = rt * L,
								et += $,
								W[et] += H * k,
								W[et + 1] += X * k,
								W[et + 2] += Y * k,
								W[et + 3] += alpha * k;
							break;
						default:
							k = C * F,
								W[et] += H * k,
								W[et + 1] += X * k,
								W[et + 2] += Y * k,
								W[et + 3] += alpha * k,
								k = E * F,
								W[et + 4] += H * k,
								W[et + 5] += X * k,
								W[et + 6] += Y * k,
								W[et + 7] += alpha * k,
								k = C * L,
								et += $,
								W[et] += H * k,
								W[et + 1] += X * k,
								W[et + 2] += Y * k,
								W[et + 3] += alpha * k,
								k = E * L,
								W[et + 4] += H * k,
								W[et + 5] += X * k,
								W[et + 6] += Y * k,
								W[et + 7] += alpha * k;
					}
			 //delete p,
				h(),
				J = n(W)  
		}
		if (G.putImageData(J, 0, 0),
			"string" == typeof i) {
			if ("png" === i || "jpeg" === i) {
				var ot;
				return ot = r && a.src ? a : new Image,
					ot.width = s,
					ot.height = f,
					ot.src = B.toDataURL("image/" + i, 0.85),
					ot
			}
			if ("png-src" === i || "jpeg-src" === i)
				return B.toDataURL("image/" + i.split("-")[0], 0.85)
		}
		return B
	}
	var e = window;//this;
	/* "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = t),
		exports.scale = t) : c = t */
		
	scaleImgAA = t;	
		
  

export default scaleImgAA