You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello , i checked your source codes and you always make new BufferedImage per scale.
This is time consuming.You can pre allocate images by ThreadLocal like shown below example :
final BufferedImage screenCapture = robot.createScreenCapture( new Rectangle( 0 , 0 , 1 , 1));
imageThreadLocal = new ThreadLocal<BufferedImage>() {
@Override
protected BufferedImage initialValue() {
final RectangleEx rectangle1 = rootRects[0];
final Rectangle rectangle2 = rectangle1.getRectangle();
return new BufferedImage( rectangle2.width , rectangle2.height , screenCapture.getType() );
}
};
writer = new ThreadLocal<ImageWriter>() {
@Override
protected ImageWriter initialValue() {
final Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
if (!writers.hasNext())
throw new IllegalStateException("No writers found");
ImageWriter writer2 = (ImageWriter) writers.next();
return writer2;
}
};
The text was updated successfully, but these errors were encountered:
Hello , i checked your source codes and you always make new BufferedImage per scale.
This is time consuming.You can pre allocate images by ThreadLocal like shown below example :
The text was updated successfully, but these errors were encountered: