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.