Example #1
0
static VALUE
writer_initialize(int argc, VALUE *argv, VALUE obj)
{
    VALUE image, opts;
	rb_scan_args(argc, argv, "11", &image, &opts);
    GetImg(image, data, im);
    GetImg(obj, data_new, im_new);

    img_add_dep(data_new, image);
    if (im_copy(im, im_new))
        vips_lib_error();

    return obj;
}
void RtTrackButton::paintCustomEvent(QPaintEvent*) ///*event*/
{
    QPainter painter(this);

    QRect SrcRect = rect();
	QPixmap* pIcon = GetImg(IMG_TRACK_ICON_C1);

    //Set text font
    QFont font(g_strTitleFontFamily, g_iListFontPointSize);
    font.setStyleStrategy(QFont::PreferAntialias);
    painter.setFont(font);

    //Set text color
    painter.setPen(QColor( __TitleTextColor__ ));

    //Draw track color icon
	//TODO: Need change icon when line color finished.
    painter.drawPixmap(ICON_OFFSET_X,((SrcRect.height() - pIcon->height()) / 2) , *pIcon);

    //Draw track name
	QRect TextRect = QRect(TEXT_OFFSET_X, SrcRect.y(), TEXT_WIDTH, SrcRect.height());
	if(m_iListIndex == 0)	//means current track
	{
		painter.drawText(TextRect,Qt::AlignLeft|Qt::AlignVCenter,g_TrackList.currentTrack()->name());
	}
	else if(!g_TrackList.track(m_iListIndex-1)->name().isEmpty())	//other saved tracks
    {
        painter.drawText(TextRect,Qt::AlignLeft|Qt::AlignVCenter,g_TrackList.track(m_iListIndex)->name());
    }
}
Example #3
0
/////////////////////////////////////
// Purpose:	blt given texture
//			make sure you call 
//			TextureBegin first
// Output:	texture blted on screen
// Return:	TRUE if success
/////////////////////////////////////
u32 IgfxTexture::Blt(f32 x, f32 y, const iRect *srcRect, gfxBlt *pBlt)
{
	Vec3D vect(x,y,0);

	D3DXVECTOR3 center(0,0,0);

	PGFXTEXTURE texture = (PGFXTEXTURE)GetImg();

	if(!texture) return FALSE;

	if(pBlt)
	{
		Vec3D scale(1,1,1);
		Vec3D rotCenter(pBlt->rotOfsX,pBlt->rotOfsY,0);

		f32 sW, sH;
	
		if(srcRect)
		{ sW = (f32)(srcRect->right - srcRect->left); sH = (f32)(srcRect->bottom - srcRect->top); }
		else
		{ sW = (f32)m_width; sH = (f32)m_height; }

		if(TESTFLAGS(pBlt->flags, GFXBLT_FLIPH))
		{ scale.x = -1; center.x += sW; }

		if(TESTFLAGS(pBlt->flags, GFXBLT_FLIPV))
		{ scale.y = -1; center.y += sH; }

		if(pBlt->rot != 0 && !TESTFLAGS(pBlt->flags, GFXBLT_ROTABS))
		{ rotCenter.x -= sW/2; rotCenter.y -= sH/2; }

		Matrix scaleRotOfsM(scale.x, 0,       0,       rotCenter.x,
			                0,       scale.y, 0,       rotCenter.y,
							0,       0,       scale.z, rotCenter.z,
							0,       0,       0,       1);

		Matrix rotRotOfsInvTransM; MtxRotateZ(pBlt->rot, &rotRotOfsInvTransM);
		
		rotRotOfsInvTransM._41 = -rotCenter.x;
		rotRotOfsInvTransM._42 = -rotCenter.y;
		rotRotOfsInvTransM._43 = -rotCenter.z;

		Matrix transM; MtxTranslate(&vect, &transM);

		s_pTxtSprite->SetTransform((D3DXMATRIX*)&Matrix(scaleRotOfsM*rotRotOfsInvTransM*transM));
		s_pTxtSprite->Draw(texture, (const RECT*)srcRect, &center, 0, pBlt->clr);

		//g_pTxtSprite->Draw(texture, (const RECT*)srcRect, &scale, &rotCenter, pBlt->rot, &vect, pBlt->clr);
	}
	else
	{
		Matrix mtxIden; MtxIdentity(&mtxIden);
		s_pTxtSprite->SetTransform((D3DXMATRIX*)&mtxIden);
		s_pTxtSprite->Draw(texture, (const RECT*)srcRect, &center, (D3DXVECTOR3*)&vect, 0xffffffff);
	}

	s_pTxtSprite->Flush();

	return TRUE;
}
void CCompChoppyThrower::ReceiveMessage(SMessage &msg) {
	if (msg.m_type == EMT_SHOOT && m_lastShot >= GetCooldown()) {
		SShootMsg &shootMsg = static_cast<SShootMsg &>(msg);
		if (shootMsg.GetWeaponId() == GetId()) {
			SGetWorldMsg worldMsg;
			m_owner->ReceiveMessage(worldMsg);
			CWorld * world = worldMsg.GetWorld();
			SGetRotMsg rotMsg;
			m_owner->ReceiveMessage(rotMsg);
			SGetPosMsg posMsg;
			m_owner->ReceiveMessage(posMsg);
			SGetEnergyMsg getEnergyMsg;
			m_owner->ReceiveMessage(getEnergyMsg);
			if (rotMsg.Modified() && getEnergyMsg.Modified() &&
				getEnergyMsg.GetEnergy() - GetEnergyConsumed() > 0) {
				world->AddEntity(world->GetEntitiesFactory().SpawnEntity(
					new SBotParams(m_owner->GetSide(), GetImg(),
						posMsg.GetX(), posMsg.GetY(), m_botLifeTime, GetDamage(),
						m_speed)));
				SUpdateEnergyMsg updateEnergyMsg(-GetEnergyConsumed());
				m_owner->ReceiveMessage(updateEnergyMsg);
				m_lastShot = 0;
				AudioBuffer * buffer = new AudioBuffer("data/sounds/fusion_blaster_shoot.wav");
				AudioSource * shootAudio = new AudioSource(buffer);
				shootAudio->Play();
			}
		}
	}
}
Example #5
0
static VALUE
png_buf_internal(VALUE obj, VALUE compression, VALUE interlace)
{
#if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 23
    VipsImage *im_out;
    char *buf;
    int length;
    GetImg(obj, data, im);

    if (!(im_out = im_open("writer_png_buf", "p")))
        vips_lib_error();

    if (im_vips2bufpng(im, im_out, NUM2INT(compression), NUM2INT(interlace),
        &buf, &length)) {
		im_close(im_out);
        vips_lib_error();
	}

    im_close(im_out);

    return rb_tainted_str_new(buf, length);
#else
    rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
}
Example #6
0
static VALUE
jpeg_buf_internal(VALUE obj, VALUE quality)
{
    char *buf = NULL;
    int length;

    GetImg(obj, data, im);

#if ATLEAST_VIPS( 7, 28 )
{
    size_t len;

    if (vips_jpegsave_buffer(im, &buf, &len,
        "Q", NUM2INT(quality),
	NULL))
        vips_lib_error();

    /* Argh.
     */
    length = len;
}
#else
    if (im_vips2bufjpeg(im, NULL, NUM2INT(quality), &buf, &length)) 
        vips_lib_error();
#endif

    return rb_tainted_str_new(buf, length);
}
Example #7
0
static VALUE
csv_write_internal(VALUE obj, VALUE path)
{
    GetImg(obj, data, im);

    if (im_vips2csv(im, RSTRING_PTR(path)))
        vips_lib_error();

    return obj;
}
Example #8
0
static VALUE
writer_image(VALUE obj)
{
    GetImg(obj, data, im);

    if(data->deps)
        return data->deps[0];

    return Qnil;
}
Example #9
0
static VALUE
img_cntlines(VALUE obj, int flag) {
    double nolines;
	GetImg(obj, data, im);
    
    if (im_cntlines(im, &nolines, flag))
        vips_lib_error();

    return DBL2NUM(nolines);
}
VALUE
img_histnd(VALUE obj, VALUE bins)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_histnD(im, im_new, NUM2INT(bins)))
        vips_lib_error();

    return new;  
}
Example #11
0
VALUE
img_rank(VALUE obj, VALUE xsize, VALUE ysize, VALUE order)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_rank(im, im_new, NUM2INT(xsize), NUM2INT(ysize), NUM2INT(order)))
        vips_lib_error();

    return new;
}
Example #12
0
VALUE
img_addgnoise(VALUE obj, VALUE sigma)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_addgnoise(im, im_new, NUM2INT(sigma)))
        vips_lib_error();

    return new;
}
Example #13
0
VALUE
img_xyz_to_lab_temp(VALUE obj, VALUE x0, VALUE y0, VALUE z0)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_XYZ2Lab_temp(im, im_new, NUM2DBL(x0), NUM2DBL(y0), NUM2DBL(z0)))
        vips_lib_error();

    return new;
}
Example #14
0
VALUE
img_icc_ac2rc(VALUE obj, VALUE depth, VALUE profile_filename)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_icc_ac2rc(im, im_new, StringValuePtr(profile_filename)))
        vips_lib_error();

    return new;
}
Example #15
0
static VALUE
img_zerox(VALUE obj, int flag)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_zerox(im, im_new, flag))
        vips_lib_error();

    return new;
}
Example #16
0
static VALUE
img_profile(VALUE obj, int dir)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_profile(im, im_new, dir))
        vips_lib_error();

    return new;
}
Example #17
0
VALUE
img_icc_import_embedded(VALUE obj, VALUE intent)
{
	ID id_intent = SYM2ID(intent);
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_icc_import_embedded(im, im_new, img_id_to_intent(id_intent)))
        vips_lib_error();

    return new;
}
Example #18
0
static VALUE
writer_meta_remove(VALUE obj, const char* name)
{
    GetImg(obj, data, im);
#if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 22
	if (im_meta_remove(im, name))
		return Qfalse;
#else
    rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
    return Qtrue;
}
Example #19
0
static VALUE
writer_meta_remove(VALUE obj, const char* name)
{
    GetImg(obj, data, im);
#if ATLEAST_VIPS( 7, 22 )
	if (im_meta_remove(im, name))
		return Qfalse;
#else
    rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
    return Qtrue;
}
Example #20
0
VALUE
img_label_regions(VALUE obj)
{
	int segments;
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_label_regions(im, im_new, &segments))
        vips_lib_error();

    return rb_ary_new3(2, new, segments);
}
Example #21
0
VALUE
img_contrast_surface(VALUE obj, VALUE half_win_size, VALUE spacing)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_contrast_surface(im, im_new, NUM2INT(half_win_size),
		NUM2INT(spacing)))
        vips_lib_error();

    return new;
}
Example #22
0
static VALUE
jpeg_buf_internal(VALUE obj, VALUE quality)
{
    char *buf = NULL;
    int length;

    GetImg(obj, data, im);

    if (im_vips2bufjpeg(im, NULL, NUM2INT(quality), &buf, &length)) 
        vips_lib_error();

    return rb_tainted_str_new(buf, length);
}
Example #23
0
VALUE
img_sharpen(VALUE obj, VALUE mask_size, VALUE x1, VALUE y2, VALUE y3, VALUE m1,
    VALUE m2)
{
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_sharpen(im, im_new, NUM2INT(mask_size), NUM2DBL(x1), NUM2DBL(y2),
		NUM2DBL(y3), NUM2DBL(m1), NUM2DBL(m2)))
        vips_lib_error();

    return new;
}
Example #24
0
VALUE
img_icc_import(VALUE obj, VALUE input_profile_filename, VALUE intent)
{
	ID id_intent = SYM2ID(intent);
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_icc_import(im, im_new, StringValuePtr(input_profile_filename),
		img_id_to_intent(id_intent)))
        vips_lib_error();

    return new;
}
Example #25
0
static VALUE
writer_write_internal(VALUE obj, VALUE path)
{
    VipsImage *out;
    GetImg(obj, data, im);

    if (!(out = im_open(StringValuePtr(path), "w")) || im_copy(im, out))
        vips_lib_error();

    im_close(out);

    return obj;
}
Example #26
0
VALUE
img_icc_export_depth(VALUE obj, VALUE depth, VALUE output_profile_filename,
	VALUE intent)
{
	ID id_intent = SYM2ID(intent);
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

    if (im_icc_export_depth(im, im_new, NUM2INT(depth),
		StringValuePtr(output_profile_filename), img_id_to_intent(id_intent)))
        vips_lib_error();

    return new;
}
Example #27
0
VALUE
img_compass(VALUE obj, VALUE mask)
{
    INTMASK *imask;
	GetImg(obj, data, im);
	OutImg2(obj, mask, new, data_new, im_new);

    mask_arg2mask(mask, &imask, NULL);

    if (im_compass(im, im_new, imask))
        vips_lib_error();

    return new;
}
VALUE
img_histgr(int argc, VALUE *argv, VALUE obj)
{
	VALUE v_bandno;
	int bandno;
	GetImg(obj, data, im);
	OutImg(obj, new, data_new, im_new);

	rb_scan_args(argc, argv, "01", &v_bandno);
	bandno = NIL_P(v_bandno) ? -1 : NUM2INT(v_bandno);

    if (im_histgr(im, im_new, bandno))
        vips_lib_error();

    return new;  
}
Example #29
0
static VALUE
vips_write_internal(VALUE obj, VALUE path)
{
    VipsImage *im_new;
    GetImg(obj, data, im);

    if (!(im_new = (VipsImage *)im_openout(RSTRING_PTR(path))))
        vips_lib_error();

    if (im_copy(im, im_new))
        vips_lib_error();

    im_close(im_new);

    return obj;
}
Example #30
0
static VALUE
writer_meta_set(VALUE obj, const char* name, VALUE str)
{
    GetImg(obj, data, im);

	size_t len = RSTRING_LEN(str);
    void *buf = malloc(len);
    memcpy(buf, RSTRING_PTR(str), len);

    if (im_meta_set_blob(im, name, (im_callback_fn)xfree, buf, len)) {
        xfree(buf);
        vips_lib_error();
    }

    return str;
}