UNPKG

openfl

Version:

A fast, productive library for 2D cross-platform development.

1,029 lines (1,014 loc) 121 kB
// Class: lime._internal.graphics.ImageDataUtil var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../../hxClasses_stub").default; var $hxEnums = require("./../../../hxEnums_stub").default; var $import = require("./../../../import_stub").default; function lime__$internal_graphics__$ImageDataUtil_ImageDataView() {return require("./../../../lime/_internal/graphics/_ImageDataUtil/ImageDataView");} function Std() {return require("./../../../Std");} function lime_math__$RGBA_RGBA_$Impl_$() {return require("./../../../lime/math/_RGBA/RGBA_Impl_");} function lime_math_Vector4() {return require("./../../../lime/math/Vector4");} function lime_math__$ColorMatrix_ColorMatrix_$Impl_$() {return require("./../../../lime/math/_ColorMatrix/ColorMatrix_Impl_");} function lime_math_Rectangle() {return require("./../../../lime/math/Rectangle");} function lime__$internal_graphics_StackBlur() {return require("./../../../lime/_internal/graphics/StackBlur");} function haxe_io_Bytes() {return require("./../../../haxe/io/Bytes");} function lime_graphics_ImageBuffer() {return require("./../../../lime/graphics/ImageBuffer");} function _$UInt_UInt_$Impl_$() {return require("./../../../_UInt/UInt_Impl_");} function lime_system_Endian() {return require("./../../../lime/system/Endian");} // Constructor var ImageDataUtil = function(){} // Meta ImageDataUtil.__name__ = "lime._internal.graphics.ImageDataUtil"; ImageDataUtil.__isInterface__ = false; ImageDataUtil.prototype = { }; ImageDataUtil.prototype.__class__ = ImageDataUtil.prototype.constructor = $hxClasses["lime._internal.graphics.ImageDataUtil"] = ImageDataUtil; // Init // Statics ImageDataUtil.displaceMap = function(target,source,map,mapPoint,componentX,componentY,smooth) { var targetData = target.buffer.data; var sourceData = source.buffer.data; var mapData = map.buffer.data; var targetFormat = target.buffer.format; var sourceFormat = source.buffer.format; var mapFormat = map.buffer.format; var targetPremultiplied = target.get_premultiplied(); var sourcePremultiplied = source.get_premultiplied(); var mapPremultiplied = map.get_premultiplied(); var sourceView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(source); var mapView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(map); var row; var sourceOffset; var sourcePixel = 0; var mapPixel = 0; var targetPixel = 0; var mapPixelX; var mapPixelY; var mapPixelA; var s1 = 0; var s2 = 0; var s3 = 0; var s4 = 0; var mPointXFloor; var mPointYFloor; var disOffsetXFloor; var disOffsetYFloor; var disX; var disY; var _g = 0; var _g1 = sourceView.height; while(_g < _g1) { var y = _g++; row = sourceView.row(y); var _g2 = 0; var _g11 = sourceView.width; while(_g2 < _g11) { var x = _g2++; sourceOffset = row + x * 4; mPointXFloor = (Std().default).int(mapPoint.x); mPointYFloor = (Std().default).int(mapPoint.y); if(smooth) { var offset = sourceView.row(y - mPointYFloor + 1) + (x - mPointXFloor) * 4; var format = mapFormat; var premultiplied = mapPremultiplied; if(premultiplied == null) { premultiplied = false; } if(format == null) { format = 0; } switch(format) { case 0: s1 = (mapData[offset] & 255) << 24 | (mapData[offset + 1] & 255) << 16 | (mapData[offset + 2] & 255) << 8 | mapData[offset + 3] & 255; break; case 1: s1 = (mapData[offset + 1] & 255) << 24 | (mapData[offset + 2] & 255) << 16 | (mapData[offset + 3] & 255) << 8 | mapData[offset] & 255; break; case 2: s1 = (mapData[offset + 2] & 255) << 24 | (mapData[offset + 1] & 255) << 16 | (mapData[offset] & 255) << 8 | mapData[offset + 3] & 255; break; } if(premultiplied) { if((s1 & 255) != 0 && (s1 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s1 & 255); s1 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s1 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s1 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s1 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s1 & 255 & 255; } } var offset1 = sourceView.row(y - mPointYFloor) + (x - mPointXFloor + 1) * 4; var format1 = mapFormat; var premultiplied1 = mapPremultiplied; if(premultiplied1 == null) { premultiplied1 = false; } if(format1 == null) { format1 = 0; } switch(format1) { case 0: s2 = (mapData[offset1] & 255) << 24 | (mapData[offset1 + 1] & 255) << 16 | (mapData[offset1 + 2] & 255) << 8 | mapData[offset1 + 3] & 255; break; case 1: s2 = (mapData[offset1 + 1] & 255) << 24 | (mapData[offset1 + 2] & 255) << 16 | (mapData[offset1 + 3] & 255) << 8 | mapData[offset1] & 255; break; case 2: s2 = (mapData[offset1 + 2] & 255) << 24 | (mapData[offset1 + 1] & 255) << 16 | (mapData[offset1] & 255) << 8 | mapData[offset1 + 3] & 255; break; } if(premultiplied1) { if((s2 & 255) != 0 && (s2 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s2 & 255); s2 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s2 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s2 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s2 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s2 & 255 & 255; } } var offset2 = sourceView.row(y - mPointYFloor + 1) + (x - mPointXFloor + 1) * 4; var format2 = mapFormat; var premultiplied2 = mapPremultiplied; if(premultiplied2 == null) { premultiplied2 = false; } if(format2 == null) { format2 = 0; } switch(format2) { case 0: s3 = (mapData[offset2] & 255) << 24 | (mapData[offset2 + 1] & 255) << 16 | (mapData[offset2 + 2] & 255) << 8 | mapData[offset2 + 3] & 255; break; case 1: s3 = (mapData[offset2 + 1] & 255) << 24 | (mapData[offset2 + 2] & 255) << 16 | (mapData[offset2 + 3] & 255) << 8 | mapData[offset2] & 255; break; case 2: s3 = (mapData[offset2 + 2] & 255) << 24 | (mapData[offset2 + 1] & 255) << 16 | (mapData[offset2] & 255) << 8 | mapData[offset2 + 3] & 255; break; } if(premultiplied2) { if((s3 & 255) != 0 && (s3 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s3 & 255); s3 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s3 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s3 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s3 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s3 & 255 & 255; } } var offset3 = sourceView.row(y - mPointYFloor) + (x - mPointXFloor) * 4; var format3 = mapFormat; var premultiplied3 = mapPremultiplied; if(premultiplied3 == null) { premultiplied3 = false; } if(format3 == null) { format3 = 0; } switch(format3) { case 0: s4 = (mapData[offset3] & 255) << 24 | (mapData[offset3 + 1] & 255) << 16 | (mapData[offset3 + 2] & 255) << 8 | mapData[offset3 + 3] & 255; break; case 1: s4 = (mapData[offset3 + 1] & 255) << 24 | (mapData[offset3 + 2] & 255) << 16 | (mapData[offset3 + 3] & 255) << 8 | mapData[offset3] & 255; break; case 2: s4 = (mapData[offset3 + 2] & 255) << 24 | (mapData[offset3 + 1] & 255) << 16 | (mapData[offset3] & 255) << 8 | mapData[offset3 + 3] & 255; break; } if(premultiplied3) { if((s4 & 255) != 0 && (s4 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s4 & 255); s4 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s4 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s4 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s4 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s4 & 255 & 255; } } mapPixel = ImageDataUtil.bilinear(s1,s2,s3,s4,mapPoint.x - mPointXFloor,mapPoint.y - mPointYFloor); } else { var offset4 = mapView.row(y - mPointYFloor) + (x - mPointXFloor) * 4; var format4 = mapFormat; var premultiplied4 = mapPremultiplied; if(premultiplied4 == null) { premultiplied4 = false; } if(format4 == null) { format4 = 0; } switch(format4) { case 0: mapPixel = (mapData[offset4] & 255) << 24 | (mapData[offset4 + 1] & 255) << 16 | (mapData[offset4 + 2] & 255) << 8 | mapData[offset4 + 3] & 255; break; case 1: mapPixel = (mapData[offset4 + 1] & 255) << 24 | (mapData[offset4 + 2] & 255) << 16 | (mapData[offset4 + 3] & 255) << 8 | mapData[offset4] & 255; break; case 2: mapPixel = (mapData[offset4 + 2] & 255) << 24 | (mapData[offset4 + 1] & 255) << 16 | (mapData[offset4] & 255) << 8 | mapData[offset4 + 3] & 255; break; } if(premultiplied4) { if((mapPixel & 255) != 0 && (mapPixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (mapPixel & 255); mapPixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((mapPixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((mapPixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((mapPixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | mapPixel & 255 & 255; } } } mapPixelA = (mapPixel & 255) / 255.0; mapPixelX = ((mapPixel >>> 24 & 255) - 128) / 255.0 * mapPixelA; mapPixelY = ((mapPixel >>> 16 & 255) - 128) / 255.0 * mapPixelA; disX = mapPixelX * componentX.x + mapPixelY * componentY.x; disY = mapPixelX * componentX.y + mapPixelY * componentY.y; disOffsetXFloor = Math.floor(disX * sourceView.width); disOffsetYFloor = Math.floor(disY * sourceView.height); if(smooth) { var offset5 = sourceView.row(y + disOffsetYFloor + 1) + (x + disOffsetXFloor) * 4; var format5 = sourceFormat; var premultiplied5 = sourcePremultiplied; if(premultiplied5 == null) { premultiplied5 = false; } if(format5 == null) { format5 = 0; } switch(format5) { case 0: s1 = (sourceData[offset5] & 255) << 24 | (sourceData[offset5 + 1] & 255) << 16 | (sourceData[offset5 + 2] & 255) << 8 | sourceData[offset5 + 3] & 255; break; case 1: s1 = (sourceData[offset5 + 1] & 255) << 24 | (sourceData[offset5 + 2] & 255) << 16 | (sourceData[offset5 + 3] & 255) << 8 | sourceData[offset5] & 255; break; case 2: s1 = (sourceData[offset5 + 2] & 255) << 24 | (sourceData[offset5 + 1] & 255) << 16 | (sourceData[offset5] & 255) << 8 | sourceData[offset5 + 3] & 255; break; } if(premultiplied5) { if((s1 & 255) != 0 && (s1 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s1 & 255); s1 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s1 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s1 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s1 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s1 & 255 & 255; } } var offset6 = sourceView.row(y + disOffsetYFloor) + (x + disOffsetXFloor + 1) * 4; var format6 = sourceFormat; var premultiplied6 = sourcePremultiplied; if(premultiplied6 == null) { premultiplied6 = false; } if(format6 == null) { format6 = 0; } switch(format6) { case 0: s2 = (sourceData[offset6] & 255) << 24 | (sourceData[offset6 + 1] & 255) << 16 | (sourceData[offset6 + 2] & 255) << 8 | sourceData[offset6 + 3] & 255; break; case 1: s2 = (sourceData[offset6 + 1] & 255) << 24 | (sourceData[offset6 + 2] & 255) << 16 | (sourceData[offset6 + 3] & 255) << 8 | sourceData[offset6] & 255; break; case 2: s2 = (sourceData[offset6 + 2] & 255) << 24 | (sourceData[offset6 + 1] & 255) << 16 | (sourceData[offset6] & 255) << 8 | sourceData[offset6 + 3] & 255; break; } if(premultiplied6) { if((s2 & 255) != 0 && (s2 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s2 & 255); s2 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s2 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s2 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s2 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s2 & 255 & 255; } } var offset7 = sourceView.row(y + disOffsetYFloor + 1) + (x + disOffsetXFloor + 1) * 4; var format7 = sourceFormat; var premultiplied7 = sourcePremultiplied; if(premultiplied7 == null) { premultiplied7 = false; } if(format7 == null) { format7 = 0; } switch(format7) { case 0: s3 = (sourceData[offset7] & 255) << 24 | (sourceData[offset7 + 1] & 255) << 16 | (sourceData[offset7 + 2] & 255) << 8 | sourceData[offset7 + 3] & 255; break; case 1: s3 = (sourceData[offset7 + 1] & 255) << 24 | (sourceData[offset7 + 2] & 255) << 16 | (sourceData[offset7 + 3] & 255) << 8 | sourceData[offset7] & 255; break; case 2: s3 = (sourceData[offset7 + 2] & 255) << 24 | (sourceData[offset7 + 1] & 255) << 16 | (sourceData[offset7] & 255) << 8 | sourceData[offset7 + 3] & 255; break; } if(premultiplied7) { if((s3 & 255) != 0 && (s3 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s3 & 255); s3 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s3 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s3 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s3 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s3 & 255 & 255; } } var offset8 = sourceView.row(y + disOffsetYFloor) + (x + disOffsetXFloor) * 4; var format8 = sourceFormat; var premultiplied8 = sourcePremultiplied; if(premultiplied8 == null) { premultiplied8 = false; } if(format8 == null) { format8 = 0; } switch(format8) { case 0: s4 = (sourceData[offset8] & 255) << 24 | (sourceData[offset8 + 1] & 255) << 16 | (sourceData[offset8 + 2] & 255) << 8 | sourceData[offset8 + 3] & 255; break; case 1: s4 = (sourceData[offset8 + 1] & 255) << 24 | (sourceData[offset8 + 2] & 255) << 16 | (sourceData[offset8 + 3] & 255) << 8 | sourceData[offset8] & 255; break; case 2: s4 = (sourceData[offset8 + 2] & 255) << 24 | (sourceData[offset8 + 1] & 255) << 16 | (sourceData[offset8] & 255) << 8 | sourceData[offset8 + 3] & 255; break; } if(premultiplied8) { if((s4 & 255) != 0 && (s4 & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (s4 & 255); s4 = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s4 >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s4 >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((s4 >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | s4 & 255 & 255; } } sourcePixel = ImageDataUtil.bilinear(s1,s2,s3,s4,disX * sourceView.width - disOffsetXFloor,disY * sourceView.height - disOffsetYFloor); } else { var offset9 = sourceView.row(y + disOffsetYFloor) + (x + disOffsetXFloor) * 4; var format9 = sourceFormat; var premultiplied9 = sourcePremultiplied; if(premultiplied9 == null) { premultiplied9 = false; } if(format9 == null) { format9 = 0; } switch(format9) { case 0: sourcePixel = (sourceData[offset9] & 255) << 24 | (sourceData[offset9 + 1] & 255) << 16 | (sourceData[offset9 + 2] & 255) << 8 | sourceData[offset9 + 3] & 255; break; case 1: sourcePixel = (sourceData[offset9 + 1] & 255) << 24 | (sourceData[offset9 + 2] & 255) << 16 | (sourceData[offset9 + 3] & 255) << 8 | sourceData[offset9] & 255; break; case 2: sourcePixel = (sourceData[offset9 + 2] & 255) << 24 | (sourceData[offset9 + 1] & 255) << 16 | (sourceData[offset9] & 255) << 8 | sourceData[offset9 + 3] & 255; break; } if(premultiplied9) { if((sourcePixel & 255) != 0 && (sourcePixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (sourcePixel & 255); sourcePixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | sourcePixel & 255 & 255; } } } var format10 = targetFormat; var premultiplied10 = targetPremultiplied; if(premultiplied10 == null) { premultiplied10 = false; } if(format10 == null) { format10 = 0; } if(premultiplied10) { if((sourcePixel & 255) == 0) { if(sourcePixel != 0) { sourcePixel = 0; } } else if((sourcePixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).a16 = (lime_math__$RGBA_RGBA_$Impl_$().default).__alpha16[sourcePixel & 255]; sourcePixel = ((sourcePixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 24 | ((sourcePixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 16 | ((sourcePixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 8 | sourcePixel & 255 & 255; } } switch(format10) { case 0: targetData[sourceOffset] = sourcePixel >>> 24 & 255; targetData[sourceOffset + 1] = sourcePixel >>> 16 & 255; targetData[sourceOffset + 2] = sourcePixel >>> 8 & 255; targetData[sourceOffset + 3] = sourcePixel & 255; break; case 1: targetData[sourceOffset] = sourcePixel & 255; targetData[sourceOffset + 1] = sourcePixel >>> 24 & 255; targetData[sourceOffset + 2] = sourcePixel >>> 16 & 255; targetData[sourceOffset + 3] = sourcePixel >>> 8 & 255; break; case 2: targetData[sourceOffset] = sourcePixel >>> 8 & 255; targetData[sourceOffset + 1] = sourcePixel >>> 16 & 255; targetData[sourceOffset + 2] = sourcePixel >>> 24 & 255; targetData[sourceOffset + 3] = sourcePixel & 255; break; } } } target.dirty = true; target.version++; } ImageDataUtil.bilinear = function(s1,s2,s3,s4,su,sv) { return ImageDataUtil.lerpRGBA(ImageDataUtil.lerpRGBA(s4,s2,su),ImageDataUtil.lerpRGBA(s1,s3,su),sv); } ImageDataUtil.lerpRGBA = function(v0,v1,x) { var result = 0; var value = Math.floor(ImageDataUtil.lerp(v0 >>> 24 & 255,v1 >>> 24 & 255,x)); result = (value & 255) << 24 | (result >>> 16 & 255 & 255) << 16 | (result >>> 8 & 255 & 255) << 8 | result & 255 & 255; var value1 = Math.floor(ImageDataUtil.lerp(v0 >>> 16 & 255,v1 >>> 16 & 255,x)); result = (result >>> 24 & 255 & 255) << 24 | (value1 & 255) << 16 | (result >>> 8 & 255 & 255) << 8 | result & 255 & 255; var value2 = Math.floor(ImageDataUtil.lerp(v0 >>> 8 & 255,v1 >>> 8 & 255,x)); result = (result >>> 24 & 255 & 255) << 24 | (result >>> 16 & 255 & 255) << 16 | (value2 & 255) << 8 | result & 255 & 255; var value3 = Math.floor(ImageDataUtil.lerp(v0 & 255,v1 & 255,x)); result = (result >>> 24 & 255 & 255) << 24 | (result >>> 16 & 255 & 255) << 16 | (result >>> 8 & 255 & 255) << 8 | value3 & 255; return result; } ImageDataUtil.lerp4f = function(v0,v1,x) { return new (lime_math_Vector4().default)(ImageDataUtil.lerp(v0.x,v1.x,x),ImageDataUtil.lerp(v0.y,v1.y,x),ImageDataUtil.lerp(v0.z,v1.z,x),ImageDataUtil.lerp(v0.w,v1.w,x)); } ImageDataUtil.lerp = function(v0,v1,x) { return (1.0 - x) * v0 + x * v1; } ImageDataUtil.colorTransform = function(image,rect,colorMatrix) { var data = image.buffer.data; if(data == null) { return; } var format = image.buffer.format; var premultiplied = image.buffer.premultiplied; var dataView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(image,rect); var alphaTable = (lime_math__$ColorMatrix_ColorMatrix_$Impl_$().default).getAlphaTable(colorMatrix); var redTable = (lime_math__$ColorMatrix_ColorMatrix_$Impl_$().default).getRedTable(colorMatrix); var greenTable = (lime_math__$ColorMatrix_ColorMatrix_$Impl_$().default).getGreenTable(colorMatrix); var blueTable = (lime_math__$ColorMatrix_ColorMatrix_$Impl_$().default).getBlueTable(colorMatrix); var row; var offset; var pixel = 0; var _g = 0; var _g1 = dataView.height; while(_g < _g1) { var y = _g++; row = dataView.row(y); var _g2 = 0; var _g11 = dataView.width; while(_g2 < _g11) { var x = _g2++; offset = row + x * 4; var format1 = format; var premultiplied1 = premultiplied; if(premultiplied1 == null) { premultiplied1 = false; } if(format1 == null) { format1 = 0; } switch(format1) { case 0: pixel = (data[offset] & 255) << 24 | (data[offset + 1] & 255) << 16 | (data[offset + 2] & 255) << 8 | data[offset + 3] & 255; break; case 1: pixel = (data[offset + 1] & 255) << 24 | (data[offset + 2] & 255) << 16 | (data[offset + 3] & 255) << 8 | data[offset] & 255; break; case 2: pixel = (data[offset + 2] & 255) << 24 | (data[offset + 1] & 255) << 16 | (data[offset] & 255) << 8 | data[offset + 3] & 255; break; } if(premultiplied1) { if((pixel & 255) != 0 && (pixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (pixel & 255); pixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((pixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((pixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((pixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | pixel & 255 & 255; } } pixel = (redTable[pixel >>> 24 & 255] & 255) << 24 | (greenTable[pixel >>> 16 & 255] & 255) << 16 | (blueTable[pixel >>> 8 & 255] & 255) << 8 | alphaTable[pixel & 255] & 255; var format2 = format; var premultiplied2 = premultiplied; if(premultiplied2 == null) { premultiplied2 = false; } if(format2 == null) { format2 = 0; } if(premultiplied2) { if((pixel & 255) == 0) { if(pixel != 0) { pixel = 0; } } else if((pixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).a16 = (lime_math__$RGBA_RGBA_$Impl_$().default).__alpha16[pixel & 255]; pixel = ((pixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 24 | ((pixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 16 | ((pixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 8 | pixel & 255 & 255; } } switch(format2) { case 0: data[offset] = pixel >>> 24 & 255; data[offset + 1] = pixel >>> 16 & 255; data[offset + 2] = pixel >>> 8 & 255; data[offset + 3] = pixel & 255; break; case 1: data[offset] = pixel & 255; data[offset + 1] = pixel >>> 24 & 255; data[offset + 2] = pixel >>> 16 & 255; data[offset + 3] = pixel >>> 8 & 255; break; case 2: data[offset] = pixel >>> 8 & 255; data[offset + 1] = pixel >>> 16 & 255; data[offset + 2] = pixel >>> 24 & 255; data[offset + 3] = pixel & 255; break; } } } image.dirty = true; image.version++; } ImageDataUtil.copyChannel = function(image,sourceImage,sourceRect,destPoint,sourceChannel,destChannel) { var destIdx; switch(destChannel._hx_index) { case 0: destIdx = 0; break; case 1: destIdx = 1; break; case 2: destIdx = 2; break; case 3: destIdx = 3; break; } var srcIdx; switch(sourceChannel._hx_index) { case 0: srcIdx = 0; break; case 1: srcIdx = 1; break; case 2: srcIdx = 2; break; case 3: srcIdx = 3; break; } var srcData = sourceImage.buffer.data; var destData = image.buffer.data; if(srcData == null || destData == null) { return; } var srcView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(sourceImage,sourceRect); var destView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(image,new (lime_math_Rectangle().default)(destPoint.x,destPoint.y,srcView.width,srcView.height)); var srcFormat = sourceImage.buffer.format; var destFormat = image.buffer.format; var srcPremultiplied = sourceImage.buffer.premultiplied; var destPremultiplied = image.buffer.premultiplied; var srcPosition; var destPosition; var srcPixel = 0; var destPixel = 0; var value = 0; var _g = 0; var _g1 = destView.height; while(_g < _g1) { var y = _g++; srcPosition = srcView.row(y); destPosition = destView.row(y); var _g2 = 0; var _g11 = destView.width; while(_g2 < _g11) { var x = _g2++; var format = srcFormat; var premultiplied = srcPremultiplied; if(premultiplied == null) { premultiplied = false; } if(format == null) { format = 0; } switch(format) { case 0: srcPixel = (srcData[srcPosition] & 255) << 24 | (srcData[srcPosition + 1] & 255) << 16 | (srcData[srcPosition + 2] & 255) << 8 | srcData[srcPosition + 3] & 255; break; case 1: srcPixel = (srcData[srcPosition + 1] & 255) << 24 | (srcData[srcPosition + 2] & 255) << 16 | (srcData[srcPosition + 3] & 255) << 8 | srcData[srcPosition] & 255; break; case 2: srcPixel = (srcData[srcPosition + 2] & 255) << 24 | (srcData[srcPosition + 1] & 255) << 16 | (srcData[srcPosition] & 255) << 8 | srcData[srcPosition + 3] & 255; break; } if(premultiplied) { if((srcPixel & 255) != 0 && (srcPixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (srcPixel & 255); srcPixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((srcPixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((srcPixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((srcPixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | srcPixel & 255 & 255; } } var format1 = destFormat; var premultiplied1 = destPremultiplied; if(premultiplied1 == null) { premultiplied1 = false; } if(format1 == null) { format1 = 0; } switch(format1) { case 0: destPixel = (destData[destPosition] & 255) << 24 | (destData[destPosition + 1] & 255) << 16 | (destData[destPosition + 2] & 255) << 8 | destData[destPosition + 3] & 255; break; case 1: destPixel = (destData[destPosition + 1] & 255) << 24 | (destData[destPosition + 2] & 255) << 16 | (destData[destPosition + 3] & 255) << 8 | destData[destPosition] & 255; break; case 2: destPixel = (destData[destPosition + 2] & 255) << 24 | (destData[destPosition + 1] & 255) << 16 | (destData[destPosition] & 255) << 8 | destData[destPosition + 3] & 255; break; } if(premultiplied1) { if((destPixel & 255) != 0 && (destPixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (destPixel & 255); destPixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | destPixel & 255 & 255; } } switch(srcIdx) { case 0: value = srcPixel >>> 24 & 255; break; case 1: value = srcPixel >>> 16 & 255; break; case 2: value = srcPixel >>> 8 & 255; break; case 3: value = srcPixel & 255; break; } switch(destIdx) { case 0: destPixel = (value & 255) << 24 | (destPixel >>> 16 & 255 & 255) << 16 | (destPixel >>> 8 & 255 & 255) << 8 | destPixel & 255 & 255; break; case 1: destPixel = (destPixel >>> 24 & 255 & 255) << 24 | (value & 255) << 16 | (destPixel >>> 8 & 255 & 255) << 8 | destPixel & 255 & 255; break; case 2: destPixel = (destPixel >>> 24 & 255 & 255) << 24 | (destPixel >>> 16 & 255 & 255) << 16 | (value & 255) << 8 | destPixel & 255 & 255; break; case 3: destPixel = (destPixel >>> 24 & 255 & 255) << 24 | (destPixel >>> 16 & 255 & 255) << 16 | (destPixel >>> 8 & 255 & 255) << 8 | value & 255; break; } var format2 = destFormat; var premultiplied2 = destPremultiplied; if(premultiplied2 == null) { premultiplied2 = false; } if(format2 == null) { format2 = 0; } if(premultiplied2) { if((destPixel & 255) == 0) { if(destPixel != 0) { destPixel = 0; } } else if((destPixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).a16 = (lime_math__$RGBA_RGBA_$Impl_$().default).__alpha16[destPixel & 255]; destPixel = ((destPixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 24 | ((destPixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 16 | ((destPixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 8 | destPixel & 255 & 255; } } switch(format2) { case 0: destData[destPosition] = destPixel >>> 24 & 255; destData[destPosition + 1] = destPixel >>> 16 & 255; destData[destPosition + 2] = destPixel >>> 8 & 255; destData[destPosition + 3] = destPixel & 255; break; case 1: destData[destPosition] = destPixel & 255; destData[destPosition + 1] = destPixel >>> 24 & 255; destData[destPosition + 2] = destPixel >>> 16 & 255; destData[destPosition + 3] = destPixel >>> 8 & 255; break; case 2: destData[destPosition] = destPixel >>> 8 & 255; destData[destPosition + 1] = destPixel >>> 16 & 255; destData[destPosition + 2] = destPixel >>> 24 & 255; destData[destPosition + 3] = destPixel & 255; break; } srcPosition += 4; destPosition += 4; } } image.dirty = true; image.version++; } ImageDataUtil.copyPixels = function(image,sourceImage,sourceRect,destPoint,alphaImage,alphaPoint,mergeAlpha) { if(mergeAlpha == null) { mergeAlpha = false; } if(image.width == sourceImage.width && image.height == sourceImage.height && sourceRect.width == sourceImage.width && sourceRect.height == sourceImage.height && sourceRect.x == 0 && sourceRect.y == 0 && destPoint.x == 0 && destPoint.y == 0 && alphaImage == null && alphaPoint == null && mergeAlpha == false && image.get_format() == sourceImage.get_format()) { image.buffer.data.set(sourceImage.buffer.data); } else { var sourceData = sourceImage.buffer.data; var destData = image.buffer.data; if(sourceData == null || destData == null) { return; } var sourceView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(sourceImage,sourceRect); var destRect = new (lime_math_Rectangle().default)(destPoint.x,destPoint.y,sourceView.width,sourceView.height); var destView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(image,destRect); var sourceFormat = sourceImage.buffer.format; var destFormat = image.buffer.format; var sourcePosition; var destPosition; var sourceAlpha; var destAlpha; var oneMinusSourceAlpha; var blendAlpha; var sourcePixel = 0; var destPixel = 0; var sourcePremultiplied = sourceImage.buffer.premultiplied; var destPremultiplied = image.buffer.premultiplied; var sourceBytesPerPixel = (Std().default).int(sourceImage.buffer.bitsPerPixel / 8); var destBytesPerPixel = (Std().default).int(image.buffer.bitsPerPixel / 8); var useAlphaImage = alphaImage != null && alphaImage.get_transparent(); var blend = mergeAlpha || useAlphaImage && !image.get_transparent() || !mergeAlpha && !image.get_transparent() && sourceImage.get_transparent(); if(!useAlphaImage) { if(blend) { var _g = 0; var _g1 = destView.height; while(_g < _g1) { var y = _g++; sourcePosition = sourceView.row(y); destPosition = destView.row(y); var _g2 = 0; var _g11 = destView.width; while(_g2 < _g11) { var x = _g2++; var format = sourceFormat; var premultiplied = sourcePremultiplied; if(premultiplied == null) { premultiplied = false; } if(format == null) { format = 0; } switch(format) { case 0: sourcePixel = (sourceData[sourcePosition] & 255) << 24 | (sourceData[sourcePosition + 1] & 255) << 16 | (sourceData[sourcePosition + 2] & 255) << 8 | sourceData[sourcePosition + 3] & 255; break; case 1: sourcePixel = (sourceData[sourcePosition + 1] & 255) << 24 | (sourceData[sourcePosition + 2] & 255) << 16 | (sourceData[sourcePosition + 3] & 255) << 8 | sourceData[sourcePosition] & 255; break; case 2: sourcePixel = (sourceData[sourcePosition + 2] & 255) << 24 | (sourceData[sourcePosition + 1] & 255) << 16 | (sourceData[sourcePosition] & 255) << 8 | sourceData[sourcePosition + 3] & 255; break; } if(premultiplied) { if((sourcePixel & 255) != 0 && (sourcePixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (sourcePixel & 255); sourcePixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | sourcePixel & 255 & 255; } } var format1 = destFormat; var premultiplied1 = destPremultiplied; if(premultiplied1 == null) { premultiplied1 = false; } if(format1 == null) { format1 = 0; } switch(format1) { case 0: destPixel = (destData[destPosition] & 255) << 24 | (destData[destPosition + 1] & 255) << 16 | (destData[destPosition + 2] & 255) << 8 | destData[destPosition + 3] & 255; break; case 1: destPixel = (destData[destPosition + 1] & 255) << 24 | (destData[destPosition + 2] & 255) << 16 | (destData[destPosition + 3] & 255) << 8 | destData[destPosition] & 255; break; case 2: destPixel = (destData[destPosition + 2] & 255) << 24 | (destData[destPosition + 1] & 255) << 16 | (destData[destPosition] & 255) << 8 | destData[destPosition + 3] & 255; break; } if(premultiplied1) { if((destPixel & 255) != 0 && (destPixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (destPixel & 255); destPixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | destPixel & 255 & 255; } } sourceAlpha = (sourcePixel & 255) / 255.0; destAlpha = (destPixel & 255) / 255.0; oneMinusSourceAlpha = 1 - sourceAlpha; blendAlpha = sourceAlpha + destAlpha * oneMinusSourceAlpha; if(blendAlpha == 0) { destPixel = 0; } else { var value = (lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round(((sourcePixel >>> 24 & 255) * sourceAlpha + (destPixel >>> 24 & 255) * destAlpha * oneMinusSourceAlpha) / blendAlpha)]; destPixel = (value & 255) << 24 | (destPixel >>> 16 & 255 & 255) << 16 | (destPixel >>> 8 & 255 & 255) << 8 | destPixel & 255 & 255; var value1 = (lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round(((sourcePixel >>> 16 & 255) * sourceAlpha + (destPixel >>> 16 & 255) * destAlpha * oneMinusSourceAlpha) / blendAlpha)]; destPixel = (destPixel >>> 24 & 255 & 255) << 24 | (value1 & 255) << 16 | (destPixel >>> 8 & 255 & 255) << 8 | destPixel & 255 & 255; var value2 = (lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round(((sourcePixel >>> 8 & 255) * sourceAlpha + (destPixel >>> 8 & 255) * destAlpha * oneMinusSourceAlpha) / blendAlpha)]; destPixel = (destPixel >>> 24 & 255 & 255) << 24 | (destPixel >>> 16 & 255 & 255) << 16 | (value2 & 255) << 8 | destPixel & 255 & 255; var value3 = (lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round(blendAlpha * 255.0)]; destPixel = (destPixel >>> 24 & 255 & 255) << 24 | (destPixel >>> 16 & 255 & 255) << 16 | (destPixel >>> 8 & 255 & 255) << 8 | value3 & 255; } var format2 = destFormat; var premultiplied2 = destPremultiplied; if(premultiplied2 == null) { premultiplied2 = false; } if(format2 == null) { format2 = 0; } if(premultiplied2) { if((destPixel & 255) == 0) { if(destPixel != 0) { destPixel = 0; } } else if((destPixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).a16 = (lime_math__$RGBA_RGBA_$Impl_$().default).__alpha16[destPixel & 255]; destPixel = ((destPixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 24 | ((destPixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 16 | ((destPixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 8 | destPixel & 255 & 255; } } switch(format2) { case 0: destData[destPosition] = destPixel >>> 24 & 255; destData[destPosition + 1] = destPixel >>> 16 & 255; destData[destPosition + 2] = destPixel >>> 8 & 255; destData[destPosition + 3] = destPixel & 255; break; case 1: destData[destPosition] = destPixel & 255; destData[destPosition + 1] = destPixel >>> 24 & 255; destData[destPosition + 2] = destPixel >>> 16 & 255; destData[destPosition + 3] = destPixel >>> 8 & 255; break; case 2: destData[destPosition] = destPixel >>> 8 & 255; destData[destPosition + 1] = destPixel >>> 16 & 255; destData[destPosition + 2] = destPixel >>> 24 & 255; destData[destPosition + 3] = destPixel & 255; break; } sourcePosition += 4; destPosition += 4; } } } else if(sourceFormat == destFormat && sourcePremultiplied == destPremultiplied && sourceBytesPerPixel == destBytesPerPixel) { var _g3 = 0; var _g12 = destView.height; while(_g3 < _g12) { var y1 = _g3++; sourcePosition = sourceView.row(y1); destPosition = destView.row(y1); destData.set(sourceData.subarray(sourcePosition,sourcePosition + destView.width * destBytesPerPixel),destPosition); } } else { var _g4 = 0; var _g13 = destView.height; while(_g4 < _g13) { var y2 = _g4++; sourcePosition = sourceView.row(y2); destPosition = destView.row(y2); var _g5 = 0; var _g14 = destView.width; while(_g5 < _g14) { var x1 = _g5++; var format3 = sourceFormat; var premultiplied3 = sourcePremultiplied; if(premultiplied3 == null) { premultiplied3 = false; } if(format3 == null) { format3 = 0; } switch(format3) { case 0: sourcePixel = (sourceData[sourcePosition] & 255) << 24 | (sourceData[sourcePosition + 1] & 255) << 16 | (sourceData[sourcePosition + 2] & 255) << 8 | sourceData[sourcePosition + 3] & 255; break; case 1: sourcePixel = (sourceData[sourcePosition + 1] & 255) << 24 | (sourceData[sourcePosition + 2] & 255) << 16 | (sourceData[sourcePosition + 3] & 255) << 8 | sourceData[sourcePosition] & 255; break; case 2: sourcePixel = (sourceData[sourcePosition + 2] & 255) << 24 | (sourceData[sourcePosition + 1] & 255) << 16 | (sourceData[sourcePosition] & 255) << 8 | sourceData[sourcePosition + 3] & 255; break; } if(premultiplied3) { if((sourcePixel & 255) != 0 && (sourcePixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (sourcePixel & 255); sourcePixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | sourcePixel & 255 & 255; } } var format4 = destFormat; var premultiplied4 = destPremultiplied; if(premultiplied4 == null) { premultiplied4 = false; } if(format4 == null) { format4 = 0; } if(premultiplied4) { if((sourcePixel & 255) == 0) { if(sourcePixel != 0) { sourcePixel = 0; } } else if((sourcePixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).a16 = (lime_math__$RGBA_RGBA_$Impl_$().default).__alpha16[sourcePixel & 255]; sourcePixel = ((sourcePixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 24 | ((sourcePixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 16 | ((sourcePixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).a16 >> 16 & 255) << 8 | sourcePixel & 255 & 255; } } switch(format4) { case 0: destData[destPosition] = sourcePixel >>> 24 & 255; destData[destPosition + 1] = sourcePixel >>> 16 & 255; destData[destPosition + 2] = sourcePixel >>> 8 & 255; destData[destPosition + 3] = sourcePixel & 255; break; case 1: destData[destPosition] = sourcePixel & 255; destData[destPosition + 1] = sourcePixel >>> 24 & 255; destData[destPosition + 2] = sourcePixel >>> 16 & 255; destData[destPosition + 3] = sourcePixel >>> 8 & 255; break; case 2: destData[destPosition] = sourcePixel >>> 8 & 255; destData[destPosition + 1] = sourcePixel >>> 16 & 255; destData[destPosition + 2] = sourcePixel >>> 24 & 255; destData[destPosition + 3] = sourcePixel & 255; break; } sourcePosition += 4; destPosition += 4; } } } } else { var alphaData = alphaImage.buffer.data; var alphaFormat = alphaImage.buffer.format; var alphaPosition; var alphaPixel = 0; var alphaView = new (lime__$internal_graphics__$ImageDataUtil_ImageDataView().default)(alphaImage,new (lime_math_Rectangle().default)(sourceView.x + (alphaPoint == null ? 0 : alphaPoint.x),sourceView.y + (alphaPoint == null ? 0 : alphaPoint.y),sourceView.width,sourceView.height)); destView.clip((Std().default).int(destPoint.x),(Std().default).int(destPoint.y),alphaView.width,alphaView.height); if(blend) { var _g6 = 0; var _g15 = destView.height; while(_g6 < _g15) { var y3 = _g6++; sourcePosition = sourceView.row(y3); destPosition = destView.row(y3); alphaPosition = alphaView.row(y3); var _g7 = 0; var _g16 = destView.width; while(_g7 < _g16) { var x2 = _g7++; var format5 = sourceFormat; var premultiplied5 = sourcePremultiplied; if(premultiplied5 == null) { premultiplied5 = false; } if(format5 == null) { format5 = 0; } switch(format5) { case 0: sourcePixel = (sourceData[sourcePosition] & 255) << 24 | (sourceData[sourcePosition + 1] & 255) << 16 | (sourceData[sourcePosition + 2] & 255) << 8 | sourceData[sourcePosition + 3] & 255; break; case 1: sourcePixel = (sourceData[sourcePosition + 1] & 255) << 24 | (sourceData[sourcePosition + 2] & 255) << 16 | (sourceData[sourcePosition + 3] & 255) << 8 | sourceData[sourcePosition] & 255; break; case 2: sourcePixel = (sourceData[sourcePosition + 2] & 255) << 24 | (sourceData[sourcePosition + 1] & 255) << 16 | (sourceData[sourcePosition] & 255) << 8 | sourceData[sourcePosition + 3] & 255; break; } if(premultiplied5) { if((sourcePixel & 255) != 0 && (sourcePixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (sourcePixel & 255); sourcePixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((sourcePixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | sourcePixel & 255 & 255; } } var format6 = destFormat; var premultiplied6 = destPremultiplied; if(premultiplied6 == null) { premultiplied6 = false; } if(format6 == null) { format6 = 0; } switch(format6) { case 0: destPixel = (destData[destPosition] & 255) << 24 | (destData[destPosition + 1] & 255) << 16 | (destData[destPosition + 2] & 255) << 8 | destData[destPosition + 3] & 255; break; case 1: destPixel = (destData[destPosition + 1] & 255) << 24 | (destData[destPosition + 2] & 255) << 16 | (destData[destPosition + 3] & 255) << 8 | destData[destPosition] & 255; break; case 2: destPixel = (destData[destPosition + 2] & 255) << 24 | (destData[destPosition + 1] & 255) << 16 | (destData[destPosition] & 255) << 8 | destData[destPosition + 3] & 255; break; } if(premultiplied6) { if((destPixel & 255) != 0 && (destPixel & 255) != 255) { (lime_math__$RGBA_RGBA_$Impl_$().default).unmult = 255.0 / (destPixel & 255); destPixel = ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 24 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 24 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 16 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 16 | ((lime_math__$RGBA_RGBA_$Impl_$().default).__clamp[Math.round((destPixel >>> 8 & 255) * (lime_math__$RGBA_RGBA_$Impl_$().default).unmult)] & 255) << 8 | destPixel & 255 & 255; } } var format7 = alphaFormat; var premultiplied7 = false; if(premultiplied7 == null) { premultiplied7 = false; } if(format7 == null) { format7 = 0; } switch(format7) { case 0: alphaPixel = (alphaData[alphaPosition] & 255) << 24 | (alphaData[alphaPosition + 1] & 255) << 16 | (alphaData[alphaPosition + 2] & 255) << 8 | alphaData[alphaPosition + 3] & 255; break; case 1: alphaPixel = (alphaData[alphaPosition + 1] & 255) << 24 | (alphaData[alphaPosition + 2] & 255) << 16 | (alphaData[alphaPosition + 3] & 255) << 8 | alphaData[alphaPosition] & 255; break; case 2: alphaPixel = (alphaData[alphaPosition + 2] & 255) << 24 | (alphaData[alphaPosition + 1] & 255) << 16 | (alphaData[alphaPosition] & 255) << 8 | alphaData[alphaPosition + 3] & 255; break; } if(premultiplied7) { if((alphaPixel & 255) != 0 && (alphaPixel & 255) != 255) { (lime_math__$R