View Single Post
  #62  
Old February 15th 20, 03:14 PM posted to alt.windows7.general,alt.comp.os.windows-10,microsoft.public.windowsxp.general
Mayayana
external usenet poster
 
Posts: 6,438
Default Image formats

"J. P. Gilliver (John)" wrote

| Even that's not totally unique (is this a rare case where that phrase
| can be validlly used!): one of the other formats, GIF I think, has the
| option of declaring one of its colours as the transparent one. (Come to
| think of it, .ico must as well). I gather PNG has _degree_ of
| transparency, which is different - the others have only yes or no.

Yes, GIF can have one color transparent, which
is convenient and easy to make use of. ICO has
traditionally been a compound file, with one or
more BMPs inside. Each BMP then has a 2-color
mask bitmap as a key to which pixels should/shouldn't
be painted. These days I think a Windows icon can
be either an actual ICO or a PNG. I'm not sure how
it works on newer systems.

PNG transparency not only has degrees but also
per-pixel. Each pixel in a 24-bit bitmap is 3 bytes of RGB.
0,0,0 is black. 255,255,255 is white. Same with JPG, which
is just a compressed BMP with sophisticated methods
applied to make it look good with less data. But once
it's decompressed it's still just a grid of RGB values.
PNG lets you set transparency through the "alpha channel",
a fourth pixel. So the bytes of a PNG image makes it 1/3
bigger to start with. Each pixel needs 4 bytes of data.
But you can do something like make every red pixel
255,0,0,128 to make red 50% transparent. Or you
could make the image fade out at the edges. Or
you could make some aspects solid and some transparent.

The problem with that is it's very processor intensive
to render it, and it's nearly impossible to make a tool to
do it easily. Such a tool not only has to remember the
alpha value for every pixel in an image, and recalculate
when the image is changed, but it would also have to
provide a convenient GUI for doing the operation. I could
make an HTA to do things like fade the left side using
wiaaut.dll. But making a usable GUI tool would be farfetched.
Thus, PNG transparency is mostly used as a 24-bit GIF. An
image with transparent background.

So that's probably part of why PNG is still not popular. It's
not really used for that aspect. It's only used for high quality
24-bit images that must be able to render on all machines.
Like JPG, it's universally supported but has big drawbacks,
like slow/complex and large file size. When you look at popular
online sites you can see that most images are JPGs that have
been reduced to a point where they're barely discernible at
the displayed resolution. Enlarge that image a bit and you
just see squares of color... Which is odd. They're loading
5 MB of script but cutting corners on a 50 KB JPG! So those
sites are not going to switch to PNG.

Even if they want transparency, that can be done with CSS,
so there's very little to recommend PNG. Example: Save this code
to an HTML file and replace IMG SRC, WIDTH, HEIGHT with the
specs of an image in the same location. When you load the page
you'll see a red-tinted image. The style setting specifies FF0000
background (red) and 50% opacity for the image. (Values go 0 to 1.0)



Ads