Lossy compression for NES screens

A place for your artistic side. Discuss techniques and tools for pixel art on the NES, GBC, or similar platforms.

Moderator: Moderators

JRoatch
Formerly 43110
Posts: 422
Joined: Wed Feb 05, 2014 7:01 am
Contact:

Re: Lossy compression for NES screens

Post by JRoatch »

Edit: post removed due to dead links.
Last edited by JRoatch on Sun Feb 12, 2023 1:02 pm, edited 1 time in total.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Lossy compression for NES screens

Post by tepples »

In case the original Tweet disappears, the drawing is mirrored on Danbooru at https://danbooru.donmai.us/posts/2178017

illustrator: Kiyohiko AZUMA
series: Yotsuba&!
characters: Yotsuba KOIWAI and her teddy bear Duralumin
Mirror's translation of caption:
Yesterday's daily calendar image is "A pair of slime sisters who mimic another party's form and appeal to friendship, Youtsuba somehow figuring it out, and Duralumin not understanding a thing."

EDIT: I missed something. Clarify purpose of this post in light of this.
Joe
Posts: 649
Joined: Mon Apr 01, 2013 11:17 pm

Re: Lossy compression for NES screens

Post by Joe »

The first post in this thread already contains a link to the source, and it's the artist's Twitter account instead of a reupload on an image gallery...
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Lossy compression for NES screens

Post by tepples »

Oops, my fault. I misread something. Clarified.
JRoatch
Formerly 43110
Posts: 422
Joined: Wed Feb 05, 2014 7:01 am
Contact:

Re: Lossy compression for NES screens

Post by JRoatch »

A much improved rewrite of this tool which is orders of magnitude faster, slightly better looking, and can handle tile flips, can be found at the attachment in the next post.

Edit: removed dead links.
Last edited by JRoatch on Sun Feb 12, 2023 1:01 pm, edited 1 time in total.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Lossy compression for NES screens

Post by tepples »

Congratulations on shipping! Calling for backup
Attachments
jrrtilevq_2020-12-07.zip
(87.65 KiB) Downloaded 200 times
JRoatch
Formerly 43110
Posts: 422
Joined: Wed Feb 05, 2014 7:01 am
Contact:

Re: Lossy compression for NES screens

Post by JRoatch »

It was pointed out that the 2020-12-07 version of this was causing segmentation faults with large (about 49000 tiles) images.
The patch for this is to change the variable types and change the if statement for jrrtilevq_distance_matrix_coords as follows:

Code: Select all

static uint32_t jrrtilevq_distance_matrix_coords(uint32_t x, uint32_t y, uint32_t w)
{
	assert(x != y);
	if (y < x) {
		uint32_t temp = x;
		x = y;
		y = temp;
	}
	y = w - y - 1;
	uint32_t r = y * w + x;
	if ((w * (w-1)) / 2 <= r) {
		r = (w * (w-1)) - r - 1;
	}
	return r;
}
Even with this patch, the input image size is still limited to <65536 tiles.

The real fix would be to replace the stupidly large square array with an actual priority queue.
Post Reply