File: eng_conv.c

package info (click to toggle)
gtkatlantic 0.4.2-3
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 4,236 kB
  • ctags: 745
  • sloc: sh: 8,786; ansic: 8,311; xml: 191; makefile: 40
file content (73 lines) | stat: -rw-r--r-- 1,926 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 *     gtkatlantic - the gtk+ monopd client, enjoy network monopoly games
 *
 *
 *  Copyright (C) 2002-2004 Rochet Sylvain
 *
 *  gtkatlantic 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 <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <glib.h>
#include <string.h>

#include "engine.h"


void eng_conv_8_to_mask(guchar * in, guchar * out, guint32 nb_pixel) {
   
	guint32 i, size_in, size_out;

	size_in  = size_out = calc_buf_size(nb_pixel, 1, 8);

	for(i = 0; i < nb_pixel; i++)  {

		if(in[i] != 0)   out[i] = 0xff;
		else  out[i] = 0x00;
	}
}


void eng_conv_16_to_mask(guchar * in, guchar * out, guint32 nb_pixel) {
   
	guint32 i, size_in, size_out;

	size_in  = calc_buf_size(nb_pixel, 1, 16);
	size_out = calc_buf_size(nb_pixel, 1, 8);

	for(i = 0; i < nb_pixel; i++)  {

		if(in[ i * 2 ]     != 0  ||  in[(i * 2) + 1] != 0)   out[i] = 0xff;
		else out[i] = 0x00;
	}
}


void eng_conv_24_to_mask(guchar * in, guchar * out, guint32 nb_pixel) {
   
	guint32 i, size_in, size_out;   

	size_in  = calc_buf_size_24(nb_pixel, 1);
	size_out = calc_buf_size(nb_pixel, 1, 8);

	for(i = 0; i < nb_pixel; i++)  {

		if(in[ i * 3 ]     != 0  ||  in[(i * 3) + 1] != 0  ||  in[(i * 3) + 2] != 0)   out[i] = 0xff;
		else  out[i] = 0x00;
	}
}