Bug 381 - Further tidying, mostly to do with device widths.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2048 e3e1d417-86f3-4887-817a-d78f3d33393f
pull/27/merge
stan 2006-11-09 11:48:56 +00:00
parent c95952fd41
commit 8a6d8da1ad
8 changed files with 26 additions and 66 deletions

View File

@ -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

View File

@ -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 );
}
?>

View File

@ -237,17 +237,7 @@ mysql_free_result( $result );
?>
<table style="width: 100%">
<?php
$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 /= $frames_per_line; // Try and get two pics per line
$scale = getDeviceScale( $event['Width'], $event['Height'], $images_per_line );
$count = 0;
if ( version_compare( phpversion(), "4.3.10", ">=") )

View File

@ -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' )

View File

@ -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") );

View File

@ -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 )
{

View File

@ -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";

View File

@ -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<SCALE_BASE)?SCALE_BASE:$scale;
$height_scale = $scale;
$zmu_command = getZmuCommand( " -m $mid -s -f" );
$zmu_output = exec( escapeshellcmd( $zmu_command ) );
list( $status, $fps ) = split( ' ', $zmu_output );
@ -86,15 +80,7 @@ mysql_free_result( $result );
$next_mid = $mon_idx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$mon_idx+1]['Id'];
$prev_mid = $mon_idx==0?$mon_index[(count($monitors)-1)]['Id']:$monitors[$mon_idx-1]['Id'];
$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;
$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 = getDeviceScale( $monitor['Width'], $monitor['Height'] );
$image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) );
?>