Example #1
0
int
im_rotquad( IMAGE *in, IMAGE *out )
{
	IMAGE *t[6];
	int xd = in->Xsize / 2;
	int yd = in->Ysize / 2;

	if( in->Xsize < 2 || in->Ysize < 2 )
		return( im_copy( in, out ) );

	if( im_open_local_array( out, t, 6, "im_rotquad-1", "p" ) ||
		/* Extract 4 areas.
		 */
		im_extract_area( in, t[0], 0, 0, xd, yd ) ||
		im_extract_area( in, t[1], xd, 0, in->Xsize - xd, yd ) ||
		im_extract_area( in, t[2], 0, yd, xd, in->Ysize - yd ) ||
		im_extract_area( in, t[3], xd, yd, 
			in->Xsize - xd, in->Ysize - yd ) ||
	
		/* Reassemble, rotated.
		 */
		im_insert( t[3], t[2], t[4], in->Xsize - xd, 0 ) ||
		im_insert( t[1], t[0], t[5], in->Xsize - xd, 0 ) ||
		im_insert( t[4], t[5], out, 0, in->Ysize - yd ) )
		return( -1 );

	out->Xoffset = xd;
	out->Yoffset = yd;

	return( 0 );
}
Example #2
0
void addNewNebula(dbref executor, int index, const char* name, double radius, double x, double y, double z, char *buff, char **bp)
{
	aspace_borders* newNebula;
	newNebula = im_find(nebula_map, index);
	
	if (newNebula != NULL) {
		safe_str("#-1 NEBULA # ALREADY IN USE", buff, bp);
		return;
	}
		
	newNebula = mush_malloc(sizeof(aspace_borders), "nebula_info");
	
	newNebula->name = mush_strdup(name, "spacenebula_name");
	newNebula->empire_id = 0;
	newNebula->radius = radius;
	newNebula->x = x;
	newNebula->y = y;
	newNebula->z = z;
	
	if( im_insert(nebula_map, index, newNebula )) {
		safe_str("New nebula Created.", buff, bp);
		write_spacelog(executor, executor, tprintf("Nebula Created: %s", newNebula->name));
	} else
		safe_str("#-1 NEBULA NOT CREATED.", buff, bp);
}
Example #3
0
/* Call im_insert via arg vector.
 */
static int
insert_vec( im_object *argv )
{
	int x = *((int *) argv[3]);
	int y = *((int *) argv[4]);

	return( im_insert( argv[0], argv[1], argv[2], x, y ) );
}
Example #4
0
/**
 * im_tbjoin:
 * @top: image to go on top
 * @bottom: image to go on bottom
 * @out: output image
 *
 * Join @top and @bottom together, up-down. If one is wider than the
 * other, @out will be has wide as the smaller.
 *
 * If the number of bands differs, one of the images 
 * must have one band. In this case, an n-band image is formed from the 
 * one-band image by joining n copies of the one-band image together, and then
 * the two n-band images are operated upon.
 *
 * The two input images are cast up to the smallest common type (see table 
 * Smallest common format in 
 * <link linkend="VIPS-arithmetic">arithmetic</link>).
 *
 * See also: im_insert(), im_tbjoin().
 *
 * Returns: 0 on success, -1 on error
 */
int 
im_tbjoin( IMAGE *top, IMAGE *bottom, IMAGE *out )
{
	IMAGE *t1;

	/* Paste top and bottom together, cut off any leftovers.
	 */
	if( !(t1 = im_open_local( out, "im_tbjoin:1", "p" )) ||
		im_insert( top, bottom, t1, 0, top->Ysize ) ||
		im_extract_area( t1, out, 
			0, 0, IM_MIN( top->Xsize, bottom->Xsize ), t1->Ysize ) )
		return( -1 );

	out->Xoffset = 0;
	out->Yoffset = top->Ysize;

	return( 0 );
}
Example #5
0
int
im__tbmerge( IMAGE *ref, IMAGE *sec, IMAGE *out, int dx, int dy, int mwidth )
{  
	Overlapping *ovlap;

	if( dy > 0 || dy < 1 - ref->Ysize ) {
		/* No overlap, use insert instead.
		 */
  		if( im_insert( ref, sec, out, -dx, -dy ) )
			return( -1 );
		out->Xoffset = -dx;
		out->Yoffset = -dy;

		return( 0 );
	}

	/* Build state for this join.
	 */
	if( !(ovlap = build_tbstate( ref, sec, out, dx, dy, mwidth )) )
		return( -1 );

	/* Prepare the output IMAGE.
	 */ 
	if( im_cp_descv( out, ref, sec, NULL ) )
		return( -1 );
	out->Xsize = ovlap->oarea.width;
	out->Ysize = ovlap->oarea.height;
	out->Xoffset = ovlap->sarea.left;
	out->Yoffset = ovlap->sarea.top;

	/* Set demand hints. 
	 */
	if( im_demand_hint( out, IM_THINSTRIP, ref, sec, NULL ) )
		return( -1 );

	/* Generate!
	 */
	if( im_generate( out,
		im__start_merge, im__merge_gen, im__stop_merge, ovlap, NULL ) )
		return( -1 );

	return ( 0 );
}
Example #6
0
void addNewBorder(dbref executor, int border_number, const char* name, double radius, double x, double y, double z, char *buff, char **bp)
{
	aspace_borders* newBorder;
	newBorder = im_find(border_map, border_number);
	if (newBorder != NULL) {
		safe_str("#-1 BORDER ALREADY EXISTS", buff, bp);
		return;
	}
		
	newBorder = mush_malloc(sizeof(aspace_borders), "border_info");
	
	newBorder->name = mush_strdup(name, "spaceborder_name");
	newBorder->empire_id = 0;
	newBorder->radius = radius;
	newBorder->x = x;
	newBorder->y = y;
	newBorder->z = z;
	
	if( im_insert(border_map, border_number, newBorder )) {
		safe_str("New Border Created.", buff, bp);
		write_spacelog(executor, executor, tprintf("Border Created: %s", newBorder->name));
	} else
		safe_str("#-1 BORDER NOT CREATED.", buff, bp);
}