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
m Maps/PreviewData moved to Maps/PreviewPack: It is not PreviewData, it's PreviewPack. And if anybody actually read these pages, it would have been spotted long ago.
m Better example code reference (added line goto)
 
(8 intermediate revisions by 4 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.
The image itself is stored as a single huge base64-encoded string spanning across every key in the PreviewPack section.{{fnl|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)
- [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 ==
[[File:DCUprisingPreviewCNCMaps.png|200px|thumb|right|Preview of DC Uprising map generated with CNCMaps renderer]]
There is little need to edit this manually, as [[XCC Mixer]] can [[XCC Mixer file conversion#Copy As|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 [http://github.com/zzattack/ccmaps-net 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 ==
[[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. 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"
!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
|}


This section in a map file contains a base64-encoded version of the picture that is to be used as the map preview. It is stored in a 0-based array, each line containing up to 70 characters. There is little need to edit this manually, as [[XCC:Mixer|XCC Mixer]] can [[XCC Mixer file conversion#Copy As|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.)


[[Category:Maps Sections|PreviewPack]]
[[Category:Maps Sections|PreviewPack]]
== 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 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.