Exemplo n.º 1
0
int CameraGetFrame(int cameraNum, unsigned char* buf, int pixelCount) {
	if (-1 == fd)
		return -1;

	sqBuffer = (void *)buf;

	/* ToDo: Should fail on wrong sized frame and return frames since last req */

	if (0 > getFrame())
		return 0;

	return 1;
}
Exemplo n.º 2
0
//------------------------------------------------------------------------
void CTextEdit::takeFocus ()
{
	if (platformControl)
		return;
#if TARGET_OS_IPHONE
 	if (getFrame ()->getFocusView () == this)
		return;
#endif
	bWasReturnPressed = false;

	// calculate offset for CViewContainers
	CRect rect (getViewSize ());
	CPoint p (0, 0);
	localToFrame (p);
	rect.offset (p.x, p.y);

	platformControl = getFrame ()->getPlatformFrame ()->createPlatformTextEdit (this);

#if TARGET_OS_IPHONE
	getFrame ()->setFocusView (this);
#endif
}
	void ZoomPanElement::draw(ApplicationData appData, Graphics graphics) const
	{
		Graphics mainGraphics(graphics);
		RectangleD frame = getFrame();
		if(isClippedToFrame())
		{
			mainGraphics.clip(frame);
		}
		drawBackground(appData, mainGraphics);
		drawMain(appData, mainGraphics);
		graphics.translate(frame.x, frame.y);
		drawElements(appData, graphics);
	}
//: Drains any queued frames
OsStatus StreamQueueingFormatDecoder::drain()
{
   uint16_t samples[80] ;

   mbDraining = TRUE ;
   while (getNumQueuedFrames() > 0)
   {
      getFrame(samples) ;
   }
   mbDraining = FALSE ;

   return OS_SUCCESS ;
}
Exemplo n.º 5
0
BOOL CLangModelsDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
	CWnd* pWnd = getFrame();
	if(pWnd) // will be null when just finished import
	{
		ASSERTX(pWnd->IsKindOf(RUNTIME_CLASS(CTabbedTreeChild)));
		((CTabbedTreeChild*)pWnd)->retrieveData(); // get any new data lurking in the interface into our members
	}
	ASSERTX(m_pLang);
	m_pLang->save(lpszPathName);
	SetModifiedFlag(FALSE);
	return TRUE;
}
Exemplo n.º 6
0
Frame* Factory::makeFrame(const string& s) {
	std::map<const string, SDL_Surface *>::iterator it = surfaceMap.find(s);
   SDL_Surface *tempSurface;
   if(it == surfaceMap.end()) {
   	tempSurface = makeSurface(s);
  	}
  	else {
  		tempSurface = getSurface(s);
  	}
  	if(frameMap.count(s) == 0)
		frameMap.insert(std::map<const string, Frame *>::value_type(s, new Frame(tempSurface, io->getScreen(), tempSurface->w, tempSurface->h, 0, 0)));
   return(getFrame(s));
}
Exemplo n.º 7
0
//-----------------------------------------------------------------------------
void UIViewSwitchContainer::setCurrentViewIndex (int32_t viewIndex)
{
	if (controller)
	{
		CView* view = controller->createViewForIndex (viewIndex);
		if (view)
		{
			if (view->getAutosizeFlags () & kAutosizeAll)
			{
				CRect vs (getViewSize ());
				vs.offset (-vs.left, -vs.top);
				view->setViewSize (vs);
				view->setMouseableArea (vs);
			}
			if (animationTime)
			{
				if (getFrame ())
					getFrame ()->getAnimator ()->removeAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex");
				CView* oldView = getView (0);
				if (isAttached () && oldView && getFrame ())
				{
					getFrame ()->getAnimator ()->addAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex", new Animation::ExchangeViewAnimation (oldView, view, Animation::ExchangeViewAnimation::kAlphaValueFade), new Animation::LinearTimingFunction (animationTime));
				}
				else
				{
					removeAll ();
					addView (view);
				}
			}
			else
			{
				CViewContainer::removeAll ();
				CViewContainer::addView (view);
			}
			currentViewIndex = viewIndex;
			invalid ();
		}
	}
}
Exemplo n.º 8
0
//-----------------------------------------------------------------------------
void CDataBrowser::valueChanged (CControl *pControl)
{
	CPoint origOffset = getScrollOffset ();
	CScrollView::valueChanged (pControl);
	CPoint offset = getScrollOffset ();
	if (origOffset != offset)
	{
		switch (pControl->getTag ())
		{
			case kHSBTag:
			{
				if (dbHeader)
				{
					CRect viewSize = dbHeader->getViewSize (viewSize);
					CCoord width = viewSize.getWidth ();
					viewSize.left = offset.x;
					viewSize.setWidth (width);
					dbHeader->setViewSize (viewSize);
					dbHeader->setMouseableArea (viewSize);
					dbHeader->invalid ();
				}
				break;
			}
		}
		if (isAttached () && (mouseDownView == dbView || mouseDownView == 0))
		{
			CPoint where;
			getFrame ()->getCurrentMouseLocation (where);
			if (getFrame ()->getViewAt (where, true) == dbView)
			{
				int32_t row = -1;
				int32_t column = -1;
				dbView->frameToLocal (where);
				dbView->getCell (where, row, column);
				db->dbOnMouseMoved (where, getFrame ()->getCurrentMouseButtons (), row, column, this);
			}
		}
	}
}
Exemplo n.º 9
0
void AGENT::draw(DISPLAY* display)
{
	int drawX = display->toScreenX((int) x);
	int drawY = display->toScreenY((int) y);

	// Draw
	BITMAP * frame;
	if (!build_data) frame = getFrame();
	else frame = build_data->sprite;

	if (highlight) circle(display->buffer, drawX, drawY, unitData->radius * 4 / (build_data ? 2 : 5), makecol(255, 255, 255)); // highlight
	pivot_sprite(display->buffer, frame, drawX, drawY, frame->w / 2, frame->h / 2, itofix( (int) (rotation / 360.0 * 256) ));
}
Exemplo n.º 10
0
void Player::send(sf::Packet& p) {
    p << num << getPos().x << getPos().y << angle << getFrame();
    p << sf::Uint8(sfx.size());
    for (int i=0;i<sfx.size();i++) {
        p << sfx[i];
    }
    sfx.clear();
    p << first;
    if (first) {
        p << classNum << color;
        first = false;
    }
}
Exemplo n.º 11
0
//------------------------------------------------------------------------
int32_t CTextEdit::onKeyDown (VstKeyCode& keyCode)
{
	if (platformControl)
	{
		if (keyCode.virt == VKEY_ESCAPE)
		{
			bWasReturnPressed = false;
			platformControl->setText (text);
			getFrame ()->setFocusView (0);
			looseFocus ();
			return 1;
		}
		else if (keyCode.virt == VKEY_RETURN)
		{
			bWasReturnPressed = true;
			getFrame ()->setFocusView (0);
			looseFocus ();
			return 1;
		}
	}
	return -1;
}
Exemplo n.º 12
0
void *videoCaptureThread(void *p)
{
	int i, len;
	if ( initCamera() < 0 )
	{
		printf("\033[0;31mInit Camera Failed.\033[0m\n");
		return NULL;
	}
	struct timeval tv;
	memset(&videoStream, 0, sizeof(VideoStream));
	while(1)
	{
		if ( recordingVideo == 0 )
		{
			sleep(1);
			continue;
		}
		startCapturing();
		i = 0;
		while (recordingVideo)
		{
			videoStream.frame[videoStream.end].index = i;
			//printf("\rstart %d %d end %d %d", videoStream.start, videoStream.frame[videoStream.start].index,
//								videoStream.end, videoStream.frame[videoStream.end].index);
			fflush(stdout);
			videoStream.frame[videoStream.end].size =
					getFrame(videoStream.frame[videoStream.end].frame);
			gettimeofday(&tv, NULL);
			videoStream.frame[videoStream.end].sec = tv.tv_sec;
			videoStream.frame[videoStream.end].usec = tv.tv_usec;
//			printf("%ld %ld\n", videoStream.frame[videoStream.end].sec, videoStream.frame[videoStream.end].usec);
			/*if ( videoStream.frame[videoStream.end].sec -
					videoStream.frame[videoStream.start].sec >= 10*60 )
			{
//				printf("free ");
				memset(videoStream.frame[videoStream.start].frame, 0, sizeof(unsigned char)*VIDEO_BUFLEN);
				videoStream.start = (videoStream.start+1)%VIDEO_BUFLEN;
			}
			videoStream.end = (videoStream.end+1)%VIDEO_BUFLEN;*/
			videoStream.end++;
			//如果超出缓存长度,则停止录像,退出线程
			if (videoStream.end >= VIDEO_BUFLEN )
			{
				recordingVideo = 0;
			}
			i++;
		}
		stopCapturing();
	}
	return NULL;
}
Exemplo n.º 13
0
//static
QPixmap KThumb::getImage(KUrl url, int frame, int width, int height)
{
    Mlt::Profile profile(KdenliveSettings::current_profile().toUtf8().constData());
    QPixmap pix(width, height);
    if (url.isEmpty()) return pix;

    //"<mlt><playlist><producer resource=\"" + url.path() + "\" /></playlist></mlt>");
    //Mlt::Producer producer(profile, "xml-string", tmp);
    Mlt::Producer *producer = new Mlt::Producer(profile, url.path().toUtf8().constData());
    double swidth = (double) profile.width() / profile.height();
    pix = QPixmap::fromImage(getFrame(producer, frame, (int) (height * swidth + 0.5), width, height));
    delete producer;
    return pix;
}
GtkWidget * AP_UnixFrameImpl::_createStatusBarWindow()
{
#ifdef ENABLE_STATUSBAR
	XAP_Frame* pFrame = getFrame();
	AP_UnixStatusBar * pUnixStatusBar = new AP_UnixStatusBar(pFrame);
	UT_ASSERT(pUnixStatusBar);

	static_cast<AP_FrameData *>(pFrame->getFrameData())->m_pStatusBar = pUnixStatusBar;
	
	return pUnixStatusBar->createWidget();
#else
	return NULL;
#endif
}
Exemplo n.º 15
0
void popFrame(WebMQueuedFrames *queue)
{
  if (queue->size <=0)
    return;
  WebMBufferedFrame* frame = getFrame(queue);
  free(frame->data);
  free(frame);
  //advance all frames in the queue
  int i;
  for (i=1; i < queue->size; i ++)
    queue->queue[i-1] = queue->queue[i];
  queue->size -=1;

}
Exemplo n.º 16
0
		MenuBar::MenuBar(double x, double y, const WideString&label_text, AssetManager*assetManager, const Dictionary&properties) : SpriteActor(x, y)
		{
			addAnimation("MenuBar", new Animation(1, assetManager, "elements/menu_bar.png"));
			changeAnimation("MenuBar", Animation::FORWARD);
			
			autoLayoutMgr.setFrame(getFrame());
			
			Font* font = assetManager->getFont("fonts/default.ttf");
			label_color = Color::BLACK;
			label_actor = new TextActor(label_text, font, label_color, 24, Font::STYLE_PLAIN, TextActor::ALIGN_BOTTOMLEFT);
			autoLayoutMgr.add(RectD(0.05, 0.05, 0.575, 0.95), label_actor);
			
			applyProperties(properties);
		}
void XAP_App::enumerateFrames(UT_Vector & v)
{
	for(UT_sint32 i = 0; i < getFrameCount(); ++i)
	{
		XAP_Frame * pF = getFrame(i);
		if(pF)
		{
			if (v.findItem((void*)pF) < 0)
			{
				v.addItem((void*)pF);
			}
		}
	}
}
Exemplo n.º 18
0
void Bird::animate() {
	const float maxFps = 3.5f;
	const float endtime = 1.2f;
	const float coef = maxFps / (endtime*endtime);
	
	if(started) {
		float val = (timer.getElapsedTime() - skippedTime).asSeconds();
		double freq = CLAMP(maxFps - coef * val*val, 0.0f, maxFps);
		
		setFlapsPerSec(freq);
	}
	
	curFrame = getFrame();
}
Exemplo n.º 19
0
// Things that go in here are things that depend on knowning
// about other languages (transfer)
// Thus, this is called after all language documents have been opened
void CLangModelsDoc::finishCreateData()
{
	// this code was delayed to here instead of readParams
	// as a hack to get around some conflict with
	// pumpMessages of the CDlgProgress which I didn't
	// take enough time to understand.  The down-side
	// is that the window will be shown as default size-location and
	// then resize in front of the user, not very pretty.
	if(!m_sWindowPlacementField.IsEmpty())
	{
		CParseStream stream(m_sWindowPlacementField);
		stream.getWindowPlacement(getFrame());
		getFrame()->Invalidate();
		//didn't work getFrame()->ActivateFrame(SW_SHOW);
	// didn't work to put a maximize into effect	AfxGetMainWnd()->Invalidate();
		m_sWindowPlacementField = "";
	}

	ASSERTX(m_pLang);
	m_pLang->finishCreate();

	// jdh 11/9/99 moved some lines from here to finishCreateInterface()
}
void AP_UnixFrameImpl::_setScrollRange(apufi_ScrollType scrollType, int iValue, gfloat fUpperLimit, gfloat fSize)
{
	GtkAdjustment *pScrollAdjustment = (scrollType == apufi_scrollX) ? m_pHadj : m_pVadj;
	GtkWidget *wScrollWidget = (scrollType == apufi_scrollX) ? m_hScroll : m_vScroll;
	UT_DEBUGMSG(("Scroll Adjustment set to %d upper %f size %f\n",iValue, fUpperLimit, fSize));
	GR_Graphics * pGr = getFrame()->getCurrentView()->getGraphics ();
	XAP_Frame::tZoomType tZoom = getFrame()->getZoomType();
	if(pScrollAdjustment) //this isn't guaranteed in AbiCommand
	{
#if GTK_CHECK_VERSION(2,14,0)
		gtk_adjustment_configure(pScrollAdjustment, iValue, 0.0, fUpperLimit,
                                 pGr->tluD(20.0), fSize, fSize);
#else
		pScrollAdjustment->value = iValue;
		pScrollAdjustment->lower = 0.0;
		pScrollAdjustment->upper = fUpperLimit;
		pScrollAdjustment->step_increment = pGr->tluD(20.0);
		pScrollAdjustment->page_increment = fSize;
		pScrollAdjustment->page_size = fSize;
		g_signal_emit_by_name(G_OBJECT(pScrollAdjustment), "changed");
#endif
	}

	// hide the horizontal scrollbar if the scroll range is such that the window can contain it all
	// show it otherwise
// Hide the horizontal scrollbar if we've set to page width or fit to page.
// This stops a resizing race condition.
//
 	if ((m_hScroll == wScrollWidget) && ((fUpperLimit <= fSize) ||(  tZoom == XAP_Frame::z_PAGEWIDTH) || (tZoom == XAP_Frame::z_WHOLEPAGE)))
	{
 		gtk_widget_hide(wScrollWidget);
	}
 	else if((wScrollWidget != m_vScroll) || !getFrame()->isMenuScrollHidden())
	{
 		gtk_widget_show(wScrollWidget);
	}
}
Exemplo n.º 21
0
void AP_UnixDialog_Styles::event_DeleteClicked(void)
{
	if (m_selectedStyle)
    {
		m_sNewStyleName = "";
        gchar * style = NULL;
		
		GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(m_tvStyles));
		GtkTreeIter iter;
		gtk_tree_model_get_iter(model, &iter, m_selectedStyle);
		gtk_tree_model_get(model, &iter, 0, &style, -1);

		if (!style)
			return; // ok, nothing's selected. that's fine

		UT_DEBUGMSG(("DOM: attempting to delete style %s\n", style));

		if (!getDoc()->removeStyle(style)) // actually remove the style
		{
			const XAP_StringSet * pSS = m_pApp->getStringSet();
			UT_UTF8String s;
			pSS->getValueUTF8 (AP_STRING_ID_DLG_Styles_ErrStyleCantDelete,s);
			const gchar * msg = s.utf8_str();
		
			getFrame()->showMessageBox (static_cast<const char *>(msg),
										XAP_Dialog_MessageBox::b_O,
										XAP_Dialog_MessageBox::a_OK);
			return;
		}

		g_free(style);

		getFrame()->repopulateCombos();
		_populateWindowData(); // force a refresh
		getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT);
    }
}
Exemplo n.º 22
0
FileCaptureInterface::FramePair FileCaptureInterface::getFrame()
{
    FramePair result;

    string name0 = getImageFileName(mCount, 0);
    string name1 = getImageFileName(mCount, 1);

    mVerbose = true;
    if (mVerbose) {
        printf("Grabbing frame from file: %s (%s)\n"
               , name0.c_str()
               , mIsRgb ? "rgb" : "gray");
    }

    if (mIsRgb) {
        result.rgbBufferLeft = BufferFactory::getInstance()->loadRGB24Bitmap(name0);
        result.bufferLeft    = result.rgbBufferLeft->toG12Buffer();

        result.rgbBufferRight = BufferFactory::getInstance()->loadRGB24Bitmap(name1);
        result.bufferRight    = result.rgbBufferRight->toG12Buffer();

    } else {
        result.bufferLeft = BufferFactory::getInstance()->loadG12Bitmap(name0);
        result.bufferRight = BufferFactory::getInstance()->loadG12Bitmap(name1);
    }


  /*  if (result.bufferLeft)
    {
        if (mVerbose) {
            printf("Grabbing frame from file: %s\n", name1.c_str());
        }

        result.bufferRight = BufferFactory::getInstance()->loadG12Bitmap(name1);
    }*/

    if (result.bufferLeft == NULL && result.bufferRight == NULL)
    {
        result.freeBuffers();
        if (mVerbose) {
            printf("Files not found, resetting to first image in the sequence.\n");
        }
        resetImageFileCounter();
        return getFrame();
    }

    increaseImageFileCounter();
    return result;
}
Exemplo n.º 23
0
void Animation::drawFrame(BITMAP *dest, int frame, int x, int y, bool hflip, bool vflip)
{
	BITMAP *src = getFrame(frame);

	if (hflip && vflip) {
		draw_sprite_vh_flip(dest, src, x, y);
	} else if (hflip && !vflip) {
		draw_sprite_h_flip(dest, src, x, y);
	} else if (!hflip && vflip) {
		draw_sprite_v_flip(dest, src, x, y);
	} else {
		draw_sprite(dest, src, x, y);
	}
	return;
}
Exemplo n.º 24
0
Box* sysGetFrame(Box* val) {
    int depth = 0;
    if (val) {
        if (!PyInt_Check(val)) {
            raiseExcHelper(TypeError, "TypeError: an integer is required");
        }
        depth = static_cast<BoxedInt*>(val)->n;
    }

    Box* frame = getFrame(depth);
    if (!frame) {
        raiseExcHelper(ValueError, "call stack is not deep enough");
    }
    return incref(frame);
}
Exemplo n.º 25
0
//------------------------------------------------------------------------
CMouseEventResult COptionMenu::onMouseDown (CPoint& where, const CButtonState& buttons)
{
	lastButton = buttons;
	if (lastButton & (kLButton|kRButton|kApple))
	{
		if (bgWhenClick)
			invalid ();
		getFrame ()->setFocusView (this);
		popup ();
		if (bgWhenClick)
			invalid ();
		return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
	}
	return kMouseEventNotHandled;
}
Exemplo n.º 26
0
bool getFrame(unsigned n, StackFrame *f, std::string *errorMessage)
{
    IInterfacePointer<CIDebugClient> client;
    if (!client.create()) {
        *errorMessage = "Cannot obtain client.";
        return false;
    }
    IInterfacePointer<CIDebugSymbols> symbols(client.data());
    IInterfacePointer<CIDebugControl> control(client.data());
    if (!symbols || !control) {
        *errorMessage = "Cannot obtain required objects.";
        return false;
    }
    return getFrame(symbols.data(), control.data(), n, f, errorMessage);
}
Exemplo n.º 27
0
// jdh 1//9/99 added this so we can re-do the transfer tabs as the user changes display settings
void CLangModelsDoc::updateInterface()
{
	ASSERTX(m_pCurrentInterface);
	ASSERTX(m_pFunctionalInterface);
	ASSERTX(m_pCarlaMenuInterface);
	m_pFunctionalInterface->populateTransferTab(); //setupForLang(m_pLang);
	m_pCarlaMenuInterface->populateTransferTab(); //setupForLang(m_pLang);

	CTabbedTreeChild* pF = getFrame();
	if(pF)
	{
		pF->InterfaceChanged();
		m_pCurrentInterface->SetCurrentTabInt(0);	// just to the data shown isn't out-of-date now (it would be nice if there was a fn just to redraw)
	}
}
Exemplo n.º 28
0
void PointWiseMapping::readRestOfFrame(){
  if( getFrame( getNumberOfReferenceFrames() - 1 )->isDirection() ) plumed_merror("cannot use directions in mapping");
  plumed_dbg_assert( property.size()>0 );

  std::vector<double> labelvals;
  if( !ispath ){
      labelvals.resize( property.size() );
      for(unsigned i=0;i<property.size();++i) parse( property[i], labelvals[i] );
  } else {
      labelvals.resize(1);
      labelvals[0]=static_cast<double>( frames.size() ); 
  }
  low_dim.push_back( labelvals ); 
  plumed_dbg_assert( low_dim.size()==getNumberOfReferenceFrames() );
}
Exemplo n.º 29
0
	Spectrum eval(const BSDFSamplingRecord &bRec, EMeasure measure) const {
		const Intersection& its = bRec.its;
		Intersection perturbed(its);
		perturbed.shFrame = getFrame(its);

		BSDFSamplingRecord perturbedQuery(perturbed,
			perturbed.toLocal(its.toWorld(bRec.wi)),
			perturbed.toLocal(its.toWorld(bRec.wo)), bRec.mode);
		if (Frame::cosTheta(bRec.wo) * Frame::cosTheta(perturbedQuery.wo) <= 0)
			return Spectrum(0.0f);
		perturbedQuery.sampler = bRec.sampler;
		perturbedQuery.typeMask = bRec.typeMask;
		perturbedQuery.component = bRec.component;
		return m_nested->eval(perturbedQuery, measure);
	}
Exemplo n.º 30
0
Box* sysGetFrame(Box* val) {
    int depth = 0;
    if (val) {
        if (!isSubclass(val->cls, int_cls)) {
            raiseExcHelper(TypeError, "TypeError: an integer is required");
        }
        depth = static_cast<BoxedInt*>(val)->n;
    }

    Box* frame = getFrame(depth);
    if (!frame) {
        raiseExcHelper(ValueError, "call stack is not deep enough");
    }
    return frame;
}