void Consumer::copyImageData(void* dst, const void* src)
	{
	if (connection.videoDevice.getRequestedPalette() == connection.videoDevice.getDevicePalette())
		{
		switch (connection.videoDevice.getDevicePalette())
			{
			case paletteGrey:
				copy(dst, src, 1);
				break;

			case paletteRGB:
			case paletteBGR:
				copy(dst, src, 3);
				break;

			case paletteRGBA:
			case paletteABGR:
				copy(dst, src, 4);
				break;

			default:
				throw Miro::Exception("can't copy image: illegal image palette");
			}
		}
	else
		{
		switch (connection.videoDevice.getDevicePalette())
			{
			case paletteRGB:
				if (connection.videoDevice.getRequestedPalette() == paletteBGR)
					swap3(dst, src);
				else
					throw Miro::Exception("can't copy image: incompatible image palette");
				break;

			case paletteBGR:
				if (connection.videoDevice.getRequestedPalette() == paletteRGB)
					swap3(dst, src);
				else
					throw Miro::Exception("can't copy image: incompatible image palette");
				break;

			case paletteRGBA:
				if (connection.videoDevice.getRequestedPalette() == paletteABGR)
					swap4(dst, src);
				else
					throw Miro::Exception("can't copy image: incompatible image palette");
				break;

			case paletteABGR:
				if (connection.videoDevice.getRequestedPalette() == paletteRGBA)
					swap4(dst, src);
				else
					throw Miro::Exception("can't copy image: incompatible image palette");
				break;
			default:
				throw Miro::Exception("can't copy image: incompatible image palette");
			}
		}
	}
void main()
{
	int a = 5;
	int b = 3;
	printf("a = %d", a);
	printf("b = %d", b);
	swap3(a, b);
	printf("a = %d", a);
	printf("b = %d", b);
}
Exemplo n.º 3
0
int main (int argc ,char * * argv)
{
  int u;
  int t;
  u = 17;
  t = -96;
  printf ("before swap3: u = %d , t = %d \n" , u , t);
  swap3 (& u , & t);
  printf ("after  swap3: u = %d , t = %d \n" , u , t);
  return EXIT_SUCCESS;
}
Exemplo n.º 4
0
int main(){
    double a = 5.5;
    double b = 10.5;
    print(a,b);
    swap1(a,b);
    print(a,b);
    swap2(a,b);   // Comment this line out
    print(a,b);   // Comment this line out
    swap3(&a,&b);
    print(a,b);    
    return 0;
}
Exemplo n.º 5
0
void sortatoms(struct Atom *coords, gint left, gint right, gboolean sort) 
{
gint i,last;

    if (left>=right) return;

    swap3(coords, left, (left+right)/2);
  
    last = left;

    for (i=left+1;i<=right;i++) 
	if (sort==1) {
	    if (compare3(coords,i,left)<0) swap3(coords, ++last, i);
	}
	else {
	    if (compare3(coords,i,left)>0) swap3(coords, ++last, i);
	}
	 
    swap3(coords, left, last);
    sortatoms(coords, left, last-1, sort);
    sortatoms(coords, last+1, right, sort);
}
Exemplo n.º 6
0
static void lockstep_swap_arrays() {
    auto & r = enabler->renderer;
    swap3(r->screen, r->screen_old, gps->screen);
    swap3(r->screentexpos, r->screentexpos_old, gps->screentexpos);
    swap3(r->screentexpos_addcolor, r->screentexpos_addcolor_old, gps->screentexpos_addcolor);
    swap3(r->screentexpos_grayscale, r->screentexpos_grayscale_old, gps->screentexpos_grayscale);
    swap3(r->screentexpos_cf, r->screentexpos_cf_old, gps->screentexpos_cf);
    swap3(r->screentexpos_cbr, r->screentexpos_cbr_old, gps->screentexpos_cbr);
    gps->screen_limit = gps->screen + gps->dimx * gps->dimy * 4;
}
Exemplo n.º 7
0
int main(void) {

	//check_reference_and_ptr();
	
	int a = 5;
	int b = 10;

	printf("1). before swap, a:	%d, addr:	%p\n", a, &a);
	printf("1). before swap, b:	%d, addr:	%p\n", b, &b);
	swap(a, b);

	printf("1). after swap, a:	%d, addr:	%p\n", a, &a);
	printf("1). after swap, b:	%d, addr:	%p\n", b, &b);


	a = 5;
	b = 10;
	printf("2). before swap, a:	%d, addr:	%p\n", a, &a);
	printf("2). before swap, b:	%d, addr:	%p\n", b, &b);
	swap(&a, &b);

	printf("2). after swap, a:	%d, addr:	%p\n", a, &a);
	printf("2). after swap, b:	%d, addr:	%p\n", b, &b);


	a = 5;
	b = 10;

	printf("3). before swap, a:	%d, addr:	%p\n", a, &a);
	printf("3). before swap, b:	%d, addr:	%p\n", b, &b);
	swap3(&a, &b);

	printf("3). after swap, a:	%d, addr:	%p\n", a, &a);
	printf("3). after swap, b:	%d, addr:	%p\n", b, &b);

	a = 5;
	b = 10;

	printf("4). before swap, a:	%d, addr:	%p\n", a, &a);
	printf("4). before swap, b:	%d, addr:	%p\n", b, &b);
	swap4(a, b);

	printf("4). after swap, a:	%d, addr:	%p\n", a, &a);
	printf("4). after swap, b:	%d, addr:	%p\n", b, &b);

	return 0;

}
Exemplo n.º 8
0
int		ft_readline_p5(t_lst *****lsta, t_lst ****lstb, char *line)
{
	if (ft_strcmp(line, "ss") == 0)
	{
		if (****lsta && ft_comptelem(****lsta) > 1)
			swap5(&lsta);
		if (***lstb && ft_comptelem(***lstb) > 1)
			swap3(&lstb);
		return (1);
	}
	else if (ft_strcmp(line, "rr") == 0)
	{
		if (****lsta && ft_comptelem(****lsta) > 1)
			rotate5(&lsta);
		if (***lstb && ft_comptelem(***lstb) > 1)
			rotate3(&lstb);
		return (1);
	}
	return (0);
}
Exemplo n.º 9
0
int main(void)
{
	printf("-----method 1------\n");
	int a = 5;
	int b = 8;
	printf("a = %d, b = %d\n", a, b);
	//异或交换的缺点 a,b 不能是同一个变量,即不能是同一块内存
	a = a ^ b;
	b = a ^ b;// a ^ b ^ b
	a = a ^ b;// a ^ b ^ a
	printf("a = %d, b = %d\n", a, b);

	printf("-----method 2------\n");
	int c = 5, d = 7;
	printf("c = %d, d = %d\n", c, d);
	int swap;
	swap = c;
	c = d;
	d = swap;
	printf("c = %d, d = %d\n", c, d);

	printf("-----method 3------\n");
	int i = 5, j = 7;
	swap3(&i, &j);

	printf("-----method 4------\n");
	//容易溢出的方式
	int e = 5, f = 7;
	printf("e = %d, f = %d\n", e, f);
	e = e + f;
	f = e - f;
	e = e - f;
	printf("e = %d, f = %d\n", e, f);

	return 0;
}
Exemplo n.º 10
0
void mat3_transpose(mat3_t mat)
{
	swap3(mat, 0, 1);
	swap3(mat, 0, 2);
	swap3(mat, 1, 2);
}
Exemplo n.º 11
0
Arquivo: misc.c Projeto: tomgrean/kash
static void
qsort1(void **base, void **lim, int (*f)(void *, void *))
{
	 void **i, **j;
	 void **lptr, **hptr;
	size_t n;
	int c;

  top:
	n = (lim - base) / 2;
	if (n == 0)
		return;
	hptr = lptr = base+n;
	i = base;
	j = lim - 1;

	for (;;) {
		if (i < lptr) {
			if ((c = (*f)(*i, *lptr)) == 0) {
				lptr --;
				swap2(i, lptr);
				continue;
			}
			if (c < 0) {
				i += 1;
				continue;
			}
		}

	  begin:
		if (j > hptr) {
			if ((c = (*f)(*hptr, *j)) == 0) {
				hptr ++;
				swap2(hptr, j);
				goto begin;
			}
			if (c > 0) {
				if (i == lptr) {
					hptr ++;
					swap3(i, hptr, j);
					i = lptr += 1;
					goto begin;
				}
				swap2(i, j);
				j -= 1;
				i += 1;
				continue;
			}
			j -= 1;
			goto begin;
		}

		if (i == lptr) {
			if (lptr-base >= lim-hptr) {
				qsort1(hptr+1, lim, f);
				lim = lptr;
			} else {
				qsort1(base, lptr, f);
				base = hptr+1;
			}
			goto top;
		}

		lptr -= 1;
		swap3(j, lptr, i);
		j = hptr -= 1;
	}
}