From a0e29e040170a3045be11f11f46e2490c6f18430 Mon Sep 17 00:00:00 2001 From: stan Date: Sat, 12 Apr 2003 17:18:52 +0000 Subject: [PATCH] Added RGB565 format. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@472 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm_local_camera.cpp | 68 +++++++++++++++++++++++++++++++++++------ web/zm_html.php | 2 +- 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index eda5dc1f8..194242619 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -101,13 +101,24 @@ void LocalCamera::Initialise() exit(-1); } - if ( (vid_pic.palette = palette) == VIDEO_PALETTE_GREY ) + switch (vid_pic.palette = palette) { - vid_pic.depth = 8; - } - else - { - vid_pic.depth = 24; + case VIDEO_PALETTE_GREY : + { + vid_pic.depth = 8; + break; + } + case VIDEO_PALETTE_RGB565 : + { + vid_pic.depth = 16; + break; + } + case VIDEO_PALETTE_RGB24 : + case VIDEO_PALETTE_YUV420P : + { + vid_pic.depth = 24; + break; + } } if( ioctl( m_videohandle, VIDIOCSPICT, &vid_pic ) ) @@ -547,7 +558,7 @@ int LocalCamera::PostCapture( Image &image ) v1_ptr = v_plane; int size = Y_size*3; int r,g,b; - for ( int i = 0; i < size; i++ ) + for ( int i = 0; i < size; i += 3 ) { y = *y_ptr++; u = *u1_ptr++; @@ -564,21 +575,58 @@ int LocalCamera::PostCapture( Image &image ) buffer = temp_buffer; break; } + case VIDEO_PALETTE_RGB565 : + { + int size = width*height*2; + unsigned char r,g,b; + unsigned char *s_ptr = buffer; + unsigned char *d_ptr = temp_buffer; + for ( int i = 0; i < size; i += 2 ) + { + //r = ((*(s_ptr+1))<<3)&0xf8; + //g = (((*s_ptr)<<5)|(*(s_ptr+1)>>3))&0xf8; + //b = (*s_ptr)&0xf8; + b = ((*s_ptr)<<3)&0xf8; + g = (((*(s_ptr+1))<<5)|((*s_ptr)>>3))&0xf8; + r = (*(s_ptr+1))&0xf8; + + *d_ptr++ = r; + *d_ptr++ = g; + *d_ptr++ = b; + s_ptr += 2; + } + buffer = temp_buffer; + break; + } case VIDEO_PALETTE_RGB24 : { if ( ZM_LOCAL_BGR_INVERT ) { int size = width*height*3; + unsigned char *s_ptr = buffer; + unsigned char *d_ptr = temp_buffer; for ( int i = 0; i < size; i += 3 ) { - temp_buffer[i] = buffer[i+2]; - temp_buffer[i+1] = buffer[i+1]; - temp_buffer[i+2] = buffer[i]; + *d_ptr++ = *(s_ptr+2); + *d_ptr++ = *(s_ptr+1); + *d_ptr++ = *s_ptr; + s_ptr += 3; } } buffer = temp_buffer; break; } + case VIDEO_PALETTE_GREY : + { + int size = width*height; + for ( int i = 0; i < size; i++ ) + { + if ( buffer[i] < 16 ) + Info(( "Lo grey %d", buffer[i] )); + if ( buffer[i] > 235 ) + Info(( "Hi grey %d", buffer[i] )); + } + } default : // Everything else is straightforward, for now. { break; diff --git a/web/zm_html.php b/web/zm_html.php index 0e0c1da9b..60f1cce9f 100644 --- a/web/zm_html.php +++ b/web/zm_html.php @@ -2063,7 +2063,7 @@ function configureButton(form,name) $monitor[FPSReportInterval] = 1000; $monitor[RefBlendPerc] = 10; } - $local_palettes = array( "Greyscale"=>1, "RGB24"=>4, "YUV420P"=>15 ); + $local_palettes = array( "Grey"=>1, "RGB24"=>4, "RGB565"=>3, "YUV420P"=>15 ); $remote_palettes = array( "8 bit greyscale"=>1, "24 bit colour"=>4 ); ?>