View Single Post
Old 11-02-2010, 05:41 PM   #1439
kartu
PRS+ author
kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.
 
Posts: 1,637
Karma: 2446233
Join Date: Dec 2007
Device: Sony PRS-300, 505, 600, 650, 950
Very funny, 600 already has the code for standby images.

PS
Update: yep, works like a charm. You can use this code (mostly shamelessly copy pasted from 350) to draw centered image, just replace this.x .y .width .height .color with 0 0 600 800 Color.black:

Spoiler:

Code:
	var window, path, bitmap, temp, port, x, y, bounds, ratio, width, height, ditheredBitmap, color;
	window = this.root.window;
	path = "/Data/logo.png";
	if (FileSystem.getFileInfo(path)) {
		try {
			bitmap = new Bitmap(path);
			temp = new Bitmap(this.width, this.height, 12);
			port = new Port(temp);
			port.setPenColor(Color.black);
			port.fillRectangle(0, 0, this.width, this.height);
			x = 0;
			y = 0;
			bounds = bitmap.getBounds();
			ratio = (bounds.height > bounds.width)?this.height / bounds.height:this.width / bounds.width;
			width = Math.floor(bounds.width * ratio);
			height = Math.floor(bounds.height * ratio);
			if (height > width) {
				x = Math.floor(this.width - width) / 2;
			} else {
				y = Math.floor(this.height - height) / 2;
			}
			bitmap.draw(port, x, y, width, height);
			bitmap.close();
			ditheredBitmap = temp.dither(true);
			port.close();
			temp.close();
			window.drawBitmap(ditheredBitmap, this.x, this.y, this.width, this.height);
			ditheredBitmap.close();
		} catch (ignore) {
		}
	} else {
		color = window.getPenColor();
		window.setPenColor(this.color);
		window.fillRectangle(0, 0, 600, 800);
		window.setPenColor(color);
	}

Last edited by kartu; 11-02-2010 at 06:41 PM.
kartu is offline   Reply With Quote