AddressLib/vopio.c
MomVop *initVop(int width, int height, MomImageType atype, MomImageType ytype, MomImageType utype, MomImageType vtype)
{
  MomVop* newvop = 0;
  ulong size;

  newvop = (MomVop *)malloc(sizeof(MomVop));
  if (!newvop) {
    fprintf(stderr,"ERROR : Out of memory");
    //exit(errno);
    return NULL;
  }

  //initialize all channels to NULL
  newvop->a_chan = 0;
  newvop->y_chan = 0;
  newvop->u_chan = 0;
  newvop->v_chan = 0;

  // size of image
  size = width*height;


  if(atype != NONE_TYPE){
		newvop->a_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->a_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}

		newvop->a_chan->data=(MomImageData*)&newvop->a_chan->f;

		newvop->a_chan->data->u = (uchar *)malloc( size*typesize(atype) );
		if (!newvop->a_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->binary_shape = 1;		//Key for alpha plane (1-binary,0-blending)
	    newvop->a_chan->x = width;
	    newvop->a_chan->y = height;
	    newvop->a_chan->upperodd= 0;
	    newvop->a_chan->grid = 's';		//square
	    newvop->a_chan->type = atype;

		// set initial value to 0
		memset( newvop->a_chan->data->u, 0, size*typesize(atype));
  }

  if(ytype != NONE_TYPE){
		newvop->y_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->y_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}

		newvop->y_chan->data=(MomImageData*)&newvop->y_chan->f;

		newvop->y_chan->data->u = (uchar *)malloc( size*typesize(ytype) );
		if (!newvop->y_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->y_chan->x = width;
		newvop->y_chan->y = height;
		newvop->y_chan->upperodd = 0;
		newvop->y_chan->grid = 's';
		newvop->y_chan->type = ytype;

		// set initial value to 0
		memset(newvop->y_chan->data->u, 0, size*typesize(ytype));
  }

  if(utype != NONE_TYPE){
		newvop->u_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->u_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}

		newvop->u_chan->data=(MomImageData*)&newvop->u_chan->f;

		newvop->u_chan->data->u = (uchar *)malloc( size*typesize(utype) );
		if (!newvop->u_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->u_chan->x = width;
		newvop->u_chan->y = height;
		newvop->u_chan->upperodd = 0;
		newvop->u_chan->grid = 's';
		newvop->u_chan->type = utype;

		// set initial value to 0
		memset(newvop->u_chan->data->u, 0, size*typesize(utype));
  }

  if(vtype != NONE_TYPE){
		newvop->v_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->v_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}

		newvop->v_chan->data=(MomImageData*)&newvop->v_chan->f;

		newvop->v_chan->data->u = (uchar *)malloc( size*typesize(vtype) );
		if (!newvop->v_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->v_chan->x = width;
		newvop->v_chan->y = height;
		newvop->v_chan->upperodd = 0;
		newvop->v_chan->grid = 's';
		newvop->v_chan->type = vtype;

		// set initial value to 0
		memset(newvop->v_chan->data->u, 0, size*typesize(vtype));
  }


  newvop->width = width;
  newvop->height = height;
  newvop->arbitrary_shape = 1;
  newvop->pextend = 0;


  return newvop;
}
/**
 * allocate memory for a MomVop image
 * If a type is NONE_TYPE that channel will not be allocated, and will be set to NULL
 * added by mb - 28.06.2008
 **/
allocate memory for a MomVop image
If a type is NONE_TYPE that channel will not be allocated, and will be set to NULL
added by mb - 28.06.2008
allocate memory for a MomVop image If a type is NONE_TYPE that channel will not be allocated and will be set to NULL added by mb - 28 . 06 . 2008
MomVop *initVop(int width, int height, MomImageType atype, MomImageType ytype, MomImageType utype, MomImageType vtype)
{
  MomVop* newvop = 0;
  ulong size;
  newvop = (MomVop *)malloc(sizeof(MomVop));
  if (!newvop) {
    fprintf(stderr,"ERROR : Out of memory");
    return NULL;
  }
  newvop->a_chan = 0;
  newvop->y_chan = 0;
  newvop->u_chan = 0;
  newvop->v_chan = 0;
  size = width*height;
  if(atype != NONE_TYPE){
		newvop->a_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->a_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->a_chan->data=(MomImageData*)&newvop->a_chan->f;
		newvop->a_chan->data->u = (uchar *)malloc( size*typesize(atype) );
		if (!newvop->a_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->binary_shape = 1;		
	    newvop->a_chan->x = width;
	    newvop->a_chan->y = height;
	    newvop->a_chan->upperodd= 0;
	    newvop->a_chan->grid = 's';		
	    newvop->a_chan->type = atype;
		memset( newvop->a_chan->data->u, 0, size*typesize(atype));
  }
  if(ytype != NONE_TYPE){
		newvop->y_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->y_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->y_chan->data=(MomImageData*)&newvop->y_chan->f;
		newvop->y_chan->data->u = (uchar *)malloc( size*typesize(ytype) );
		if (!newvop->y_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->y_chan->x = width;
		newvop->y_chan->y = height;
		newvop->y_chan->upperodd = 0;
		newvop->y_chan->grid = 's';
		newvop->y_chan->type = ytype;
		memset(newvop->y_chan->data->u, 0, size*typesize(ytype));
  }
  if(utype != NONE_TYPE){
		newvop->u_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->u_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->u_chan->data=(MomImageData*)&newvop->u_chan->f;
		newvop->u_chan->data->u = (uchar *)malloc( size*typesize(utype) );
		if (!newvop->u_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->u_chan->x = width;
		newvop->u_chan->y = height;
		newvop->u_chan->upperodd = 0;
		newvop->u_chan->grid = 's';
		newvop->u_chan->type = utype;
		memset(newvop->u_chan->data->u, 0, size*typesize(utype));
  }
  if(vtype != NONE_TYPE){
		newvop->v_chan=(MomImage *)malloc(sizeof(MomImage));
		if (!newvop->v_chan) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->v_chan->data=(MomImageData*)&newvop->v_chan->f;
		newvop->v_chan->data->u = (uchar *)malloc( size*typesize(vtype) );
		if (!newvop->v_chan->data->u) {
			fprintf(stderr,"ERROR : initVop - Memory allocation failed");
			exit(errno);
		}
		newvop->v_chan->x = width;
		newvop->v_chan->y = height;
		newvop->v_chan->upperodd = 0;
		newvop->v_chan->grid = 's';
		newvop->v_chan->type = vtype;
		memset(newvop->v_chan->data->u, 0, size*typesize(vtype));
  }
  newvop->width = width;
  newvop->height = height;
  newvop->arbitrary_shape = 1;
  newvop->pextend = 0;
  return newvop;
}
MomVop * initVop ( int width , int height , MomImageType atype , MomImageType ytype , MomImageType utype , MomImageType vtype ) { MomVop * newvop = 0 ; ulong size ; newvop = ( MomVop * ) malloc ( sizeof ( MomVop ) ) ; if ( ! newvop ) { fprintf ( stderr , " " ) ; return NULL ; } newvop -> a_chan = 0 ; newvop -> y_chan = 0 ; newvop -> u_chan = 0 ; newvop -> v_chan = 0 ; size = width * height ; if ( atype != NONE_TYPE ) { newvop -> a_chan = ( MomImage * ) malloc ( sizeof ( MomImage ) ) ; if ( ! newvop -> a_chan ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> a_chan -> data = ( MomImageData * ) & newvop -> a_chan -> f ; newvop -> a_chan -> data -> u = ( uchar * ) malloc ( size * typesize ( atype ) ) ; if ( ! newvop -> a_chan -> data -> u ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> binary_shape = 1 ; newvop -> a_chan -> x = width ; newvop -> a_chan -> y = height ; newvop -> a_chan -> upperodd = 0 ; newvop -> a_chan -> grid = ' ' ; newvop -> a_chan -> type = atype ; memset ( newvop -> a_chan -> data -> u , 0 , size * typesize ( atype ) ) ; } if ( ytype != NONE_TYPE ) { newvop -> y_chan = ( MomImage * ) malloc ( sizeof ( MomImage ) ) ; if ( ! newvop -> y_chan ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> y_chan -> data = ( MomImageData * ) & newvop -> y_chan -> f ; newvop -> y_chan -> data -> u = ( uchar * ) malloc ( size * typesize ( ytype ) ) ; if ( ! newvop -> y_chan -> data -> u ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> y_chan -> x = width ; newvop -> y_chan -> y = height ; newvop -> y_chan -> upperodd = 0 ; newvop -> y_chan -> grid = ' ' ; newvop -> y_chan -> type = ytype ; memset ( newvop -> y_chan -> data -> u , 0 , size * typesize ( ytype ) ) ; } if ( utype != NONE_TYPE ) { newvop -> u_chan = ( MomImage * ) malloc ( sizeof ( MomImage ) ) ; if ( ! newvop -> u_chan ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> u_chan -> data = ( MomImageData * ) & newvop -> u_chan -> f ; newvop -> u_chan -> data -> u = ( uchar * ) malloc ( size * typesize ( utype ) ) ; if ( ! newvop -> u_chan -> data -> u ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> u_chan -> x = width ; newvop -> u_chan -> y = height ; newvop -> u_chan -> upperodd = 0 ; newvop -> u_chan -> grid = ' ' ; newvop -> u_chan -> type = utype ; memset ( newvop -> u_chan -> data -> u , 0 , size * typesize ( utype ) ) ; } if ( vtype != NONE_TYPE ) { newvop -> v_chan = ( MomImage * ) malloc ( sizeof ( MomImage ) ) ; if ( ! newvop -> v_chan ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> v_chan -> data = ( MomImageData * ) & newvop -> v_chan -> f ; newvop -> v_chan -> data -> u = ( uchar * ) malloc ( size * typesize ( vtype ) ) ; if ( ! newvop -> v_chan -> data -> u ) { fprintf ( stderr , " " ) ; exit ( errno ) ; } newvop -> v_chan -> x = width ; newvop -> v_chan -> y = height ; newvop -> v_chan -> upperodd = 0 ; newvop -> v_chan -> grid = ' ' ; newvop -> v_chan -> type = vtype ; memset ( newvop -> v_chan -> data -> u , 0 , size * typesize ( vtype ) ) ; } newvop -> width = width ; newvop -> height = height ; newvop -> arbitrary_shape = 1 ; newvop -> pextend = 0 ; return newvop ; }
allocate memory for a MomVop image
 If a type is NONE_TYPE that channel will not be allocated, and will be set to NULL
 added by mb - 28.06.2008
allocate memory for a MomVop image If a type is NONE_TYPE that channel will not be allocated and will be set to NULL added by mb - 28 . 06 . 2008
//exit(errno);
 //initialize all channels to NULL
 // size of image
 //Key for alpha plane (1-binary,0-blending)
 //square
 // set initial value to 0
 // set initial value to 0
 // set initial value to 0
 // set initial value to 0
