Sub timer1_tick
timer1.Enabled=False
Dim Rect1 As JavaObject
Rect1.InitializeNewInstance("java.awt.Rectangle",Array(0,0,1920,1080)) 'you can give only the rectangle you want !
Dim Jo As JavaObject = Me
Dim bbi() As Byte
bbi=Jo.RunMethod("capturess",Array(Rect1))
timer1.Enabled=true
end sub
#if java
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.io.*;
import javax.imageio.ImageIO;
import org.apache.commons.codec.binary.Base64;
import com.github.zakgof:webp4j:0.0.2;
public static byte[] capturess(final Rectangle rect) throws AWTException,
IOException {
Robot robot = new Robot();
BufferedImage screenFullImage = robot.createScreenCapture(rect);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(screenFullImage, "jpg", baos);
byte[] bytes = baos.toByteArray();
//String bytesBase64 = Base64.encodeBase64String(bytes);
return bytes;
}
// convert BufferedImage to byte[]
public static byte[] toByteArray(BufferedImage bi, String format)
throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, format, baos);
byte[] bytes = baos.toByteArray();
return bytes;
}
#End If