Here you can find the source of changeContrast(BufferedImage img, float amount)
Parameter | Description |
---|---|
img | a parameter |
amount | a parameter |
public static BufferedImage changeContrast(BufferedImage img, float amount)
//package com.java2s; /* Image to ZX Spec//from w w w . j a va2 s. c o m * Copyright (C) 2014 Silent Software (Benjamin Brown) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.awt.image.BufferedImage; import java.awt.image.RescaleOp; public class Main { /** * Changes the contrast of an image * * @param img * @param amount * @return */ public static BufferedImage changeContrast(BufferedImage img, float amount) { if (amount == 1) { return img; } RescaleOp rescaleOp = new RescaleOp(amount, 0, null); return rescaleOp.filter(img, null); } }