ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

PreviewPack: Difference between revisions

From ModEnc
Jump to navigation Jump to search
Zzattack (talk | contribs)
No edit summary
m Better example code reference (added line goto)
 
(2 intermediate revisions by 2 users 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.
[[File:DCUprisingPreviewOfficial.png|200px|thumb|right|Original preview of the DC Uprising map]]
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 LZO compressed data that, when decompressed, contains the image in BGR format. The scanline of each row of pixels is precisely 3 times the width, i.e. no additional padding is used.  
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 16: Line 18:
== Width/height proportions of original maps ==
== Width/height proportions of original maps ==
[[File:PreviewPackWrongDimensionsRatio.png|200px|thumb|right|PreviewPack that does not adhere to official dimensions ratio]]
[[File:PreviewPackWrongDimensionsRatio.png|200px|thumb|right|PreviewPack that does not adhere to official dimensions ratio]]
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. 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 at{{fnl|1}}, where more precise values can be found.
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 at{{fnl|1}}, where more precise values can be found.


{| align="center" cellpadding="4" class="table_descrowdesccol"
{| align="center" cellpadding="4" class="table_descrowdesccol"
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 sizem LocalSize and full map size for the official TS, FS, RA2 and YR maps.}}
{{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 page should correctly be named "[PreviewPack]"; it is wrong due to technical restrictions.


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

Preview of DC Uprising map generated with CNCMaps renderer

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

PreviewPack that does not adhere to official dimensions ratio

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.