package com.yanzhu.gateway.config; import com.google.code.kaptcha.BackgroundProducer; import com.google.code.kaptcha.util.Configurable; import java.awt.*; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; public class NoBackground extends Configurable implements BackgroundProducer { @Override public BufferedImage addBackground(BufferedImage baseImage) { Color colorFrom = getConfig().getBackgroundColorFrom(); Color colorTo = getConfig().getBackgroundColorTo(); int width = baseImage.getWidth(); int height = baseImage.getHeight(); // create an opaque image BufferedImage imageWithBackground = new BufferedImage(width, height, BufferedImage.TRANSLUCENT); Graphics2D graph = (Graphics2D) imageWithBackground.getGraphics(); graph.drawImage(baseImage, 0, 0, null); return imageWithBackground; } }