void Module_Rectifier::build_rectified_image(guint8* mybuffer, guint8* mybuffer_rectified)
{
		Tpoint p;
		int i,j,offset,offset2;

		for (i=0; i<IMAGE_HEIGHT; i++){
			for (j=0; j<IMAGE_WIDTH; j++){

				calculate_allocation(j,i,&p);

				offset2 = i*IMAGE_WIDTH+j;
				if (mybuffer_rectified && mybuffer){
					if ((p.x>0) && (p.y>0) && (p.x<=IMAGE_WIDTH) && (p.y<=IMAGE_HEIGHT)){
						/* We copy pixels "known" */
						offset = p.y*IMAGE_WIDTH+p.x;

						mybuffer_rectified[offset2*3] = mybuffer[offset*3];
						mybuffer_rectified[offset2*3+1] = mybuffer[offset*3+1];
						mybuffer_rectified[offset2*3+2] = mybuffer[offset*3+2];
					}else{
						/* We paint pixels "unknown" with white colour */
						mybuffer_rectified[offset2*3] = 255;
						mybuffer_rectified[offset2*3+1] = 255;
						mybuffer_rectified[offset2*3+2] = 255;;

					}
				}
			}
		}
}
Exemple #2
0
static void *
vec_heap_o_reserve_1 (void *vec, int reserve, size_t vec_offset,
		      size_t elt_size, bool exact MEM_STAT_DECL)
{
  struct vec_prefix *pfx = (struct vec_prefix *) vec;
  unsigned alloc = calculate_allocation (pfx, reserve, exact);

  if (!alloc)
    {
      if (pfx)
        vec_heap_free (pfx);
      return NULL;
    }

#ifdef GATHER_STATISTICS
  if (vec)
    free_overhead (pfx);
#endif
  
  vec = xrealloc (vec, vec_offset + alloc * elt_size);
  ((struct vec_prefix *)vec)->alloc = alloc;
  if (!pfx)
    ((struct vec_prefix *)vec)->num = 0;
#ifdef GATHER_STATISTICS
  if (vec)
    register_overhead ((struct vec_prefix *)vec,
    		       vec_offset + alloc * elt_size PASS_MEM_STAT);
#endif
  
  return vec;
}
Exemple #3
0
void *
vec_gc_o_reserve_1 (void *vec, int reserve, size_t vec_offset, size_t elt_size,
		    bool exact MEM_STAT_DECL)
{
  struct vec_prefix *pfx = (struct vec_prefix *) vec;
  unsigned alloc = calculate_allocation (pfx, reserve, exact);
  size_t size;

  if (!alloc)
    {
      if (pfx)
        ggc_free (pfx);
      return NULL;
    }

  /* Calculate the amount of space we want.  */
  size = vec_offset + alloc * elt_size;
  /* Ask the allocator how much space it will really give us.  */
  size = ggc_round_alloc_size (size);
  /* Adjust the number of slots accordingly.  */
  alloc = (size - vec_offset) / elt_size;
  /* And finally, recalculate the amount of space we ask for.  */
  size = vec_offset + alloc * elt_size;

  vec = ggc_realloc_stat (vec, size PASS_MEM_STAT);

  ((struct vec_prefix *)vec)->alloc = alloc;
  if (!pfx)
    ((struct vec_prefix *)vec)->num = 0;

  return vec;
}
Exemple #4
0
void *
vec_o_reserve (void *vec, int reserve, size_t vec_offset, size_t elt_size)
{
  struct vec_prefix *pfx = vec;
  unsigned alloc = calculate_allocation (pfx, reserve);

  if (!alloc)
    return NULL;

  vec = xrealloc (vec, vec_offset + alloc * elt_size);
  ((struct vec_prefix *)vec)->alloc = alloc;
  if (!pfx)
    ((struct vec_prefix *)vec)->num = 0;

  return vec;
}
Exemple #5
0
void *
vec_gc_o_reserve (void *vec, int reserve, size_t vec_offset, size_t elt_size
		   MEM_STAT_DECL)
{
  struct vec_prefix *pfx = vec;
  unsigned alloc = alloc = calculate_allocation (pfx, reserve);
  
  if (!alloc)
    return NULL;
  
  vec = ggc_realloc_stat (vec, vec_offset + alloc * elt_size PASS_MEM_STAT);
  ((struct vec_prefix *)vec)->alloc = alloc;
  if (!pfx)
    ((struct vec_prefix *)vec)->num = 0;
  
  return vec;
}
Exemple #6
0
static void *
vec_gc_o_reserve_1 (void *vec, int reserve, size_t vec_offset, size_t elt_size,
		    bool exact MEM_STAT_DECL)
{
  struct vec_prefix *pfx = (struct vec_prefix *) vec;
  unsigned alloc = calculate_allocation (pfx, reserve, exact);
  
  if (!alloc)
    {
      if (pfx)
        ggc_free (pfx);
      return NULL;
    }
  
  vec = ggc_realloc_stat (vec, vec_offset + alloc * elt_size PASS_MEM_STAT);
  ((struct vec_prefix *)vec)->alloc = alloc;
  if (!pfx)
    ((struct vec_prefix *)vec)->num = 0;
  
  return vec;
}