Png Transparency
Caboose
title = name(self, handle) Join Date: 2003-02-15 Member: 13597Members, Constellation
in Off-Topic
<div class="IPBDescription">Why doesn't IE support it?</div> Yea, so I've been using IE on my friends laptop for a little bit, and I've noticed that transparent png's don't show the transparency.
png's are far better than gifs for transparency, because it's actual transparency, not just making one color transparent. Why can't MS implement png transparency?
<a href='http://homepage.ntlworld.com/bobosola/' target='_blank'>http://homepage.ntlworld.com/bobosola/</a>
there's a fix there for it, it's written in javascript and would be a cool thing to add to the forums <!--emo&:p--><img src='http://www.unknownworlds.com/forums/html/emoticons/tounge.gif' border='0' style='vertical-align:middle' alt='tounge.gif' /><!--endemo-->
Yea, one more reason I hate IE.
png's are far better than gifs for transparency, because it's actual transparency, not just making one color transparent. Why can't MS implement png transparency?
<a href='http://homepage.ntlworld.com/bobosola/' target='_blank'>http://homepage.ntlworld.com/bobosola/</a>
there's a fix there for it, it's written in javascript and would be a cool thing to add to the forums <!--emo&:p--><img src='http://www.unknownworlds.com/forums/html/emoticons/tounge.gif' border='0' style='vertical-align:middle' alt='tounge.gif' /><!--endemo-->
Yea, one more reason I hate IE.
Comments
perhaps ie7 will have it. it'll be here soon.
That's amazing, so did I!
Either way, we have learnt three things from this:
1. <a href='http://www.microsoft.com/windows/ie/default.mspx' target='_blank'>IE</a> sucks.
2. All friends of his should have <a href='http://www.mozilla.org/products/firefox/' target='_blank'>FireFox</a>.
3. <a href='http://en.wikipedia.org/wiki/Terrorists' target='_blank'>Terrorists</a> work for <a href='http://www.microsoft.com/' target='_blank'>Microsoft</a>.
PNG support will be in Internet Explorer 7.
<a href='http://blogs.msdn.com/ie/archive/2005/05/27/422721.aspx' target='_blank'>http://blogs.msdn.com/ie/archive/2005/05/27/422721.aspx</a>
Unfortunately, it won't be available for any operating system other than Windows XP SP2 and above.
Internet Explorer 6 doesn't support alpha transparency by default: it requires DirectX code to work. From what I recall, using the code in the img src makes the PNG no longer work in other browsers.
And I hate the following sentence.
LIES!
Well it depends what format you compare it to. Compared to jpg (which is really what it should be compared to): png smokes it. Compared to gif, well gif usually wins but it also has a limited palette.
You might have been lead to this conclusion by photoshop's horrid png handling.
Get PNGCrush and everyone is happy:
<a href='http://pmt.sourceforge.net/pngcrush/' target='_blank'>http://pmt.sourceforge.net/pngcrush/</a>
what
PNG and GIF both use indexed pattern compression that's best suited for images containing repetition or blocks of single color; JPEG uses frequency based compression and can perform far better at storing images that don't contain repetitive pixel blocks if you are willing to introduce a little noise to the image. The human eye can't pick up subtle differences between two complex images if there is enough detail, which is when you typically want to switch to JPEG anyway.
If you're saving line art as JPEG of course it'll be far worse than either GIF or PNG (both quality and size), but if you're willing to accept some loss, JPEG fares better than ether pattern indexing format for many photographs.
Saying that PNG is better than JPEG is like saying a nail is better than a screw. Nails and screws can hold two or more objects together; the problem statement determines which one is best.
PNG and GIF use the same family of compression techniques (PNG was designed specifically to be a successor to GIF), so that's a much more valid comparason than PNG and JPEG. GIF is based on LZW compression, PNG uses LZ77 compression.
The fix is really easy though. So easy its not even worth complaining that much:
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1--><!--[if gte IE 5.5000]>
<script type="text/javascript">
// Correctly handle PNG transparency in Win IE 5.5 or higher.
// [URL=http://homepage.ntlworld.com/bobosola]http://homepage.ntlworld.com/bobosola[/URL]. Updated 02-March-2004
function correctPNG()
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i];
var imgName = img.src.toUpperCase();
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : "";
var imgClass = (img.className) ? "class='" + img.className + "' " : "";
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
var imgStyle = "display:inline-block;" + img.style.cssText;
if (img.align == "left") imgStyle = "float:left;" + imgStyle;
if (img.align == "right") imgStyle = "float:right;" + imgStyle;
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
img.outerHTML = strNewHTML;
i = i-1;
}
}
}
// Onload event changed by Russell Weed to facilitate multiple onload things.
if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", correctPNG, false );
else if ( typeof window.attachEvent != "undefined" ) {
window.attachEvent( "onload", correctPNG);
}
else {
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
correctPNG();
};
}
else
window.onload = myInitFunction;
}
</script>
<![endif]--><!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
It always sucks to have to do these type of hack things, but what are you gonna do eh? Can't tell your paying customers their e-wang is inferior and they shouldn't use the only browser they know how...
^^ lol the forums are broekz I cant fix it D: