diff --git a/web/zm_config.php.in b/web/zm_config.php.in index 49fd836fe..21bd2b415 100644 --- a/web/zm_config.php.in +++ b/web/zm_config.php.in @@ -58,9 +58,6 @@ define( "MAX_EVENTS", 10 ); // The maximum number of events to show in th define( "RATE_BASE", 100 ); // The additional scaling factor used to help get fractional rates in integer format define( "SCALE_BASE", 100 ); // The additional scaling factor used to help get fractional scales in integer format define( "LEARN_MODE", false ); // Currently unimplemented, do not change -define( 'DEVICE_WIDTH', 320 ); // Default device width for phones and handhelds -define( 'DEVICE_HEIGHT', 240 ); // Default device height for phones and handhelds -define( 'DEVICE_LINES', 10 ); // Default device lines for phones and handhelds // // Date and time formats, eventually some of these may end up in the language files diff --git a/web/zm_xhtml_config.php b/web/zm_xhtml_config.php index 80caface3..5eb517a5b 100644 --- a/web/zm_xhtml_config.php +++ b/web/zm_xhtml_config.php @@ -18,8 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -define( 'DEVICE_WIDTH', 150 ); // Default device width for phones and handhelds -define( 'DEVICE_HEIGHT', 150 ); // Default device height for phones and handhelds +define( 'DEVICE_WIDTH', 320 ); // Default device width for phones and handhelds +define( 'DEVICE_HEIGHT', 240 ); // Default device height for phones and handhelds define( 'DEVICE_LINES', 10 ); // Default device lines for phones and handhelds $rates = array( @@ -53,4 +53,22 @@ switch ( $bandwidth ) } } +function getDeviceScale( $width, $height, $divisor=1 ) +{ + global $device; + + $device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; + $device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT; + + // Allow for margins etc + $device_width -= 2; + $device_height -= 2; + + $width_scale = ($device_width*SCALE_BASE)/$width; + $height_scale = ($device_height*SCALE_BASE)/$height; + $scale = (int)(($width_scale<$height_scale)?$width_scale:$height_scale); + if ( divisor != 1 ) + $scale = (int)($scale/$divisor); + return( $scale ); +} ?> diff --git a/web/zm_xhtml_view_event.php b/web/zm_xhtml_view_event.php index fb1edc8a1..302c2dbec 100644 --- a/web/zm_xhtml_view_event.php +++ b/web/zm_xhtml_view_event.php @@ -237,17 +237,7 @@ mysql_free_result( $result ); ?> =") ) diff --git a/web/zm_xhtml_view_eventdetails.php b/web/zm_xhtml_view_eventdetails.php index e11947367..f32e5ed85 100644 --- a/web/zm_xhtml_view_eventdetails.php +++ b/web/zm_xhtml_view_eventdetails.php @@ -36,16 +36,7 @@ $frame = mysql_fetch_assoc( $result ); mysql_free_result( $result ); $fid = $frame['FrameId']; -$device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; -$device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT; -// Allow for margins etc -$device_width -= 16; -$device_height -= 16; - -$width_scale = ($device_width*SCALE_BASE)/$event['Width']; -$height_scale = ($device_height*SCALE_BASE)/$event['Height']; -$scale = (int)(($width_scale<$height_scale)?$width_scale:$height_scale); -$scale /= 2; +$scale = getDeviceScale( $event['Width'], $event['Height'], 2 ); $image1 = getThumbnail( $event, 1, $scale ); if ( $frame['Type'] == 'Alarm' ) diff --git a/web/zm_xhtml_view_frame.php b/web/zm_xhtml_view_frame.php index 731ef97e8..a58f0b234 100644 --- a/web/zm_xhtml_view_frame.php +++ b/web/zm_xhtml_view_frame.php @@ -55,15 +55,7 @@ $prev_fid = $fid-1; $next_fid = $fid+1; $last_fid = $max_fid; -$device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; -$device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT; -// Allow for margins etc -$device_width -= 16; -$device_height -= 16; - -$width_scale = ($device_width*SCALE_BASE)/$event['Width']; -$height_scale = ($device_height*SCALE_BASE)/$event['Height']; -$scale = (int)(($width_scale<$height_scale)?$width_scale:$height_scale); +$scale = getDeviceScale( $event['Width'], $event['Height'] ); $image_data = getImageSrc( $event, $frame, $scale, (isset($show)&&$show=="capt") ); diff --git a/web/zm_xhtml_view_montage.php b/web/zm_xhtml_view_montage.php index 444455f7d..3ad3f13ed 100644 --- a/web/zm_xhtml_view_montage.php +++ b/web/zm_xhtml_view_montage.php @@ -18,14 +18,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // -$device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; -$device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT; - -// Allow for margins etc -$device_width -= 4; -$device_height -= 4; - -$images_per_line = 1; +$images_per_line = 2; $sql = "select * from Groups where Name = 'Mobile'"; $result = mysql_query( $sql ); @@ -71,10 +64,7 @@ mysql_free_result( $result ); $count = 0; foreach( $monitors as $monitor ) { - $width_scale = ($device_width*SCALE_BASE)/$monitor['Width']; - $height_scale = ($device_height*SCALE_BASE)/$monitor['Height']; - $scale = (int)(($width_scale<$height_scale)?$width_scale:$height_scale); - $scale = (int)($scale/$images_per_line); + $scale = getDeviceScale( $monitor['Width'], $monitor['Height'], $images_per_line ); if ( $count%$images_per_line == 0 ) { diff --git a/web/zm_xhtml_view_video.php b/web/zm_xhtml_view_video.php index b4f832b05..8542140c1 100644 --- a/web/zm_xhtml_view_video.php +++ b/web/zm_xhtml_view_video.php @@ -42,10 +42,6 @@ mysql_free_result( $result ); $device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH; $device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT; -// Allow for margins etc -$device_width -= 4; -$device_height -= 4; - if ( $device_width >= 352 && $device_height >= 288 ) { $video_size = "352x288"; diff --git a/web/zm_xhtml_view_watch.php b/web/zm_xhtml_view_watch.php index d1d3eabb1..b82e0618f 100644 --- a/web/zm_xhtml_view_watch.php +++ b/web/zm_xhtml_view_watch.php @@ -29,12 +29,6 @@ if ( !$result ) $monitor = mysql_fetch_assoc( $result ); mysql_free_result( $result ); -if ( !isset($scale) ) - $scale = ZM_WEB_DEFAULT_SCALE; - -$width_scale = ($scale