diff --git a/lib/src/bitmap_font.dart b/lib/src/bitmap_font.dart index 306da3f8..6b43b446 100644 --- a/lib/src/bitmap_font.dart +++ b/lib/src/bitmap_font.dart @@ -280,7 +280,7 @@ class BitmapFont { var lines = []; lines = content.split('\r\n'); - if(lines.length <= 1) { + if (lines.length <= 1) { lines = content.split('\n'); } diff --git a/lib/src/color.dart b/lib/src/color.dart index 3fb28c49..8ba62e3d 100644 --- a/lib/src/color.dart +++ b/lib/src/color.dart @@ -100,7 +100,9 @@ int getChannel(int color, Channel channel) => channel == Channel.red ? getGreen(color) : channel == Channel.blue ? getBlue(color) - : channel == Channel.alpha ? getAlpha(color) : getLuminance(color); + : channel == Channel.alpha + ? getAlpha(color) + : getLuminance(color); /// Returns a new color, where the given [color]'s [channel] has been /// replaced with the given [value]. @@ -110,7 +112,9 @@ int setChannel(int color, Channel channel, int value) => channel == Channel.red ? setGreen(color, value) : channel == Channel.blue ? setBlue(color, value) - : channel == Channel.alpha ? setAlpha(color, value) : color; + : channel == Channel.alpha + ? setAlpha(color, value) + : color; /// Get the red channel from the [color]. int getRed(int color) => (color) & 0xff; diff --git a/lib/src/draw/draw_string.dart b/lib/src/draw/draw_string.dart index cfcf3266..1235a81d 100644 --- a/lib/src/draw/draw_string.dart +++ b/lib/src/draw/draw_string.dart @@ -63,7 +63,7 @@ Image drawString(Image image, BitmapFont font, int x, int y, String string, } /// Draw a string horizontally into [image] at position -/// [x],[y] with the given [color]. +/// [x],[y] with the given [color]. /// If x is omitted text is automatically centered into [image] /// If y is omitted text is automatically centered into [image]. /// If both x and y are provided it has the same behaviour of drawString method. @@ -83,19 +83,19 @@ Image drawStringCentered(Image image, BitmapFont font, String string, } var ch = font.characters[c]; stringWidth += ch.xadvance; - if(ch.height + ch.yoffset > stringHeight) { + if (ch.height + ch.yoffset > stringHeight) { stringHeight = ch.height + ch.yoffset; } } } int xPos, yPos; - if(x == null) { + if (x == null) { xPos = (image.width / 2).round() - (stringWidth / 2).round(); } else { xPos = x; } - if(y == null) { + if (y == null) { yPos = (image.height / 2).round() - (stringHeight / 2).round(); } else { yPos = y; diff --git a/lib/src/draw/fill_flood.dart b/lib/src/draw/fill_flood.dart index 4999a0f5..3774b1d5 100644 --- a/lib/src/draw/fill_flood.dart +++ b/lib/src/draw/fill_flood.dart @@ -63,8 +63,7 @@ Uint8List maskFlood(Image src, int x, int y, _TestPixel array; if (threshold > 0) { - var lab = - rgbToLab(getRed(srcColor), getGreen(srcColor), getBlue(srcColor)); + var lab = rgbToLab(getRed(srcColor), getGreen(srcColor), getBlue(srcColor)); if (compareAlpha) { lab.add(getAlpha(srcColor).toDouble()); diff --git a/lib/src/formats/exr/exr_compressor.dart b/lib/src/formats/exr/exr_compressor.dart index 0af67a17..29455b9e 100644 --- a/lib/src/formats/exr/exr_compressor.dart +++ b/lib/src/formats/exr/exr_compressor.dart @@ -29,23 +29,18 @@ abstract class ExrCompressor { case RLE_COMPRESSION: return ExrRleCompressor(hdr, maxScanLineSize); case ZIPS_COMPRESSION: - return ExrZipCompressor( - hdr, maxScanLineSize, numScanLines ?? 1); + return ExrZipCompressor(hdr, maxScanLineSize, numScanLines ?? 1); case ZIP_COMPRESSION: - return ExrZipCompressor( - hdr, maxScanLineSize, numScanLines ?? 16); + return ExrZipCompressor(hdr, maxScanLineSize, numScanLines ?? 16); case PIZ_COMPRESSION: - return ExrPizCompressor( - hdr, maxScanLineSize, numScanLines ?? 32); + return ExrPizCompressor(hdr, maxScanLineSize, numScanLines ?? 32); case PXR24_COMPRESSION: - return ExrPxr24Compressor( - hdr, maxScanLineSize, numScanLines ?? 16); + return ExrPxr24Compressor(hdr, maxScanLineSize, numScanLines ?? 16); case B44_COMPRESSION: - return ExrB44Compressor(hdr, maxScanLineSize, - numScanLines ?? 32, false); + return ExrB44Compressor( + hdr, maxScanLineSize, numScanLines ?? 32, false); case B44A_COMPRESSION: - return ExrB44Compressor(hdr, maxScanLineSize, - numScanLines ?? 32, true); + return ExrB44Compressor(hdr, maxScanLineSize, numScanLines ?? 32, true); default: throw ImageException('Invalid compression type: $type'); } diff --git a/lib/src/formats/exr/exr_huffman.dart b/lib/src/formats/exr/exr_huffman.dart index 7498c062..86ee4b80 100644 --- a/lib/src/formats/exr/exr_huffman.dart +++ b/lib/src/formats/exr/exr_huffman.dart @@ -59,8 +59,7 @@ class ExrHuffman { // Access decoding table while (c_lc[1] >= HUF_DECBITS) { - var pl = - hdecod[(c_lc[0] >> (c_lc[1] - HUF_DECBITS)) & HUF_DECMASK]; + var pl = hdecod[(c_lc[0] >> (c_lc[1] - HUF_DECBITS)) & HUF_DECMASK]; if (pl.len != 0) { // Get short code @@ -334,8 +333,7 @@ class ExrHuffman { static const SHORT_ZEROCODE_RUN = 59; static const LONG_ZEROCODE_RUN = 63; - static const SHORTEST_LONG_RUN = - 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN; + static const SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN; static const LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN; } diff --git a/lib/src/formats/exr/exr_piz_compressor.dart b/lib/src/formats/exr/exr_piz_compressor.dart index 6e7e9d49..94686cbf 100644 --- a/lib/src/formats/exr/exr_piz_compressor.dart +++ b/lib/src/formats/exr/exr_piz_compressor.dart @@ -19,8 +19,8 @@ abstract class ExrPizCompressor extends ExrCompressor { @internal class InternalExrPizCompressor extends InternalExrCompressor implements ExrPizCompressor { - InternalExrPizCompressor(ExrPart header, this._maxScanLineSize, - this._numScanLines) + InternalExrPizCompressor( + ExrPart header, this._maxScanLineSize, this._numScanLines) : super(header as InternalExrPart) { _channelData = List<_PizChannelData>(header.channels.length); for (var i = 0; i < _channelData.length; ++i) { @@ -114,8 +114,8 @@ class InternalExrPizCompressor extends InternalExrCompressor // Expand the pixel data to their original range _applyLut(lut, _tmpBuffer, tmpBufferEnd); - _output ??= OutputBuffer( - size: (_maxScanLineSize * _numScanLines) + (65536 + 8192)); + _output ??= + OutputBuffer(size: (_maxScanLineSize * _numScanLines) + (65536 + 8192)); _output.rewind(); diff --git a/lib/src/formats/ico_decoder.dart b/lib/src/formats/ico_decoder.dart index 5aa33946..9526ed58 100644 --- a/lib/src/formats/ico_decoder.dart +++ b/lib/src/formats/ico_decoder.dart @@ -182,15 +182,15 @@ class IcoInfo extends DecodeInfo { } class IcoInfoImage { - IcoInfoImage({ - @required this.width, - @required this.height, - @required this.colorPalette, - @required this.bytesSize, - @required this.bytesOffset, - @required this.colorPlanes, - @required this.bitsPerPixel - }) : assert(width != null), + IcoInfoImage( + {@required this.width, + @required this.height, + @required this.colorPalette, + @required this.bytesSize, + @required this.bytesOffset, + @required this.colorPlanes, + @required this.bitsPerPixel}) + : assert(width != null), assert(height != null), assert(colorPalette != null), assert(bytesSize != null), diff --git a/lib/src/formats/jpeg/_jpeg_quantize_html.dart b/lib/src/formats/jpeg/_jpeg_quantize_html.dart index 377a8355..89b68f83 100644 --- a/lib/src/formats/jpeg/_jpeg_quantize_html.dart +++ b/lib/src/formats/jpeg/_jpeg_quantize_html.dart @@ -8,7 +8,11 @@ import '_component_data.dart'; import 'jpeg_data.dart'; Uint8List _dctClip; -int _clamp8(int i) => i < 0 ? 0 : i > 255 ? 255 : i; +int _clamp8(int i) => i < 0 + ? 0 + : i > 255 + ? 255 + : i; // These functions contain bit-shift operations that fail with HTML builds. // A conditional import is used to use a modified version for HTML builds @@ -376,8 +380,9 @@ Image getImageFromJpeg(JpegData jpeg) { K = component4Line[x4]; C = 255 - _clamp8((Y + 1.402 * (Cr - 128)).toInt()); - M = 255 - _clamp8((Y - 0.3441363 * (Cb - 128) - - 0.71413636 * (Cr - 128)).toInt()); + M = 255 - + _clamp8((Y - 0.3441363 * (Cb - 128) - 0.71413636 * (Cr - 128)) + .toInt()); Ye = 255 - _clamp8((Y + 1.772 * (Cb - 128)).toInt()); } R = shiftR((C * K), 8); diff --git a/lib/src/formats/jpeg/_jpeg_quantize_io.dart b/lib/src/formats/jpeg/_jpeg_quantize_io.dart index e19fa7db..1ff1dca1 100644 --- a/lib/src/formats/jpeg/_jpeg_quantize_io.dart +++ b/lib/src/formats/jpeg/_jpeg_quantize_io.dart @@ -7,7 +7,11 @@ import '_component_data.dart'; import 'jpeg_data.dart'; Uint8List _dctClip; -int _clamp8(int i) => i < 0 ? 0 : i > 255 ? 255 : i; +int _clamp8(int i) => i < 0 + ? 0 + : i > 255 + ? 255 + : i; // Quantize the coefficients and apply IDCT. // @@ -370,8 +374,9 @@ Image getImageFromJpeg(JpegData jpeg) { K = component4Line[x4]; C = 255 - _clamp8((Y + 1.402 * (Cr - 128)).toInt()); - M = 255 - _clamp8((Y - 0.3441363 * (Cb - 128) - - 0.71413636 * (Cr - 128)).toInt()); + M = 255 - + _clamp8((Y - 0.3441363 * (Cb - 128) - 0.71413636 * (Cr - 128)) + .toInt()); Ye = 255 - _clamp8((Y + 1.772 * (Cb - 128)).toInt()); } R = (C * K) >> 8; diff --git a/lib/src/formats/jpeg/jpeg.dart b/lib/src/formats/jpeg/jpeg.dart index 1686240c..9d6f9de6 100644 --- a/lib/src/formats/jpeg/jpeg.dart +++ b/lib/src/formats/jpeg/jpeg.dart @@ -16,8 +16,7 @@ class Jpeg { static const DCTSIZE2 = 64; // DCTSIZE squared; # of elements in a block static const NUM_QUANT_TBLS = 4; // Quantization tables are numbered 0..3 static const NUM_HUFF_TBLS = 4; // Huffman tables are numbered 0..3 - static const NUM_ARITH_TBLS = - 16; // Arith-coding tables are numbered 0..15 + static const NUM_ARITH_TBLS = 16; // Arith-coding tables are numbered 0..15 static const MAX_COMPS_IN_SCAN = 4; // JPEG limit on # of components in one scan static const MAX_SAMP_FACTOR = 4; // JPEG limit on sampling factors diff --git a/lib/src/formats/jpeg/jpeg_data.dart b/lib/src/formats/jpeg/jpeg_data.dart index 73a2d1a1..0f67c507 100644 --- a/lib/src/formats/jpeg/jpeg_data.dart +++ b/lib/src/formats/jpeg/jpeg_data.dart @@ -50,7 +50,7 @@ class JpegData { break; } input.offset += sectionByteSize - 2; - + switch (marker) { case Jpeg.M_SOF0: // SOF0 (Start of Frame, Baseline DCT) case Jpeg.M_SOF1: // SOF1 (Start of Frame, Extended DCT) @@ -319,7 +319,7 @@ class JpegData { return block.readInt16(); case FMT_SLONG: return block.readInt32(); - // Not sure if this is correct (never seen float used in Exif format) + // Not sure if this is correct (never seen float used in Exif format) case FMT_SINGLE: return block.readFloat32(); case FMT_DOUBLE: diff --git a/lib/src/formats/jpeg_encoder.dart b/lib/src/formats/jpeg_encoder.dart index 94e095c9..829189e0 100644 --- a/lib/src/formats/jpeg_encoder.dart +++ b/lib/src/formats/jpeg_encoder.dart @@ -92,15 +92,21 @@ class JpegEncoder extends Encoder { // calculate YUV values YDU[pos] = ((RGB_YUV_TABLE[r] + RGB_YUV_TABLE[(g + 256)] + - RGB_YUV_TABLE[(b + 512)]) >> 16) - 128.0; + RGB_YUV_TABLE[(b + 512)]) >> + 16) - + 128.0; UDU[pos] = ((RGB_YUV_TABLE[(r + 768)] + RGB_YUV_TABLE[(g + 1024)] + - RGB_YUV_TABLE[(b + 1280)]) >> 16) - 128.0; + RGB_YUV_TABLE[(b + 1280)]) >> + 16) - + 128.0; VDU[pos] = ((RGB_YUV_TABLE[(r + 1280)] + RGB_YUV_TABLE[(g + 1536)] + - RGB_YUV_TABLE[(b + 1792)]) >> 16) - 128.0; + RGB_YUV_TABLE[(b + 1792)]) >> + 16) - + 128.0; } DCY = _processDU(fp, YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); diff --git a/lib/src/formats/png_decoder.dart b/lib/src/formats/png_decoder.dart index 94a095c1..f039212c 100644 --- a/lib/src/formats/png_decoder.dart +++ b/lib/src/formats/png_decoder.dart @@ -402,7 +402,11 @@ class PngDecoder extends Decoder { int xStep, int yStep, int passWidth, int passHeight) { final channels = (_info.colorType == GRAYSCALE_ALPHA) ? 2 - : (_info.colorType == RGB) ? 3 : (_info.colorType == RGBA) ? 4 : 1; + : (_info.colorType == RGB) + ? 3 + : (_info.colorType == RGBA) + ? 4 + : 1; final pixelDepth = channels * _info.bits; final bpp = (pixelDepth + 7) >> 3; @@ -461,7 +465,11 @@ class PngDecoder extends Decoder { void _process(InputBuffer input, Image image) { final channels = (_info.colorType == GRAYSCALE_ALPHA) ? 2 - : (_info.colorType == RGB) ? 3 : (_info.colorType == RGBA) ? 4 : 1; + : (_info.colorType == RGB) + ? 3 + : (_info.colorType == RGBA) + ? 4 + : 1; final pixelDepth = channels * _info.bits; @@ -617,7 +625,11 @@ class PngDecoder extends Decoder { ? 3 : (numBits == 4) ? 0xf - : (numBits == 8) ? 0xff : (numBits == 16) ? 0xffff : 0; + : (numBits == 8) + ? 0xff + : (numBits == 16) + ? 0xffff + : 0; var octet = (_bitBuffer >> (_bitBufferLen - numBits)) & mask; diff --git a/lib/src/formats/psd/psd_image.dart b/lib/src/formats/psd/psd_image.dart index 92dcda55..420b4764 100644 --- a/lib/src/formats/psd/psd_image.dart +++ b/lib/src/formats/psd/psd_image.dart @@ -523,7 +523,11 @@ class PsdImage extends DecodeInfo { } var numChannels = channelList.length; - var ns = (bitDepth == 8) ? 1 : (bitDepth == 16) ? 2 : -1; + var ns = (bitDepth == 8) + ? 1 + : (bitDepth == 16) + ? 2 + : -1; if (ns == -1) { throw ImageException('PSD: unsupported bit depth: $bitDepth'); } diff --git a/lib/src/formats/webp/vp8.dart b/lib/src/formats/webp/vp8.dart index dedafb52..574c04cb 100644 --- a/lib/src/formats/webp/vp8.dart +++ b/lib/src/formats/webp/vp8.dart @@ -173,7 +173,11 @@ class VP8 { } } - _filterType = (hdr.level == 0) ? 0 : hdr.simple ? 1 : 2; + _filterType = (hdr.level == 0) + ? 0 + : hdr.simple + ? 1 + : 2; return true; } @@ -314,7 +318,11 @@ class VP8 { } } - level = (level < 0) ? 0 : (level > 63) ? 63 : level; + level = (level < 0) + ? 0 + : (level > 63) + ? 63 + : level; if (level > 0) { var ilevel = level; if (hdr.sharpness > 0) { @@ -335,7 +343,11 @@ class VP8 { info.fInnerLevel = ilevel; info.fLimit = 2 * level + ilevel; - info.hevThresh = (level >= 40) ? 2 : (level >= 15) ? 1 : 0; + info.hevThresh = (level >= 40) + ? 2 + : (level >= 15) + ? 1 + : 0; } else { info.fLimit = 0; // no filtering } @@ -847,7 +859,11 @@ class VP8 { } int _clip8(int v) { - var d = ((v & XOR_YUV_MASK2) == 0) ? (v >> YUV_FIX2) : (v < 0) ? 0 : 255; + var d = ((v & XOR_YUV_MASK2) == 0) + ? (v >> YUV_FIX2) + : (v < 0) + ? 0 + : 255; return d; } @@ -966,8 +982,7 @@ class VP8 { alpha.offset -= webp.width; } - var dst = - InputBuffer(output.getBytes(), offset: startY * stride + 3); + var dst = InputBuffer(output.getBytes(), offset: startY * stride + 3); if (_cropTop + mbY + mbH == _cropBottom) { // If it's the very last call, we process all the remaining rows! @@ -987,8 +1002,7 @@ class VP8 { int _emitFancyRGB(int mbY, int mbW, int mbH) { var numLinesOut = mbH; // a priori guess - var dst = - InputBuffer(output.getBytes(), offset: mbY * webp.width * 4); + var dst = InputBuffer(output.getBytes(), offset: mbY * webp.width * 4); var curY = InputBuffer.from(_y); var curU = InputBuffer.from(_u); var curV = InputBuffer.from(_v); @@ -1242,7 +1256,11 @@ class VP8 { int _nzCodeBits(int nz_coeffs, int nz, int dc_nz) { nz_coeffs <<= 2; - nz_coeffs |= (nz > 3) ? 3 : (nz > 1) ? 2 : dc_nz; + nz_coeffs |= (nz > 3) + ? 3 + : (nz > 1) + ? 2 + : dc_nz; return nz_coeffs; } @@ -1419,7 +1437,11 @@ class VP8 { // Hardcoded UVMode decision tree block.uvmode = br.getBit(142) == 0 ? DC_PRED - : br.getBit(114) == 0 ? V_PRED : br.getBit(183) != 0 ? TM_PRED : H_PRED; + : br.getBit(114) == 0 + ? V_PRED + : br.getBit(183) != 0 + ? TM_PRED + : H_PRED; } // Main data source @@ -1542,7 +1564,11 @@ class VP8 { //Uint8List _layerData; static int _clip(int v, int M) { - return v < 0 ? 0 : v > M ? M : v; + return v < 0 + ? 0 + : v > M + ? M + : v; } static const kYModesIntra4 = [ @@ -2142,7 +2168,6 @@ class VP8 { static const kVToG = 13320; // 0.813 = 255 / 112 * 0.701 * 0.299 / 0.587 static const kUToB = 33050; // 2.018 = 255 / 112 * 0.886 static const kRCst = (-kYScale * 16 - kVToR * 128 + YUV_HALF2); - static const kGCst = - (-kYScale * 16 + kUToG * 128 + kVToG * 128 + YUV_HALF2); + static const kGCst = (-kYScale * 16 + kUToG * 128 + kVToG * 128 + YUV_HALF2); static const kBCst = (-kYScale * 16 - kUToB * 128 + YUV_HALF2); } diff --git a/lib/src/formats/webp/vp8_filter.dart b/lib/src/formats/webp/vp8_filter.dart index 3c3075c4..2d0f5d61 100644 --- a/lib/src/formats/webp/vp8_filter.dart +++ b/lib/src/formats/webp/vp8_filter.dart @@ -691,20 +691,36 @@ class VP8Filter { abs1[255 + i] = abs0[255 + i] >> 1; } for (var i = -1020; i <= 1020; ++i) { - sclip1[1020 + i] = (i < -128) ? -128 : (i > 127) ? 127 : i; + sclip1[1020 + i] = (i < -128) + ? -128 + : (i > 127) + ? 127 + : i; } for (var i = -112; i <= 112; ++i) { - sclip2[112 + i] = (i < -16) ? -16 : (i > 15) ? 15 : i; + sclip2[112 + i] = (i < -16) + ? -16 + : (i > 15) + ? 15 + : i; } for (var i = -255; i <= 255 + 255; ++i) { - clip1[255 + i] = (i < 0) ? 0 : (i > 255) ? 255 : i; + clip1[255 + i] = (i < 0) + ? 0 + : (i > 255) + ? 255 + : i; } _tablesInitialized = true; } } static int _clip8b(int v) { - return ((v & -256) == 0) ? v : (v < 0) ? 0 : 255; + return ((v & -256) == 0) + ? v + : (v < 0) + ? 0 + : 255; } //static int __maxN = 0; diff --git a/lib/src/formats/webp/vp8l.dart b/lib/src/formats/webp/vp8l.dart index b26b7bb1..bc17eb5a 100644 --- a/lib/src/formats/webp/vp8l.dart +++ b/lib/src/formats/webp/vp8l.dart @@ -121,7 +121,11 @@ class VP8L { final numColors = br.readBits(8) + 1; final bits = (numColors > 16) ? 0 - : (numColors > 4) ? 1 : (numColors > 2) ? 2 : 3; + : (numColors > 4) + ? 1 + : (numColors > 2) + ? 2 + : 3; transformSize[0] = _subSampleSize(transform.xsize, bits); transform.bits = bits; transform.data = _decodeImageStream(numColors, 1, false); diff --git a/lib/src/formats/webp/vp8l_transform.dart b/lib/src/formats/webp/vp8l_transform.dart index 015b5f75..2ab2c8f3 100644 --- a/lib/src/formats/webp/vp8l_transform.dart +++ b/lib/src/formats/webp/vp8l_transform.dart @@ -302,12 +302,9 @@ class VP8LTransform { static int _clampedAddSubtractHalf(int c0, int c1, int c2) { final avg = _average2(c0, c1); final a = _addSubtractComponentHalf(avg >> 24, c2 >> 24); - final r = - _addSubtractComponentHalf((avg >> 16) & 0xff, (c2 >> 16) & 0xff); - final g = - _addSubtractComponentHalf((avg >> 8) & 0xff, (c2 >> 8) & 0xff); - final b = - _addSubtractComponentHalf((avg >> 0) & 0xff, (c2 >> 0) & 0xff); + final r = _addSubtractComponentHalf((avg >> 16) & 0xff, (c2 >> 16) & 0xff); + final g = _addSubtractComponentHalf((avg >> 8) & 0xff, (c2 >> 8) & 0xff); + final b = _addSubtractComponentHalf((avg >> 0) & 0xff, (c2 >> 0) & 0xff); return (a << 24) | (r << 16) | (g << 8) | b; } diff --git a/lib/src/formats/webp/webp_filters.dart b/lib/src/formats/webp/webp_filters.dart index eb70ebf8..6b2e3188 100644 --- a/lib/src/formats/webp/webp_filters.dart +++ b/lib/src/formats/webp/webp_filters.dart @@ -138,7 +138,11 @@ class WebPFilters { static int _gradientPredictor(int a, int b, int c) { final g = a + b - c; - return ((g & ~0xff) == 0) ? g : (g < 0) ? 0 : 255; // clip to 8bit + return ((g & ~0xff) == 0) + ? g + : (g < 0) + ? 0 + : 255; // clip to 8bit } static void _doGradientFilter(Uint8List src, int width, int height, diff --git a/lib/src/formats/webp_decoder.dart b/lib/src/formats/webp_decoder.dart index 8c3fa39f..eefd720a 100644 --- a/lib/src/formats/webp_decoder.dart +++ b/lib/src/formats/webp_decoder.dart @@ -91,19 +91,16 @@ class WebPDecoder extends Decoder { } final f = _info.frames[frame] as InternalWebPFrame; - final frameData = - _input.subset(f.frameSize, position: f.framePosition); + final frameData = _input.subset(f.frameSize, position: f.framePosition); return _decodeFrame(frameData, frame: frame); } if (_info.format == WebPInfo.FORMAT_LOSSLESS) { - final data = - _input.subset(_info.vp8Size, position: _info.vp8Position); + final data = _input.subset(_info.vp8Size, position: _info.vp8Position); return VP8L(data, _info).decode(); } else if (_info.format == WebPInfo.FORMAT_LOSSY) { - final data = - _input.subset(_info.vp8Size, position: _info.vp8Position); + final data = _input.subset(_info.vp8Size, position: _info.vp8Position); return VP8(data, _info).decode(); } @@ -193,8 +190,7 @@ class WebPDecoder extends Decoder { return null; } final f = webp.frames[frame] as InternalWebPFrame; - final frameData = - input.subset(f.frameSize, position: f.framePosition); + final frameData = input.subset(f.frameSize, position: f.framePosition); return _decodeFrame(frameData, frame: frame); } else { diff --git a/lib/src/hdr/half.dart b/lib/src/hdr/half.dart index b044e0ab..0f9872c3 100644 --- a/lib/src/hdr/half.dart +++ b/lib/src/hdr/half.dart @@ -76,23 +76,39 @@ class Half { /// Addition operator for Half or num left operands. Half operator +(dynamic f) { - var d = (f is Half) ? f.toDouble() : (f is num) ? f.toDouble() : 0; + var d = (f is Half) + ? f.toDouble() + : (f is num) + ? f.toDouble() + : 0; return Half(toDouble() + d); } /// Subtraction operator for Half or num left operands. Half operator -(dynamic f) { - var d = (f is Half) ? f.toDouble() : (f is num) ? f.toDouble() : 0; + var d = (f is Half) + ? f.toDouble() + : (f is num) + ? f.toDouble() + : 0; return Half(toDouble() - d.toDouble()); } Half operator *(dynamic f) { - var d = (f is Half) ? f.toDouble() : (f is num) ? f.toDouble() : 0; + var d = (f is Half) + ? f.toDouble() + : (f is num) + ? f.toDouble() + : 0; return Half(toDouble() * d.toDouble()); } Half operator /(dynamic f) { - var d = (f is Half) ? f.toDouble() : (f is num) ? f.toDouble() : 0; + var d = (f is Half) + ? f.toDouble() + : (f is num) + ? f.toDouble() + : 0; return Half(toDouble() / d.toDouble()); } diff --git a/lib/src/image.dart b/lib/src/image.dart index b272aa0a..e09d3ffc 100644 --- a/lib/src/image.dart +++ b/lib/src/image.dart @@ -572,12 +572,11 @@ class Image { return bytes is Uint32List ? bytes.sublist(0) : bytes is Uint8List - ? Uint32List.view(bytes.buffer).sublist(0) - : Uint32List.view(Uint8List.fromList(bytes).buffer); + ? Uint32List.view(bytes.buffer).sublist(0) + : Uint32List.view(Uint8List.fromList(bytes).buffer); } - var input = - bytes is Uint32List ? Uint8List.view(bytes.buffer) : bytes; + var input = bytes is Uint32List ? Uint8List.view(bytes.buffer) : bytes; var data = Uint32List(width * height); var rgba = Uint8List.view(data.buffer); diff --git a/lib/src/transform/trim.dart b/lib/src/transform/trim.dart index 20652d93..01834e20 100644 --- a/lib/src/transform/trim.dart +++ b/lib/src/transform/trim.dart @@ -48,7 +48,9 @@ List findTrim(Image src, final bg = (mode == TrimMode.topLeftColor) ? src.getPixel(0, 0) - : (mode == TrimMode.bottomRightColor) ? src.getPixel(w - 1, h - 1) : 0; + : (mode == TrimMode.bottomRightColor) + ? src.getPixel(w - 1, h - 1) + : 0; var xmin = w; var xmax = 0; diff --git a/lib/src/util/input_buffer.dart b/lib/src/util/input_buffer.dart index 55db2284..14a13ef1 100644 --- a/lib/src/util/input_buffer.dart +++ b/lib/src/util/input_buffer.dart @@ -242,10 +242,10 @@ class InputBuffer { b.buffer, b.offsetInBytes + this.offset + offset, len); } return (buffer is Uint8List) - ? (buffer as Uint8List).sublist(this.offset + offset, - this.offset + offset + len) - : Uint8List.fromList(buffer.sublist(this.offset + offset, - this.offset + offset + len)); + ? (buffer as Uint8List) + .sublist(this.offset + offset, this.offset + offset + len) + : Uint8List.fromList( + buffer.sublist(this.offset + offset, this.offset + offset + len)); } Uint32List toUint32List([int offset = 0]) { diff --git a/lib/src/util/octree_quantizer.dart b/lib/src/util/octree_quantizer.dart index a7ede1b6..b8ace51b 100644 --- a/lib/src/util/octree_quantizer.dart +++ b/lib/src/util/octree_quantizer.dart @@ -67,7 +67,11 @@ class OctreeQuantizer extends Quantizer { var ac = a.count >> a.depth; var bc = b.count >> b.depth; - return (ac < bc) ? -1 : (ac > bc) ? 1 : 0; + return (ac < bc) + ? -1 + : (ac > bc) + ? 1 + : 0; } _OctreeNode _nodeInsert(_OctreeNode root, int r, int g, int b) { diff --git a/lib/src/util/output_buffer.dart b/lib/src/util/output_buffer.dart index a5a54313..ecd80853 100644 --- a/lib/src/util/output_buffer.dart +++ b/lib/src/util/output_buffer.dart @@ -100,7 +100,9 @@ class OutputBuffer { void _expandBuffer([int required]) { final blockSize = (required != null) ? required - : (_buffer.isEmpty) ? _BLOCK_SIZE : (_buffer.length * 2); + : (_buffer.isEmpty) + ? _BLOCK_SIZE + : (_buffer.length * 2); final newBuffer = Uint8List(_buffer.length + blockSize); newBuffer.setRange(0, _buffer.length, _buffer); _buffer = newBuffer; diff --git a/test/cur_test.dart b/test/cur_test.dart index d4bbd5dd..6ebaaade 100644 --- a/test/cur_test.dart +++ b/test/cur_test.dart @@ -19,9 +19,8 @@ void main() { final image2 = Image(64, 64); image2.fill(getColor(100, 255, 200)); - final png2 = - CurEncoder(hotSpots: {1: Point(64, 64), 0: Point(64, 64)}) - .encodeImages([image, image2]); + final png2 = CurEncoder(hotSpots: {1: Point(64, 64), 0: Point(64, 64)}) + .encodeImages([image, image2]); File('.dart_tool/out/cur/encode2.cur') ..createSync(recursive: true) ..writeAsBytesSync(png2); diff --git a/test/exr_test.dart b/test/exr_test.dart index 246b7684..33e1a25e 100644 --- a/test/exr_test.dart +++ b/test/exr_test.dart @@ -27,7 +27,8 @@ void main() { hdrGamma(hdr, gamma: 2.2); //hdrBloom(hdr, radius: 0.2); img2 = hdrToImage(hdr); - File('.dart_tool/out/exr/lenna_gamma.png').writeAsBytesSync(encodePng(img2)); + File('.dart_tool/out/exr/lenna_gamma.png') + .writeAsBytesSync(encodePng(img2)); }); }); } diff --git a/test/filter_test.dart b/test/filter_test.dart index 9402bc2b..345586ba 100644 --- a/test/filter_test.dart +++ b/test/filter_test.dart @@ -122,8 +122,8 @@ void main() { fill(src, getColor(255, 0, 0)); drawImage(src, dst, blend: false); File('.dart_tool/out/drawImage.jpg') - ..createSync(recursive: true) - ..writeAsBytesSync(writeJpg(src)); + ..createSync(recursive: true) + ..writeAsBytesSync(writeJpg(src)); }); test('brightness', () { diff --git a/web/filter_lab.dart b/web/filter_lab.dart index e4c1cb37..1b9e0d2d 100644 --- a/web/filter_lab.dart +++ b/web/filter_lab.dart @@ -6,8 +6,8 @@ CanvasElement canvas; DivElement logDiv; Image origImage; -void _addControl(String label, String value, DivElement parent, - dynamic callback) { +void _addControl( + String label, String value, DivElement parent, dynamic callback) { var amountLabel = LabelElement(); amountLabel.text = label + ':'; var amountEdit = InputElement(); diff --git a/web/test_formats.dart b/web/test_formats.dart index d6b17165..807d480d 100644 --- a/web/test_formats.dart +++ b/web/test_formats.dart @@ -73,8 +73,8 @@ void main() { // Create a buffer that the canvas can draw. var d = c.context2D.createImageData(c.width, c.height); // Fill the buffer with our image data. - d.data.setRange(0, d.data.length, - newImage.getBytes(format: Format.rgba)); + d.data.setRange( + 0, d.data.length, newImage.getBytes(format: Format.rgba)); // Draw the buffer onto the canvas. c.context2D.putImageData(d, 0, 0);