Esempio n. 1
0
// Load sid file and setup default rule ids
bool Rule::load (const char *filename, int repeats, bool usage)
{
    SidTuneMod tune(0);
    if (!tune.load(filename))
    {
        m_status = false;
        return false;
    }

    strcpy (m_md5, tune.createMD5 ());
    if (md5_used ())
	    return false;

    for (int i = 0; i < 0x10000; i++)
        m_flags[i] = IGNORED;
    tune.placeSidTuneInC64mem (m_memory);
    { // Setup load image
        const SidTuneInfo &info = tune.getInfo ();
        _image (info.loadAddr, info.c64dataLen, repeats);
    }
    if (usage)
	    _usage (filename, m_md5);

    _eval  ();
    m_status   = true;
    strcpy (m_filename, filename);
    return true;
}
Esempio n. 2
0
void Widget::setTexCoordRegion(point_type x, point_type y, point_type w, point_type h) {
    osg::Image* image = _image();

    if(!image) return;

    point_type tw = image->s();
    point_type th = image->t();

    TexCoordArray* texs = _texs();

    // Set the LOWER_LEFT point.
    XYCoord t(x / tw, y / tw);

    (*texs)[LL] = t;

    // Set the LOWER_RIGHT point.
    t += XYCoord(w / tw, 0.0f);

    (*texs)[LR] = t;

    // Set the UPPER_RIGHT point.
    t += XYCoord(0.0f, h / th);

    (*texs)[UR] = t;

    // Set the UPPER_LEFT point.
    t += XYCoord(-(w / tw), 0.0f);

    (*texs)[UL] = t;
}
Esempio n. 3
0
void Widget::setTexCoordWrapVertical() {
    osg::Image*   image   = _image();
    osg::Texture* texture = _texture();

    if(!image || !texture || image->t() == 0.0f) return;

    texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);

    setTexCoord(0.0f, getHeight() / image->t(), UPPER_LEFT);
    setTexCoord(1.0f, getHeight() / image->t(), UPPER_RIGHT);
}
Esempio n. 4
0
void Widget::setTexCoordWrapHorizontal() {
    osg::Image*   image   = _image();
    osg::Texture* texture = _texture();

    if(!image || !texture || image->s() == 0.0f) return;

    texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);

    setTexCoord(getWidth() / image->s(), 0.0f, LOWER_RIGHT);
    setTexCoord(getWidth() / image->s(), 1.0f, UPPER_RIGHT);
}
Esempio n. 5
0
Image::Image(std::string path, float pCutTop, float pCutLeft, float pCutRight, float pCutBottom)
{
	_path = path;
	_image = cv::imread( path, 1 );
	if( _image.empty() )
	{
		Log::exit_error("Unable to open image: '" + path + "'");
	}

	int difT = _image.rows * pCutTop;
	int difL = _image.cols * pCutLeft;
	int difR = _image.cols * pCutRight;
	int difB = _image.rows * pCutBottom;
	_roi = _image( cv::Rect( difL, difT, _image.cols - ( difR + difL ), _image.rows - ( difB + difT ) ) );

	std::vector< cv::KeyPoint > _keypoints;
	cv::Mat _descriptors;
	std::map< std::string, image_match* > _matches;
}
Esempio n. 6
0
/** \brief Create a new menu item in the current menu
 *
 * Add a menu item along with action.
 */
void MenuManager::Item( const molib::moWCString& path, molib::moMenuItemSPtr item )
{
	molib::moWCString name  	= item->Value("Name");
	molib::moWCString event 	= item->Value("Event");
	molib::moWCString image 	= item->Value("Image");
	molib::moWCString stock_image	= item->Value("StockImage");
	molib::moWCString toolbar	= item->Value("Toolbar");

	if( name.IsEmpty() || event.IsEmpty() )
	{
		std::cerr << "Item " << path.c_str() << " is bad! Important missing elements!" << std::endl;
		exit( 1 );
	}

	if( !image.IsEmpty() )
	{
		ActionManager::ButtonImage _image( image.c_str() );
		AddAction( name.c_str(), event.c_str(), &_image );
	}
	else if( !stock_image.IsEmpty() )
	{
		Gtk::StockID id = TranslateBuiltinStockId( stock_image );
		AddAction( name.c_str(), event.c_str(), id );
	}
	else
	{
		AddAction( name.c_str(), event.c_str() );
	}

	AddMenuItem( event.c_str() );

	if( !toolbar.IsEmpty() )
	{
		const int weight = atoi( toolbar.c_str() );
#ifdef DEBUG
		std::cerr << "toolbar=" << toolbar.c_str() << ", weight=" << weight << endl;
#endif
		f_toolbarItems[weight] = item;
	}
}
Esempio n. 7
0
File: Frame.cpp Progetto: nusus/osg
void Frame::Border::positioned()
{
    osg::Image* image = _image();

    if(!image) return;

    Frame* parent = dynamic_cast<Frame*>(getParent());

    if(!parent || !parent->canTexture()) return;

    point_type w = image->s() / 8.0f;
    point_type h = getHeight();

    if(_border == BORDER_LEFT) setTexCoordRegion(w * 3, 0.0f, w, h);

    else if(_border == BORDER_RIGHT) setTexCoordRegion(w * 4, 0.0f, w, h);

    else if(_border == BORDER_TOP) {
        // TODO: Temporary; fix this.
        point_type tx1 = (w * 2) / image->s();
        point_type tx2 = w / image->s();
        point_type tx3 = getWidth() / w;

        setTexCoord(tx1, tx3,  LL);
        setTexCoord(tx1, 0.0f, LR);
        setTexCoord(tx2, 0.0f, UR);
        setTexCoord(tx2, tx3,  UL);
    }

    else {
        point_type tx1 = (w * 7) / image->s();
        point_type tx2 = (w * 6) / image->s();
        point_type tx3 = getWidth() / w;

        setTexCoord(tx1, tx3,  LL);
        setTexCoord(tx1, 0.0f, LR);
        setTexCoord(tx2, 0.0f, UR);
        setTexCoord(tx2, tx3,  UL);
    }
}
Esempio n. 8
0
Color Widget::getImageColorAtXY(point_type x, point_type y) const {
    const osg::Image* image = _image();

    if(!image) return Color();

    const TexCoordArray* texs = _texs();

    /*
    How do we do this? First we need to make sure our right side is larger
    than our left side and that the top side is larger the bottom; otherwise,
    they're using strange tex coords.

    Then, we find the percent area being used in both dimensions. We multiply
    the XY values by those ratios and then add those values to the "offsets."
    */

    point_type width  = fabs((*texs)[LR].x() - (*texs)[LL].x());
    point_type height = fabs((*texs)[LR].y() - (*texs)[UR].y());

    point_type X = ((x / getWidth()) * width) + (*texs)[LL].x();
    point_type Y = (((getHeight() - y) / getHeight()) * height) + (*texs)[UR].y();

    return image->getColor(TexCoord(X, Y));
}