<commit_before>package example;

import com.artifex.mupdf.fitz.*;
import java.awt.*;
import java.awt.image.*;

public class PageCanvas extends java.awt.Canvas
{
	protected Page page;
	protected BufferedImage image;

	public static BufferedImage imageFromPixmap(Pixmap pixmap) {
		int w = pixmap.getWidth();
		int h = pixmap.getHeight();
		BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
		image.setRGB(0, 0, w, h, pixmap.getPixels(), 0, w);
		return image;
	}

	public static BufferedImage imageFromPageWithDevice(Page page, Matrix ctm) {
		Rect bbox = page.getBounds();
		Pixmap pixmap = new Pixmap(ColorSpace.DeviceBGR, bbox);
		pixmap.clear(255);
		DrawDevice dev = new DrawDevice(pixmap);
		page.run(dev, new Matrix());
		dev.destroy();
		BufferedImage image = imageFromPixmap(pixmap);
		pixmap.destroy();
		return image;
	}<commit_msg>android desktop viewer: scale the page box before making the pixmap in imageFromPageWithDevice<commit_after>package example;

import com.artifex.mupdf.fitz.*;
import java.awt.*;
import java.awt.image.*;

public class PageCanvas extends java.awt.Canvas
{
	protected Page page;
	protected BufferedImage image;

	public static BufferedImage imageFromPixmap(Pixmap pixmap) {
		int w = pixmap.getWidth();
		int h = pixmap.getHeight();
		BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
		image.setRGB(0, 0, w, h, pixmap.getPixels(), 0, w);
		return image;
	}

	public static BufferedImage imageFromPageWithDevice(Page page, Matrix ctm) {
		Rect bbox = page.getBounds();
		bbox.transform(ctm);
		Pixmap pixmap = new Pixmap(ColorSpace.DeviceBGR, bbox);
		pixmap.clear(255);
		DrawDevice dev = new DrawDevice(pixmap);
		page.run(dev, new Matrix());
		dev.destroy();
		BufferedImage image = imageFromPixmap(pixmap);
		pixmap.destroy();
		return image;
	}
{'fraction_non_alphanumeric': 0.11467391304347826, 'fraction_numerical': 0.006521739130434782, 'mean_word_length': 4.957928802588997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2476458', 'n_tokens_mistral': 676, 'n_tokens_neox': 611, 'n_words': 163}