rust/hedgewars-engine/src/main.rs
changeset 15808 1fa2f38c5700
parent 15807 67f83b7dfc6c
child 15890 8a6a2d931bae
equal deleted inserted replaced
15807:67f83b7dfc6c 15808:1fa2f38c5700
    34 const PREVIEW_HEIGHT: u32 = 128;
    34 const PREVIEW_HEIGHT: u32 = 128;
    35 const PREVIEW_NPIXELS: usize = (PREVIEW_WIDTH * PREVIEW_HEIGHT) as usize;
    35 const PREVIEW_NPIXELS: usize = (PREVIEW_WIDTH * PREVIEW_HEIGHT) as usize;
    36 const SCALE_FACTOR: u32 = 16;
    36 const SCALE_FACTOR: u32 = 16;
    37 const VALUE_PER_INPIXEL: u8 = 1;
    37 const VALUE_PER_INPIXEL: u8 = 1;
    38 
    38 
       
    39 /// Resizes the land preview from the library into appropriate format for --preview command.
       
    40 ///
       
    41 /// # Arguments
       
    42 ///
       
    43 /// * `mono_pixels` - Raw pixels of a land preview (monochrome, 0 = empty, else = filled)
       
    44 /// * `in_width` - Width of the preview stored in `mono_pixels`
       
    45 /// * `in_height` - Height of the preview stored in `mono_pixels`
       
    46 /// * `preview_pixels` - Used as **output** for a resized and (kinda) anti-aliased grayscale preview
    39 fn resize_mono_preview(mono_pixels: &[u8], in_width: u32, in_height: u32, preview_pixels: &mut [u8]) {
    47 fn resize_mono_preview(mono_pixels: &[u8], in_width: u32, in_height: u32, preview_pixels: &mut [u8]) {
    40 
    48 
    41     assert!(mono_pixels.len() == (in_width * in_height) as usize);
    49     assert!(mono_pixels.len() == (in_width * in_height) as usize);
    42 
    50 
    43     let v_offset: u32 = max(0, PREVIEW_HEIGHT as i64 - (in_height / SCALE_FACTOR) as i64) as u32;
    51     let v_offset: u32 = max(0, PREVIEW_HEIGHT as i64 - (in_height / SCALE_FACTOR) as i64) as u32;