fix image.write slow
This commit is contained in:
parent
b390fe3f3f
commit
2d68b0f89b
@ -6,6 +6,8 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import com.sun.image.codec.jpeg.JPEGCodec;
|
||||||
|
import com.sun.image.codec.jpeg.JPEGImageEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* png格式验证码
|
* png格式验证码
|
||||||
@ -92,7 +94,9 @@ public class SpecCaptcha extends Captcha {
|
|||||||
g.setFont(font.deriveFont(num(2) == 0 ? Font.PLAIN : Font.ITALIC));
|
g.setFont(font.deriveFont(num(2) == 0 ? Font.PLAIN : Font.ITALIC));
|
||||||
g.drawString(String.valueOf(strs[i]), x, y);
|
g.drawString(String.valueOf(strs[i]), x, y);
|
||||||
}
|
}
|
||||||
ImageIO.write(bi, "png", out);
|
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(outputStream);
|
||||||
|
encoder.encode(bi);
|
||||||
|
// ImageIO.write(bi, "png", out);
|
||||||
out.flush();
|
out.flush();
|
||||||
ok = true;
|
ok = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user