use of com.teamdev.jxbrowser.ui.Bitmap in project JxBrowser-Examples by TeamDev-IP.
the class BitmapToSwingImage method main.
public static void main(String[] args) throws IOException {
try (Engine engine = Engine.newInstance(OFF_SCREEN)) {
Browser browser = engine.newBrowser();
// Resize browser to the required dimension
browser.resize(1024, 768);
// Load the required web page and wait until it is loaded completely
browser.navigation().loadUrlAndWait("https://www.google.com");
Bitmap bitmap = browser.bitmap();
// Convert the bitmap to java.awt.image.BufferedImage
BufferedImage bufferedImage = BitmapImage.toToolkit(bitmap);
// Save the image to a PNG file
ImageIO.write(bufferedImage, "PNG", new File("bitmap.png"));
}
}
use of com.teamdev.jxbrowser.ui.Bitmap in project JxBrowser-Examples by TeamDev-IP.
the class BitmapToJavaFxImage method main.
public static void main(String[] args) throws IOException {
try (Engine engine = Engine.newInstance(OFF_SCREEN)) {
Browser browser = engine.newBrowser();
// Resize browser to the required dimension
browser.resize(1024, 768);
// Load the required web page and wait until it is loaded completely
browser.navigation().loadUrlAndWait("https://www.google.com");
Bitmap bitmap = browser.bitmap();
// Convert the bitmap to javafx.scene.image.Image
Image image = BitmapImage.toToolkit(bitmap);
// Convert javafx.scene.image.Image to java.awt.image.BufferedImage
BufferedImage bufferedImage = SwingFXUtils.fromFXImage(image, null);
// Save the image to a PNG file
ImageIO.write(bufferedImage, "PNG", new File("bitmap.png"));
}
}
use of com.teamdev.jxbrowser.ui.Bitmap in project JxBrowser-Examples by TeamDev-IP.
the class BitmapToSwtImage method main.
public static void main(String[] args) {
Display display = new Display();
try (Engine engine = Engine.newInstance(OFF_SCREEN)) {
Browser browser = engine.newBrowser();
// Resize browser to the required dimension
browser.resize(1024, 768);
// Load the required web page and wait until it is loaded completely
browser.navigation().loadUrlAndWait("https://www.google.com");
Bitmap bitmap = browser.bitmap();
// Convert the bitmap to org.eclipse.swt.graphics.Image
Image image = BitmapImage.toToolkit(display, bitmap);
// Save the image to a PNG file
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData() };
loader.save("bitmap.png", SWT.IMAGE_PNG);
}
display.dispose();
}
Aggregations