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