• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
  • avdevice
bayer.cpp
Go to the documentation of this file.
1 /*
2  * BAYER2RGB24 ROUTINE TAKEN FROM:
3  *
4  * Sonix SN9C101 based webcam basic I/F routines
5  * Copyright (C) 2004 Takafumi Mizuno <taka-qce@ls-a.jp>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 void bayer2rgb24(unsigned char *dst, unsigned char *src, long int WIDTH, long int HEIGHT)
30 {
31  long int i;
32  unsigned char *rawpt, *scanpt;
33  long int size;
34 
35  rawpt = src;
36  scanpt = dst;
37  size = WIDTH*HEIGHT;
38 
39  for ( i = 0; i < size; i++ )
40  {
41  if ( (i/WIDTH) % 2 == 0 )
42  {
43  if ( (i % 2) == 0 )
44  {
45  // B
46  if ( (i > WIDTH) && ((i % WIDTH) > 0) )
47  {
48  *scanpt++ = (*(rawpt-WIDTH-1)+*(rawpt-WIDTH+1)+*(rawpt+WIDTH-1)+*(rawpt+WIDTH+1))/4; // R
49  *scanpt++ = (*(rawpt-1)+*(rawpt+1)+*(rawpt+WIDTH)+*(rawpt-WIDTH))/4; // G
50  *scanpt++ = *rawpt; // B
51  }
52  else
53  {
54  // first line or left column
55  *scanpt++ = *(rawpt+WIDTH+1); // R
56  *scanpt++ = (*(rawpt+1)+*(rawpt+WIDTH))/2; // G
57  *scanpt++ = *rawpt; // B
58  }
59  }
60  else
61  {
62  // (B)G
63  if ( (i > WIDTH) && ((i % WIDTH) < (WIDTH-1)) )
64  {
65  *scanpt++ = (*(rawpt+WIDTH)+*(rawpt-WIDTH))/2; // R
66  *scanpt++ = *rawpt; // G
67  *scanpt++ = (*(rawpt-1)+*(rawpt+1))/2; // B
68  }
69  else
70  {
71  // first line or right column
72  *scanpt++ = *(rawpt+WIDTH); // R
73  *scanpt++ = *rawpt; // G
74  *scanpt++ = *(rawpt-1); // B
75  }
76  }
77  }
78  else
79  {
80  if ( (i % 2) == 0 )
81  {
82  // G(R)
83  if ( (i < (WIDTH*(HEIGHT-1))) && ((i % WIDTH) > 0) )
84  {
85  *scanpt++ = (*(rawpt-1)+*(rawpt+1))/2; // R
86  *scanpt++ = *rawpt; // G
87  *scanpt++ = (*(rawpt+WIDTH)+*(rawpt-WIDTH))/2; // B
88  }
89  else
90  {
91  // bottom line or left column
92  *scanpt++ = *(rawpt+1); /* R */
93  *scanpt++ = *rawpt; /* G */
94  *scanpt++ = *(rawpt-WIDTH); /* B */
95  }
96  }
97  else
98  {
99  // R
100  if ( i < (WIDTH*(HEIGHT-1)) && ((i % WIDTH) < (WIDTH-1)) )
101  {
102  *scanpt++ = *rawpt; // R
103  *scanpt++ = (*(rawpt-1)+*(rawpt+1)+*(rawpt-WIDTH)+*(rawpt+WIDTH))/4; // G
104  *scanpt++ = (*(rawpt-WIDTH-1)+*(rawpt-WIDTH+1)+*(rawpt+WIDTH-1)+*(rawpt+WIDTH+1))/4; // B
105  }
106  else
107  {
108  // bottom line or right column
109  *scanpt++ = *rawpt; /* R */
110  *scanpt++ = (*(rawpt-1)+*(rawpt-WIDTH))/2; /* G */
111  *scanpt++ = *(rawpt-WIDTH-1); /* B */
112  }
113  }
114  }
115  rawpt++;
116  }
117 }
118 
bayer2rgb24
void bayer2rgb24(unsigned char *dst, unsigned char *src, long int WIDTH, long int HEIGHT)
Definition: bayer.cpp:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal