Determine the source pixel location

@param dest
destination pixel location
@param destMin
destination minimum most pixel
@param srcMin
source minimum most pixel
@param ratio
source over destination length ratio
@return source pixel
961039
private float getSource(float dest, float destMin, float srcMin, float ratio) {

		float destDistance = dest - destMin;
		float srcDistance = destDistance * ratio;
		float ySource = srcMin + srcDistance;

		return ySource;
	}
693681
public static int Minimum(ImageSource fastBitmap, int startX, int startY, int width, int height) {
        int min = 255;
        if (fastBitmap.isGrayscale()) {
            for (int i = startX; i < height; i++) {
                for (int j = startY; j < width; j++) {
                    int gray = fastBitmap.getRGB(j, i);
                    if (gray < min) {
                        min = gray;
                    }
                }
            }
        } else {
            for (int i = startX; i < height; i++) {
                for (int j = startY; j < width; j++) {
                    int gray = fastBitmap.getG(j, i);
                    if (gray < min) {
                        min = gray;
                    }
                }
            }
        }
        return min;
    }
193410
public static void scaleFill(Bitmap src, Bitmap dest, int clearColor) {
        float ratio = Math.max(dest.getWidth() / (float) src.getWidth(), dest.getHeight() / (float) src.getHeight());
        int newW = (int) (src.getWidth() * ratio);
        int newH = (int) (src.getHeight() * ratio);
        int paddingTop = (dest.getHeight() - (int) (src.getHeight() * ratio)) / 2;
        int paddingLeft = (dest.getWidth() - (int) (src.getWidth() * ratio)) / 2;

        scale(src, dest, clearColor, 0, 0, src.getWidth(), src.getHeight(), paddingLeft, paddingTop,
                newW + paddingLeft,
                newH + paddingTop);
    }
31064
protected float getYSource(int y, float destTop, float srcTop,
			float heightRatio) {

		float dest = getYEncodedLocation(y, encoding);
		float source = getSource(dest, destTop, srcTop, heightRatio);

		return source;
	}
443093
public final void pcmpestri(XMMRegister dst, XMMRegister src, Immediate imm8)
  {
    emitX86(INST_PCMPESTRI, dst, src, imm8);
  }
906443
private int getSourcePixel(int[] srcImage, int x, int y)
    {
        int x1 = Math.max(0, x);
        x1 = Math.min(width - 1, x1);
        int y1 = Math.max(0, y);
        y1 = Math.min(height - 1, y1);

        return srcImage[x1 + y1 * width];
    }
1034455
public static ByteBuffer copy(ByteBuffer src, ByteBuffer dest) {
		return copy(src, dest, Math.min(src.limit(), dest.remaining()));
	}
667279
public void toNormalImage(String src, String dest) {
        toNormalImage(new File(src), new File(dest));
    }
935214
public static void bufferedToGray(DataBufferUShort buffer , WritableRaster src, GrayI16 dst) {
		short[] srcData = buffer.getData();

		int numBands = src.getNumBands();

		int size = dst.getWidth() * dst.getHeight();

		int srcStride = stride(src);
		int srcOffset = getOffset(src);
		int srcStrideDiff = srcStride-src.getNumDataElements()*dst.width;

		if (numBands == 1) {
			if (dst.startIndex == 0 && dst.width == dst.stride && srcStrideDiff == 0 && srcOffset == 0 )
				System.arraycopy(srcData, 0, dst.data, 0, size);
			else {
				//CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.height, y -> {
				for (int y = 0; y < dst.height; y++) {
					int indexDst = dst.startIndex + dst.stride * y;
					int indexSrc = srcOffset + srcStride * y;

					System.arraycopy(srcData, indexSrc, dst.data, indexDst, dst.width);
				}
				//CONCURRENT_ABOVE });
			}
		} else {
			throw new RuntimeException("Only single band images are currently support for 16bit");
		}
	}
747326
function (source, destination) {
      if (!source) return null;

      destination = destination || {};

      angular.forEach('left top right bottom width height'.split(' '), function (key) {
        destination[key] = Math.round(source[key]);
      });

      destination.width = destination.width || (destination.right - destination.left);
      destination.height = destination.height || (destination.bottom - destination.top);

      return destination;
    }
996835
public static function copyRecDir($source, $dest) {
    if (!is_dir($dest)) {
      self::mkdirRec($dest);
    }
    $dir = opendir($source);
    while ($file = readdir($dir)) {
      if ($file == "." || $file == "..") {
        continue;
      }
      self::copyRec("$source/$file", "$dest/$file");
    }
    closedir($dir);
  }
1214395
public static void copyMemory(final Object src, long srcOffset, final Object dest,
      final long destOffset, final long len) {

    // TODO make this work if destOffset is not STRIDE aligned
    Preconditions.checkNotNull(src);
    Preconditions.checkArgument(len % COPY_STRIDE != 0, "Length (%d) is not a multiple of stride", len);

    Preconditions.checkArgument(destOffset % COPY_STRIDE != 0,
        "Dest offset (%d) is not stride aligned", destOffset);

    long end = destOffset + len;
    for (long offset = destOffset; offset < end; ) {
      unsafe.putLong(dest, offset, unsafe.getLong(srcOffset));
      offset += COPY_STRIDE;
      srcOffset += COPY_STRIDE;
    }
  }
734050
public static BufferedImage createTracedImage (
        ImageCreator isrc, BufferedImage src, Color tcolor, int thickness)
    {
        return createTracedImage(isrc, src, tcolor, thickness, 1.0f, 1.0f);
    }
862453
public final void cmpss(XMMRegister dst, Mem src, Immediate imm8)
  {
    emitX86(INST_CMPSS, dst, src, imm8);
  }
1172713
public BufferedImage filter(BufferedImage src, BufferedImage dest) {
        if (dest == null) {
            dest = createCompatibleDestImage(src, null);
        }

        // Make grayscale
        BufferedImage image = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), getRenderingHints()).filter(src, null);

        // Make image faded/too bright
        image = new RescaleOp(1.2f, 120f, getRenderingHints()).filter(image, image);

        // Blur
        image = ImageUtil.blur(image, 2.5f);

        Graphics2D g = dest.createGraphics();
        try {
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            g.drawImage(image, 0, 0, null);

            // Rotate it slightly for a more analogue feeling
            double angle = .0055;
            g.rotate(angle);

            // Apply fake green-ish h-sync line at random position
            Random random = new Random();
            int lineStart = random.nextInt(image.getHeight() - 80);
            int lineHeight = random.nextInt(10) + 20;

            g.setComposite(AlphaComposite.SrcOver.derive(.3f));
            g.setPaint(new LinearGradientPaint(
                    0, lineStart, 0, lineStart + lineHeight,
                    new float[] {0, .3f, .9f, 1},
                    new Color[] {new Color(0, true), new Color(0x90AF66), new Color(0x99606F33, true), new Color(0, true)}
            ));
            g.fillRect(0, lineStart, image.getWidth(), lineHeight);

            // Apply fake large dot-pitch (black lines w/transparency)
            g.setComposite(AlphaComposite.SrcOver.derive(.55f));
            g.setColor(Color.BLACK);

            for (int y = 0; y < image.getHeight(); y += 3) {
                g.setStroke(new BasicStroke(random.nextFloat() / 3 + .8f));
                g.drawLine(0, y, image.getWidth(), y);
            }

            // Vignette/border
            g.setComposite(AlphaComposite.SrcOver.derive(.75f));
            int focus = Math.min(image.getWidth() / 8, image.getHeight() / 8);
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.6f,
                    new Point(focus, focus),
                    new float[] {0, .3f, .9f, 1f},
                    new Color[] {new Color(0x99FFFFFF, true), new Color(0x00FFFFFF, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(-2, -2, image.getWidth() + 4, image.getHeight() + 4);

            g.rotate(-angle);

            g.setComposite(AlphaComposite.SrcOver.derive(.35f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.65f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .85f, 1f},
                    new Color[] {new Color(0x0, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());

            // Highlight
            g.setComposite(AlphaComposite.SrcOver.derive(.55f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth(), image.getHeight()),
                    Math.max(image.getWidth(), image.getHeight()) * 1.1f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .75f, 1f},
                    new Color[] {new Color(0x00FFFFFF, true), new Color(0x00FFFFFF, true), Color.WHITE},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
        }
        finally {
            g.dispose();
        }

        // Round corners
        BufferedImage foo = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = foo.createGraphics();
        try {
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            graphics.setColor(Color.WHITE);
            double angle = -0.04;
            g.rotate(angle);
            graphics.fillRoundRect(1, 1, image.getWidth() - 2, image.getHeight() - 2, 20, 20);
        }
        finally {
            graphics.dispose();
        }

        foo = ImageUtil.blur(foo, 4.5f);

        // Compose image into rounded corners
        graphics = foo.createGraphics();
        try {
            graphics.setComposite(AlphaComposite.SrcIn);
            graphics.drawImage(dest, 0, 0, null);
        }
        finally {
            graphics.dispose();
        }

        // Draw it all back to dest
        g = dest.createGraphics();
        try {
            g.setComposite(AlphaComposite.SrcOver);
            g.setColor(Color.BLACK);
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            g.drawImage(foo, 0, 0, null);
        }
        finally {
            g.dispose();
        }

        return dest;
    }
509787
function assignDeep(dest, source) {
	if (source && source.constructor === Object) {
		var sourceBaseKeys = Object.keys(source);

		for (var i = 0; i < sourceBaseKeys.length; ++i) {
			var sourceBaseKey = sourceBaseKeys[i];
			var destinationField = dest[sourceBaseKey];
			var sourceField = source[sourceBaseKey];

			if (destinationField === undefined) {
				dest[sourceBaseKey] = sourceField;
			} else {
				// Recursive assign.
				assignDeep(destinationField, sourceField);
			}
		}
	}
}
130733
@Override
    public BufferedImage filter(BufferedImage src, BufferedImage dest) {
        if (dest == null) {
            dest = createCompatibleDestImage(src, null);
        }

        BufferedImage image = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), getRenderingHints()).filter(src, dest);

        Graphics2D g2d = dest.createGraphics();
        try {
            g2d.drawImage(image, 0, 0, null);
        }
        finally {
            g2d.dispose();
        }

        // Blur
        image = ImageUtil.blur(image, 2.5f);

        Graphics2D g = dest.createGraphics();
        try {
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            g.drawImage(image, 0, 0, null);

            // Rotate it slightly for a more analogue feeling
            double angle = -.0055;
            g.rotate(angle);

            // Vignette/border
            g.setComposite(AlphaComposite.SrcOver.derive(.35f));
            g.setPaint(new RadialGradientPaint(
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    Math.max(image.getWidth(), image.getHeight()) / 1.65f,
                    new Point(image.getWidth() / 2, image.getHeight() / 2),
                    new float[] {0, .85f, 1f},
                    new Color[] {new Color(0x0, true), new Color(0x0, true), Color.BLACK},
                    MultipleGradientPaint.CycleMethod.NO_CYCLE
            ));
            g.fillRect(0, 0, image.getWidth(), image.getHeight());

        }
        finally {
            g.dispose();
        }

        // Round corners
        BufferedImage foo = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = foo.createGraphics();
        try {
            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            graphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
            graphics.setColor(Color.WHITE);
            double angle = (random.nextDouble() * .01) - .005;
            graphics.rotate(angle);
            graphics.fillRoundRect(4, 4, image.getWidth() - 8, image.getHeight() - 8, 20, 20);
        }
        finally {
            graphics.dispose();
        }

        // Noise
        NoiseFilter noise = new NoiseFilter();
        noise.setAmount(20);
        noise.setDensity(1);
        noise.setMonochrome(true);
        foo = noise.filter(foo, foo);

        foo = ImageUtil.blur(foo, 4.5f);

        // Compose image into rounded corners
        graphics = foo.createGraphics();
        try {
            graphics.setComposite(AlphaComposite.SrcIn);
            graphics.drawImage(dest, 0, 0, null);
        }
        finally {
            graphics.dispose();
        }

        float[] scales = new float[] {1, 1, 1, 1};
        float[] offsets = new float[] {80, 40, 0, 0};
        foo = new RescaleOp(scales, offsets, getRenderingHints()).filter(foo, foo);

        // Draw it all back to dest
        g = dest.createGraphics();
        try {
            g.setComposite(AlphaComposite.SrcOver);
            g.setColor(Color.WHITE);
            g.fillRect(0, 0, image.getWidth(), image.getHeight());
            g.drawImage(foo, 0, 0, null);
        }
        finally {
            g.dispose();
        }

        return dest;
    }