MediaWiki
REL1_22
|
00001 <?php 00030 class BmpHandler extends BitmapHandler { 00031 00036 function mustRender( $file ) { 00037 return true; 00038 } 00039 00048 function getThumbType( $text, $mime, $params = null ) { 00049 return array( 'png', 'image/png' ); 00050 } 00051 00059 function getImageSize( $image, $filename ) { 00060 $f = fopen( $filename, 'rb' ); 00061 if ( !$f ) { 00062 return false; 00063 } 00064 $header = fread( $f, 54 ); 00065 fclose( $f ); 00066 00067 // Extract binary form of width and height from the header 00068 $w = substr( $header, 18, 4 ); 00069 $h = substr( $header, 22, 4 ); 00070 00071 // Convert the unsigned long 32 bits (little endian): 00072 try { 00073 $w = wfUnpack( 'V', $w, 4 ); 00074 $h = wfUnpack( 'V', $h, 4 ); 00075 } catch ( MWException $e ) { 00076 return false; 00077 } 00078 return array( $w[1], $h[1] ); 00079 } 00080 }