Image Format Selection in XNA

Source: Internet
Author: User

XNA compiles the image. xnb format, which can only be read by xna. The main part is jpg, png, and tag format. Generally, I will use Paint.net to create a graph. The problem is that the xnb format is too large, the following uses a large white image (1440X900) to generate an XNB file.

Format Original size XNB size Zip size after compression
. Jpg 21.7 K 5063 K 11 K
. Png 10.1 K 5063 K 8 K
. Tag 44.6 K 5063 K 8 K

Therefore, the size of XNB is determined by the image size.

1440*900/5063 = 256

Therefore, each K (256 B) data is stored in pixels. Therefore, each pixel needs to be stored in 4 bytes, which is the familiar rgba.

Considering that only jpg and png can be previewed in the system, while PNG supports transparency, it is decided to use PNG in future CG scenarios.

If there are 100 scenarios, it is a waste of MB space after decompression.

There are many solutions. One is to write and compile the parsing file by yourself and add the compression logic. The other is to directly use the IO class to read the file without compiling it into XNB, which may cause cross-platform problems. Not demonstrated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.