利用 Flash CS4 的 PNG 压缩,但作为外部文件?
问题是:我正在开发一些 Flash 网站并且非常喜欢 AS3。
问题: PNG 24 位图像太大...我有三个具有透明度的 PNG 图像,我想每 10 秒左右在“主页”上旋转一次。伟大的。没问题 - 但我不想将所有三个 PNG 嵌入到 SWF 中(这会花费更长的时间来加载),而是希望从外部文件动态加载它们,以便用户不必等待图像加载无论如何,接下来的 10-15 秒内都不会显示。没关系...我有工作代码。
真正的问题:这些 PNG 尺寸,甚至是从外部文件动态加载的,都让我很烦恼。使用 Photoshop 保存时,一张图像为 350k - 使用 PNGOUT 时为 300k。但是...当我将 PNG 导入 Flash 的库时,我可以进去并将其设置为 JPG/图像压缩,这会将大小减少到大约 45k,但仍保留 alpha 信息!如果 Flash 可以对我的 PNG 进行如此大的压缩,并且仍然使其看起来不错,为什么我找不到可以对外部文件执行相同操作的应用程序?我很乐意将图像加载到 Flash 库中并让它处理压缩,但如果我最终得到 5 或 6 个图像,加载时间仍然太长。
摘要:如何将透明度为 350k 的 PNG 图像缩小到 45k,就像将 Flash 导入其库时那样?
可能的解决方案: 或者...嗯...这可能是一个解决方法...也许我可以为我想要使用的每个 PNG 制作一个单独的 SWF 影片,该影片使用 Flash 压缩图像- 然后使用加载器动态读取该文件...这应该可以工作! 我将返回并报告...
但是,Flash 为何能够比 PNGOUT 这样的压缩器压缩这些 PNG 的效果呢?也许我只是没有传递正确的参数以使它们有效。
感谢您阅读我的漫谈。你们都是很棒的参谋!
Here's the issue: I'm developing some Flash web sites and really enjoying AS3.
The problem: PNG 24-bit images are too big... I have three PNG images with transparency that I'd like to rotate through on the "Home page" every 10 seconds or so. Great. No problem - but instead of embedding all three PNGs in the SWF, which would take the thing longer to load, I'd like to load them dynamically from external files, so that the user doesn't have to wait around for images to load that aren't going to be displayed for another 10-15 seconds anyway. That's fine... I have working code for that.
The real problem: These PNG sizes, even loaded from external files on the fly, are really bugging me. One image is 350k when saved with Photoshop - 300k when I use PNGOUT. But... when I import the PNG into Flash's Library, I can go in and set it to JPG/Image Compression which reduces the size to about 45k, yet maintains the alpha information!! If Flash can compress my PNG that much, and still make it look good, why can't I find an app that can do the same for an external file? I'd be content to load my images into the Flash library and let it handle the compression, but if I end up with 5 or 6 images, that still turns out to be too long of a loading time.
Summary: How can I shrink my 350k PNG image with transparency down to 45k like Flash does when I import it into it's library?
Possible solution: Or.... hmmmm.... this could be a workaround... maybe I could just make a separate SWF movie for each PNG I want to use which uses the Flash compressed image - then read that file dynamically using a Loader... That ought to work! I shall return and report...
But still, how does Flash compress those PNGs so much more than compressors like PNGOUT? Maybe I'm just not passing in the right parameters for them to be effective.
Thanks for reading my ramblings. You all are a great sounding board!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PNG 压缩是无损的,因此它无法与 JPEG 等有损感知压缩方案竞争。只需确保您的 png 是要显示的大小(或不是:一种简单的“压缩”方案是保存按比例缩小的图像并在显示时缩放它,但这通常不能令人满意)。如果你不能低于 24 位(我猜你不能使用 256 调色板),我认为无能为力。我只能建议看看 PngCrush。
PNG compression is lossless, so it can't compete with lossy perceptual compression schemes as JPEG. Just be sure that your png are the size to be displayed (or not : one trivial "compression" scheme would be to save your image scaled down and zoom it when displaying, but this is normally unsatisfactory). If you can't go below 24-bits (you cant go to a 256-pallete, I guesss) I dont think much can be done. I can only suggest to give a look at PngCrush.
我以前也有同样的问题,但后来我认为flash对PNG文件使用了JPEG压缩。 JPEG压缩的“png”实际上是标准png格式不支持的变体,但flash支持。在我自己的flash项目中,我经常使用它。我什至使用 swftools 从大量 png 生成动画 SWF,因此我可以加载单个“png gallery”swf 并使用其中的所有 png。
I used to have the same question, but later, I think flash used JPEG compress for PNG files. The JPEG-compressed "png" is actually a variant that standard png format does not support, but flash supports. In my own flash project, I used it a lot. I even used swftools to generate an animated SWF from a lot of png, so I can load the single "png gallery" swf and use all the pngs inside.
我知道这个问题已经有一年了,但我认为这对将来的参考很有帮助。使用任何 png 压缩工具(PngCrush、Optipng)都不会获得与 Flash 压缩相同的结果。
我发现使用 Flash 压缩而不用在 Flash IDE 中创建每个 swf 的最佳方法是使用 SwfTools 的 png2swf 实用程序,它将保留 Alpha 通道并允许您设置 jpeg 的压缩质量。
http://www.swftools.org/png2swf.html
I know that the question is a year old, but I thought it would be good for future reference. Using any of the png compression tools (PngCrush, Optipng) will not get anywhere near the same results as Flash compression.
The best way I've found to use flash compression without creating each swf in the Flash IDE is using SwfTools' png2swf utility, it will keep alpha channels and also allow you to set the jpeg's compression quality.
http://www.swftools.org/png2swf.html