Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
cs_xfm.c
Package: unicap-0.2.19.tar.gz [view]
Upload User: shyika
Upload Date: 2017-11-25
Package Size: 1227k
Code Size: 4k
Category:
Video Capture
Development Platform:
Unix_Linux
- /* unicap
- *
- * Copyright (C) 2004 Arne Caspari ( arne_caspari@users.sourceforge.net )
- *
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- #include <gdk/gdk.h>
- #include <string.h>
- #include <ucil.h>
- #include "cs_xfm.h"
- size_t cs_xfm_get_image_data_size( unicap_format_t *format )
- {
- size_t size = 0;
- switch( format->fourcc )
- {
- case RGB3:
- size = format->size.width * format->size.height * 3;
- break;
- case RGB4:
- size = format->size.width * format->size.height * 4;
- break;
- default:
- size = format->size.width * format->size.height * 3;
- }
- return size;
- }
- void cs_xfm_to_RGB24( unicap_data_buffer_t *data_buffer, guchar *dest )
- {
- switch( data_buffer->format.fourcc )
- {
- case RGB3:
- memcpy( dest, data_buffer->data, data_buffer->buffer_size );
- break;
- /* case RGB4: */
- /* g_warning( "No conversion method for video format!n" ); */
- /* break; */
- default:
- {
- unicap_data_buffer_t target_buffer;
- target_buffer.buffer_size = target_buffer.format.buffer_size = data_buffer->format.size.width *
- data_buffer->format.size.height * 3;
- target_buffer.format.fourcc = UCIL_FOURCC( 'R', 'G', 'B', 0 );
- target_buffer.format.size.width = data_buffer->format.size.width;
- target_buffer.format.size.height = data_buffer->format.size.height;
- target_buffer.data = dest;
- ucil_convert_buffer( &target_buffer, data_buffer );
- }
- }
- }
- void cs_xfm_to_RGB32( unicap_data_buffer_t *data_buffer, guchar *dest )
- {
- switch( data_buffer->format.fourcc )
- {
- case RGB3:
- memcpy( data_buffer->data, dest, data_buffer->buffer_size );
- break;
- case RGB4:
- g_assert( "No conversion" == FALSE );
- break;
- default:
- {
- unicap_data_buffer_t target_buffer;
- target_buffer.buffer_size = target_buffer.format.buffer_size = data_buffer->format.size.width *
- data_buffer->format.size.height * 4;
- target_buffer.format.fourcc = UCIL_FOURCC( 'R', 'G', 'B', 'A' );
- target_buffer.format.size.width = data_buffer->format.size.width;
- target_buffer.format.size.height = data_buffer->format.size.height;
- target_buffer.data = dest;
- ucil_convert_buffer( &target_buffer, data_buffer );
- }
- }
- }
- GdkPixbuf *cs_xfm_new_pixbuf( unicap_data_buffer_t *image_buffer, guchar *image_data )
- {
- GdkPixbuf *pixbuf;
- switch( image_buffer->format.fourcc )
- {
- case RGB3:
- pixbuf = gdk_pixbuf_new_from_data( image_data,
- GDK_COLORSPACE_RGB,
- 0, // alpha
- 8, // bps
- image_buffer->format.size.width,
- image_buffer->format.size.height,
- image_buffer->format.size.width * 3,
- NULL,
- 0 );
- break;
- case RGB4:
- pixbuf = gdk_pixbuf_new_from_data( image_data,
- GDK_COLORSPACE_RGB,
- 1, // alpha
- 8, // bps
- image_buffer->format.size.width,
- image_buffer->format.size.height,
- image_buffer->format.size.width * 4,
- NULL,
- 0 );
- break;
- default:
- {
- unicap_data_buffer_t target_buffer;
- target_buffer.buffer_size = target_buffer.format.buffer_size = image_buffer->format.size.width *
- image_buffer->format.size.height * 3;
- target_buffer.format.fourcc = UCIL_FOURCC( 'R', 'G', 'B', 0 );
- target_buffer.format.size.width = image_buffer->format.size.width;
- target_buffer.format.size.height = image_buffer->format.size.height;
- target_buffer.data = image_data;
- ucil_convert_buffer( &target_buffer, image_buffer );
- pixbuf = gdk_pixbuf_new_from_data( image_data,
- GDK_COLORSPACE_RGB,
- 0, // alpha
- 8, // bps
- image_buffer->format.size.width,
- image_buffer->format.size.height,
- image_buffer->format.size.width * 3,
- NULL,
- 0 );
- }
- break;
- }
- return pixbuf;
- }