Things I wish I had never heard

Started by
4 comments, last by Scouting Ninja 7 years, 6 months ago

"as a workaround you could probably decode JNG with javascript"

For context: https://en.wikipedia.org/wiki/JPEG_Network_Graphics

Basically JPEG for color with PNG for alpha. Legitimately good idea, but not supported in browsers because it's a subset of MNG and there's a religious war against MNG pretty much. But yeah, not the kind of thing you want to do in javascript, you'd be implementing the decompression algorithm yourself for starters...

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
Advertisement

"as a workaround you could probably decode JNG with javascript"

Can I ask why not just use PNG?

PNG compresses much worse for things like photos or the like (PNG is good at flat shades and gradients), but JPEG can't support transparencies at all so you're forced to stick with the rectangular shape. JNG is meant to be a middle point that uses the best part of both (see how its name is a mix of JPEG and PNG, even). Browsers don't support it though, so probably your best choice here is to split it into two files (a JPEG and a PNG) and merge them in a canvas. Or you can be careless, parse the format yourself in a script, then bring the browser to a halt because of how much CPU time and RAM you're hogging by doing that. Especially if the image is large.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
PNG compresses much worse for things like photos or the like

Yes, however it's my understanding that you can use any compressing technique with it if you have the programming skills; I am only a hobbyist programmer so I could be wrong.

There was a network gaming company I did some 3D work for, they had us using a "lossy PNG compressor" although honestly I prefer my textures with out grainy noise in them.

(a JPEG and a PNG) and merge them in a canvas

Couldn't you just use a JPG and then add a array to show the alpha, so each image when saved will be a JPG and a array that you save as a text or binary file.

edit:

JPG 2000, doesn't it support alpha?. Never used it as I mostly use TGA and what my client ask witch is %90 PNG.

Yeah, converting the PNG to 8-bit with dithering is another option (that turns out to save a lot of space), though not everybody likes the dithering and also has a serious potential to backfire if there are too many hues. Still probably the best option when you have control over what images are processed though, especially at high resolution. As for JPEG 2000, I think it also has the issue of nearly nothing supporting it, at least as far as everyday use goes (IIRC it has way more support in the professional side of things).

In any case the original point wasn't so much this but rather the suggestion of using javascript for an horrendously expensive operation =P

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

In any case the original point wasn't so much this but rather the suggestion of using javascript for an horrendously expensive operation =P

Still I learned a lot and a believe it will help others who want to make browser games. :D

This topic is closed to new replies.

Advertisement