@@ -355,7 +355,7 @@ impl<T: Copy> Table<T> {
355355#[ test]
356356fn test_file ( ) {
357357 use std:: io:: prelude:: * ;
358- let sample = "samples/test .crn" ;
358+ let sample = "samples/logo .crn" ;
359359 assert_eq ! ( Header :: fixed_size( ) , Header :: serialize_option( )
360360 . serialized_size( & Header :: default ( ) ) . expect( "header size" ) as usize ) ;
361361 let mut file = std:: fs:: File :: open ( sample) . expect ( "open sample crn file" ) ;
@@ -369,7 +369,7 @@ fn test_file() {
369369 let tables = header. get_table ( & buffer) . expect ( "read table" ) ;
370370 println ! ( "table: {:x?}" , tables) ;
371371 let level0 = header. unpack_level ( & tables, & buffer, 0 ) . expect ( "unpack" ) ;
372- println ! ( "{:02x?} " , level0) ;
372+ println ! ( "{}x{} => {} " , header . width , header . height , level0. len ( ) ) ;
373373 header. unpack_level ( & tables, & buffer, header. level_count as usize - 1 ) . expect ( "unpack" ) ;
374374
375375 use image:: ImageDecoder ;
@@ -381,11 +381,12 @@ fn test_file() {
381381 Format :: Dxt5 => image:: codecs:: dxt:: DxtVariant :: DXT5 ,
382382 format => unimplemented ! ( "image does not support format {:?}" , format) ,
383383 } ;
384- let decoder = image:: codecs:: dxt:: DxtDecoder :: new ( std:: io:: Cursor :: new ( & level0) , width0 as u32 , height0 as u32 , variant) . expect ( "new image" ) ;
384+ fn stride_of ( x : u16 ) -> u32 { ( ( x + 3 ) / 4 * 4 ) as _ }
385+ let decoder = image:: codecs:: dxt:: DxtDecoder :: new ( std:: io:: Cursor :: new ( & level0) , stride_of ( width0) , stride_of ( height0) , variant) . expect ( "new image" ) ;
385386 let mut raw = vec ! [ 0 ; decoder. total_bytes( ) as usize ] ;
386387 let color_type = decoder. color_type ( ) ;
387388 decoder. read_image ( & mut raw) . expect ( "decode dxt" ) ;
388389 let f = std:: fs:: File :: create ( std:: path:: Path :: new ( sample) . with_extension ( "tga" ) ) . expect ( "create sample tga file" ) ;
389390 let encoder = image:: codecs:: tga:: TgaEncoder :: new ( f) ;
390- encoder. encode ( & raw , width0 as u32 , height0 as u32 , color_type) . expect ( "encode tga" ) ;
391+ encoder. encode ( & raw , stride_of ( width0) , stride_of ( height0) , color_type) . expect ( "encode tga" ) ;
391392}
0 commit comments