开发者

How to get the maximum width & height size image when loading several images before loading them completely?

I am loading images of different size and then images are scaled and border is drawn for each image as shown in below link,

http://web.s4spk.com/irfan/test.swf

I want that border of images to be of the same width and height and for that I need to find out the max w开发者_JS百科idth and height size image before loading all the images. Is there any way that I can know the width and height of an image before loading it completely?


Hard way: Use the ByteArray class and load your images as byte data (URLLoader with type set to BINARY). Load in the first few bytes to read in the header. In the header of the image, you can parse out the width and height.

You'll need to be familiar with the specifications of the image type you're using (PNG is found at http://www.w3.org/TR/PNG/) and have a working knowledge of bytes (Thibault Imbert is writing an excellent book on the subject: http://www.bytearray.org/?p=711)

Easy way: Load in all your images, but don't add them to the stage. They won't be shown, and you can check the width/height and draw your border as needed.

Even easier way: Have a fixed border size and scale your images as they're loaded

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜