PreviewPack: Difference between revisions
mNo edit summary |
Vananabanana (talk | contribs) m Better example code reference (added line goto) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{WrongTitle|[PreviewPack]}} | {{WrongTitle|[PreviewPack]}} | ||
This section in a map file contains the picture that is to be used as the map preview. The dimensions of this image are given in the [[Preview]] section. | |||
The image itself is stored as a single huge base64-encoded string spanning across every key in the PreviewPack section.{{fnl|2}} | |||
This section in a map file contains the picture that is to be used as the map preview. The dimensions of this image are given in the [[Preview]] section. The image itself is stored as a base64-encoded string of | When decoded, the string will contain blocks of compressed pixel data: | ||
- 2 unsigned bytes of the compressed block size (excluding this header) | |||
- 2 unsigned bytes of the uncompressed block size (excluding this header) | |||
- [http://www.oberhumer.com/opensource/lzo/ LZO compressed] pixels in BGR888 format. | |||
The scanline of each row of pixels is precisely 3 times the width, i.e. no additional padding is used. | |||
== Editing previews == | == Editing previews == | ||
Line 44: | Line 46: | ||
== See also == | == See also == | ||
{{fn|1|[[https://docs.google.com/spreadsheet/ccc?key=0AiVQdoAJ4w7bdGFraGRqM3FZZk5FWVBiR0pIYnJGbGc&usp=sharing C&C TS/RA2 - PreviewPack / LocalSize / Map Size proportions]] - Spreadsheet containing the proportions between preview | {{fn|1|[[https://docs.google.com/spreadsheet/ccc?key=0AiVQdoAJ4w7bdGFraGRqM3FZZk5FWVBiR0pIYnJGbGc&usp=sharing C&C TS/RA2 - PreviewPack / LocalSize / Map Size proportions]] - Spreadsheet containing the proportions between preview size LocalSize and full map size for the official TS, FS, RA2 and YR maps.}} | ||
{{fn|2|[[https://github.com/CnCNet/xna-cncnet-client/blob/450cfb1c0a03e8af7fb1d2388d55d1f9bd285fd8/DXMainClient/Domain/Multiplayer/MapPreviewExtractor.cs#L73 MapPreviewExtractor.cs]] - Decoder example code from the CNCNet Client.}} |
Latest revision as of 15:28, 19 June 2022
This section in a map file contains the picture that is to be used as the map preview. The dimensions of this image are given in the Preview section. The image itself is stored as a single huge base64-encoded string spanning across every key in the PreviewPack section.2 When decoded, the string will contain blocks of compressed pixel data:
- 2 unsigned bytes of the compressed block size (excluding this header) - 2 unsigned bytes of the uncompressed block size (excluding this header) - LZO compressed pixels in BGR888 format.
The scanline of each row of pixels is precisely 3 times the width, i.e. no additional padding is used.
Editing previews
There is little need to edit this manually, as XCC Mixer can create this section from any desired picture, which can then be pasted into a map file. This is used in the newest version of the Assault Mappacks to display an informational picture to users which are playing an Assault-compatible mod without downloading the mappacks themselves. (See the Assault Mappacks page for more info.) The map editor Final Alert is also capable of generating previews based on the tiles of the map. Higher quality previews can be obtained using a resized picture of the full map. The CNCMaps rendering tool contains an option to create these, and directly inject a high-quality preview into the map.
Width/height proportions of original maps
The dimensions of the preview image on official maps appear to have a relation to either the LocalSize or Size of the map, depending on the game. Deviating from these dimensions can but not always will cause unwanted black pixels to appear in the image, as can be seen in the image on the right. This was confirmed at least for Yuri's Revenge. The table below shows the formulas that appear to be used, values presented are rounded and not precise. They were taken from the research presented at1, where more precise values can be found.
Game | Preview width | Preview height |
---|---|---|
Tiberian Sun | 1.975 * full width | 0.995 * full height |
FireStorm | 1.975 * full width | 0.995 * full height |
Red Alert 2 | 1.975 * full width | 0.995 * full height |
Yuri's Revenge | 1.975 * local width | 1.0 * local height |
See also
1 ↑ [C&C TS/RA2 - PreviewPack / LocalSize / Map Size proportions] - Spreadsheet containing the proportions between preview size LocalSize and full map size for the official TS, FS, RA2 and YR maps.
2 ↑ [MapPreviewExtractor.cs] - Decoder example code from the CNCNet Client.