YZProjectCloud/yanzhu-gateway/src/main/java/com/yanzhu/gateway/config/NoBackground.java

30 lines
928 B
Java
Raw Normal View History

2024-12-21 12:53:39 +08:00
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;
}
}