示例#1
0
void MatCache::set_yuv422(uint8_t *y, int rs_y,
						  uint8_t *u, int rs_u, uint8_t *v, int rs_v)
{
	invalidate();

	cv::Mat y_mat(height, width, CV_8UC1, (void*)y, rs_y);
	update_image("gray_8u", y_mat);
	cv::Mat u_mat(height / 2, width / 2, CV_8UC1, (void*)u, rs_u);
	update_image("yuv422_u_8u", u_mat);
	cv::Mat v_mat(height / 2, width / 2, CV_8UC1, (void*)v, rs_v);
	update_image("yuv422_v_8u", v_mat);
}
示例#2
0
文件: main.c 项目: mastensg/gamma
int
main(int argc, char **argv) {
    if(argc != 2)
        errx(EXIT_FAILURE, "no input files");

    pthread_mutex_init(&mutex_update_image, NULL);

    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_t inotify_thread;
    if(pthread_create(&inotify_thread, &attr, monitor_file, argv[1]))
        err(EXIT_FAILURE, "pthread_create");

    font_init();
    screen_init();
    update_image(argv[1]);

    for(;;) {
        handle_events();
        draw();
    }

    SDL_Quit();

    return EXIT_SUCCESS;
}
void fractFunc::draw_aa(float min_progress, float max_progress)
{
    int w = im->Xres();
    int h = im->Yres();

    reset_counts();

    float delta = (max_progress - min_progress)/2.0;

    // if we have multiple threads,make sure they don't modify
    // pixels the other thread will look at - that wouldn't be 
    // an error per se but would make drawing nondeterministic,
    // which I'm trying to avoid
    // We do this by drawing every even line, then every odd one.

    for(int i = 0; i < 2 ; ++i)
    {
	set_progress_range(
	    min_progress + delta * i,
	    min_progress + delta * (i+1));

	reset_progress(0.0);
        last_update_y = 0;

        for(int y = i; y < h ; y+= 2) 
	{
	    worker->row_aa(0,y,w);
	    if(update_image(y))
	    {
		break;
	    }
        }
        reset_progress(1.0);
    }
}
示例#4
0
/////////////////////////////////////////////////////////
// get the image at <m_frame> from the buffer
// and insert it into the gemchain
/////////////////////////////////////////////////////////
void pix_buffer_read :: render(GemState*state)
{
  if(m_needsupdate) {
    update_image();
  }


  // if we don't have an image, just return
  if (!m_haveImage) {
    return;
  }

  /* push the incoming state->image into a temporary memory */
  state->get(GemState::_PIX, orgPixBlock);

  /*
    pd_findbyclass costs at least 2 if's
    if m_bindname is also used for other classes too, we get an
    additional penalty for traversing the list of classes;
    all in all, msp has done a good job
  */
  if (NULL==pd_findbyclass(m_bindname, pix_buffer_class)) {
    return;
  }

  state->set(GemState::_PIX, &m_pixBlock);

}
示例#5
0
int main(int argc, char *argv[]) {
	pthread_t 		thread;

	/* init threads */
    g_thread_init (NULL);
    gdk_threads_init ();
    gdk_threads_enter ();

    gtk_init(&argc, &argv);

    initApp();

    appdata->program = HILDON_PROGRAM(hildon_program_get_instance());
    g_set_application_name("Webview");

    appdata->window = HILDON_WINDOW(hildon_window_new());
    hildon_program_add_window(appdata->program, appdata->window);


    create_menu(appdata->window);
    build_interface(appdata->window);

    /* Connect signal to X in the upper corner */
    g_signal_connect(G_OBJECT(appdata->window), "delete_event", G_CALLBACK(destroy), NULL);

	update_image();
	load_settings();

	gtk_widget_show_all(GTK_WIDGET(appdata->window));

	if(! start_camera(appdata->window))
	{
		g_warning("Unable to start camera\n");

		GtkWidget *failDialog = gtk_message_dialog_new(NULL,
	     		GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
	     		GTK_BUTTONS_OK,
	     		"Unable to start camera\n");
		gtk_dialog_run (GTK_DIALOG (failDialog));
		gtk_widget_destroy (failDialog);
	}

	if(! start_webserver())
	{
		GtkWidget *failDialog = gtk_message_dialog_new(NULL,
	     		GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
	     		GTK_BUTTONS_OK,
	     		"Unable to start web server.\nCheck server port is not already in use.\n");
		gtk_dialog_run (GTK_DIALOG (failDialog));
		gtk_widget_destroy (failDialog);
	}
	sleep(1);

	pthread_create(&thread, NULL, count_down_thread, NULL);

	gtk_main();

	gdk_threads_leave ();
	return( 0 );
}
示例#6
0
文件: main.c 项目: mastensg/gamma
static void *
monitor_file(void *arg) {
    char *path = arg;

    int fd = inotify_init1(IN_NONBLOCK);
    if(fd == -1)
        err(EXIT_FAILURE, "inotify_init1");

    if(inotify_add_watch(fd, path, IN_CLOSE_WRITE) == -1)
        err(EXIT_FAILURE, "inotify_add_watch");

    for(;;) {
        fd_set set;
        FD_SET(fd, &set);
        if(select(fd + 1, &set, NULL, NULL, NULL) == -1)
            err(EXIT_FAILURE, "select");

        if(!(FD_ISSET(fd, &set)))
            continue;

        int numbytes;
        if(ioctl(fd, FIONREAD, &numbytes) == -1)
            err(EXIT_FAILURE, "ioctl");

        char *buf[65536];
        if(read(fd, buf, sizeof(buf)) == -1)
            err(EXIT_FAILURE, "read");

        update_image(path);
    }

    return NULL;
}
示例#7
0
static void
refresh_button_clicked(GtkWidget *button, gpointer data)
{

	take_photo(config->image_file);
	sleep(1);
	update_image();
}
示例#8
0
文件: testegl.c 项目: ryumiel/gst-omx
static gboolean
handle_queued_objects (APP_STATE_T * state)
{
    GstMiniObject *object = NULL;

    g_mutex_lock (&state->queue_lock);
    if (state->flushing) {
        g_cond_broadcast (&state->cond);
        goto beach;
    } else if (g_async_queue_length (state->queue) == 0) {
        goto beach;
    }

    if ((object = g_async_queue_try_pop (state->queue))) {
        if (GST_IS_BUFFER (object)) {
            GstBuffer *buffer = GST_BUFFER_CAST (object);
            update_image (state, buffer);
            render_scene (state);
            gst_buffer_unref (buffer);
            if (!SYNC_BUFFERS) {
                object = NULL;
            }
        } else if (GST_IS_QUERY (object)) {
            GstQuery *query = GST_QUERY_CAST (object);
            GstStructure *s = (GstStructure *) gst_query_get_structure (query);

            if (gst_structure_has_name (s, "not-used")) {
                g_assert_not_reached ();
            } else {
                g_assert_not_reached ();
            }
        } else if (GST_IS_EVENT (object)) {
            GstEvent *event = GST_EVENT_CAST (object);
            g_print ("\nevent %p %s\n", event,
                     gst_event_type_get_name (GST_EVENT_TYPE (event)));

            switch (GST_EVENT_TYPE (event)) {
            case GST_EVENT_EOS:
                flush_internal (state);
                break;
            default:
                break;
            }
            gst_event_unref (event);
            object = NULL;
        }
    }

    if (object) {
        state->popped_obj = object;
        g_cond_broadcast (&state->cond);
    }

beach:
    g_mutex_unlock (&state->queue_lock);

    return FALSE;
}
示例#9
0
void Image_controls::on_modulate_spin_box__valueChanged(double value)
{
	int slider_value = static_cast<int>(value * 100.0);

	Signal_blocker blocker(ui->modulate_spin_box_);
	ui->modulate_slider_->setValue(slider_value);

	update_image();
}
示例#10
0
void MainWindow::on_pushButton_clicked()
{
    if (!ui->label_6->isVisible()) {
        billiard->balls[0][0] = billiard->X_size/2;
        billiard->balls[0][1] = billiard->Y_size/4;
        billiard->balls[0][4] = 1;
        update_image();
    }
}
示例#11
0
void EtagStore::get_value_of_impl(const std::string& key,
                                  const std::string& def) {
    {
        boost::mutex::scoped_lock lock(resource_->cookie_to_etag_mutex_);
        resource_->cookie_to_etag_[cookie_value_].def = def;
    }
    key_ = key;
    update_image();
}
示例#12
0
void Image_controls::on_modulate_slider__valueChanged(int value)
{
	double spin_box_value = static_cast<double>(value) / 100.0;

	Signal_blocker blocker(ui->modulate_slider_);
	ui->modulate_spin_box_->setValue(spin_box_value);

	update_image();
}
示例#13
0
//Handle updating the displayed image from a given midi message
static void midi_update_image(int midi_note,int velocity)
{
    if(velocity > 0)
    {
        switch(midi_note)
        {
            case C4:
                //printf("%c",event->keyval);
                update_image("c4.jpg");
                break;

            case D4:
                //printf("%c",event->keyval);
                update_image("d4.jpg");
                break;

            case E4:
                //printf("%c",event->keyval);
                update_image("e4.jpg");
                break;

            case F4:
                //printf("%c",event->keyval);
                update_image("f4.jpg");
                break;

            case G4:
                //printf("%c",event->keyval);
                update_image("g4.jpg");
                break;

            case A5:
                //printf("%c",event->keyval);
                update_image("a5.jpg");
                break;

            case B5:
                //printf("%c",event->keyval);
                update_image("b5.jpg");
                break;

            case C5:
                //printf("%c",event->keyval);
                update_image("c5.jpg");
                break;

            case 96:
                //printf("%c",event->keyval);
                gtk_exit(0);
                break;
        }
    }

}
示例#14
0
void Image_controls::on_image_source_combo_box__currentIndexChanged(int index)
{
	if (0 == index)
	{
		update_constant();
	}
	else
	{
		update_image();
	}
}
示例#15
0
void EtagStore::set_item_impl(const std::string& key,
                              const std::string& value) {
    {
        boost::mutex::scoped_lock lock(resource_->cookie_to_etag_mutex_);
        typedef EtagStoreResource::Etag Etag;
        Etag& etag = resource_->cookie_to_etag_[cookie_value_];
        etag.to_client = value;
    }
    key_ = key;
    update_image();
}
示例#16
0
void MainWindow::pull(double x1, double y1, double x2, double y2, double speed_factor)
{
    QString str;
    if (!ui->label_6->isVisible()){
        if (N_p == 0) {
            ui->label_2->setText("<FONT COLOR=#FF0000>Player 1</FONT>");
            ui->label_3->setText("<FONT COLOR=#000000>Player 2</FONT>");
        }

        if (N_p == 1) {
            ui->label_2->setText("<FONT COLOR=#000000>Player 1</FONT>");
            ui->label_3->setText("<FONT COLOR=#FF0000>Player 2</FONT>");
        }

        double sp = billiard->pull(x1, y1, x2, y2, speed_factor);
        str.setNum(sp);
        ui->textEdit->setText(str);
        ui->label_6->setVisible(1);
        while (!stop_cond() && !stop) {
            QApplication::processEvents();
            billiard->move();
            update_image();
        }

        if ((balls - billiard->left_balls) > 0) {
            p[N_p] += (balls - billiard->left_balls);
        } else {
            // N_p = ~N_p;
            if (N_p == 1)
                N_p = 0;
            else {
                if (N_p == 0)
                    N_p = 1;
            }
        }

        balls = billiard->left_balls;
        ui->label_6->setVisible(0);
        str.setNum(p[0]);
        ui->label_4->setText(str);
        str.setNum(p[1]);
        ui->label_5->setText(str);
        if (N_p == 0) {
            ui->label_2->setText("<FONT COLOR=#FF0000>Player 1</FONT>");
            ui->label_3->setText("<FONT COLOR=#000000>Player 2</FONT>");
        }

        if (N_p == 1) {
            ui->label_2->setText("<FONT COLOR=#000000>Player 1</FONT>");
            ui->label_3->setText("<FONT COLOR=#FF0000>Player 2</FONT>");
        }
    }
}
示例#17
0
/////////////////////////////////////////////////////////
// postrender
/////////////////////////////////////////////////////////
void pix_buffer_read :: postrender(GemState *state)
{
  m_pixBlock.newimage = 0;

  // auto-mode logic:
  if(m_auto > 0.00001 || m_auto < -0.00001) {
    m_frame+=m_auto;
    update_image();
  }

  /* restore the original incoming image */
  state->set(GemState::_PIX, orgPixBlock);
}
示例#18
0
void MatCache::set_cv_mat(const cv::Mat &image)
{
	invalidate();

	af_assert(image.depth() == CV_8U);
	if (image.channels() == 1)
		update_image("gray_8u", image);
	else if (image.channels() == 3)
	{
		cv::Mat mat;
		cv::cvtColor(image, mat, CV_BGR2RGB);
		update_image("rgb_8u", mat);
	}
	else if (image.channels() == 4)
	{
		cv::Mat mat;
		cv::cvtColor(image, mat, CV_BGRA2RGB);
		update_image("rgb_8u", mat);
	}
	else
		aifil::except(false, "MatCache: incorrect input channels num: " +
			   std::to_string(image.channels()));
}
void dialogSourceChangedCallback(GimpIntComboBox *widget, PlugInVals *vals) {
	gint value;
#ifdef DEBUG
	g_warning("dialogSourceChangedCallback");
#endif

	if (gimp_int_combo_box_get_active(widget,&value)) {
		vals->image_drawable_id = value;
		vals->output_drawable_id = value;
		update_image(vals);
		renderPreview(vals);


	}
}
示例#20
0
文件: blursk.cpp 项目: PyroOS/Pyro
/* This is the entry point for the pcm view.  Normally it just calls the
 * renderer with the input data.
 */
static void blursk_render_pcm(gint16 data[2][512])
{
	gint	i, imin, imax, start;
	gint32	loudness, delta_sum;

	/* If slow motion, then ignore odd-numbered frames */
	oddeven = !oddeven;
	if (config.slow_motion && oddeven)
		return;

#if 0
	/* if not supposed to do PCM data, then do nothing */
	if (blursk_vp.num_pcm_chs_wanted == 0)
		return;
#endif

	/* Find the maximum and minimum, with the restriction that
	 * the minimum must occur after the maximum.
	 */
	for (i = 1, imin = imax = 0, delta_sum = 0; i < 127 / 2; i++)
	{
		if (data[0][i] < data[0][imin])
			imin = i;
		if (data[0][i] > data[0][imax])
			imin = imax = i;
		delta_sum += abs(data[0][i] - data[0][i - i]);
	}

	/* Triggered sweeps start halfway between min & max */
	start = (imax + imin) / 2;

	/* Compute the loudness.  We don't want to do a full spectrum analysis
	 * to do this, but we can guess the low-frequency sound is proportional
	 * to the maximum difference found (because loud low frequencies need
	 * big signal changes), and that high-frequency sound is proportional
	 * to the differences between adjacent samples.  We want to be sensitive
	 * to both of those, while ignoring the mid-range sound.
	 *
	 * Because we have only one low-frequency difference, but hundreds of
	 * high-frequency differences, we need to give more weight to the
	 * low-frequency difference (even though each high-frequency difference
	 * is small).
	 */
	loudness = (((gint32)data[0][imax] - (gint32)data[0][imin]) * 60 + delta_sum) / 75;

	/* Draw it */
	update_image(loudness, 256, &data[0][start]);
}
示例#21
0
void MainWindow::on_actionStart_triggered()
{
    billiard = new QBilliard;
    billiard->init();
    update_image();
    stop = 0;
    ui->label_2->setVisible(1);
    ui->label_3->setVisible(1);
    ui->label_4->setVisible(1);
    ui->label_5->setVisible(1);

    ui->label->setVisible(1);
    ui->textEdit->setVisible(1);
    ui->pushButton->setVisible(1);
    ui->label_2->setText("<FONT COLOR=#FF0000>Player 1</FONT>");
}
示例#22
0
文件: key_hook.c 项目: vchaillo/rtv1
int				key_hook(int keycode, t_env *e)
{
	if (keycode == ESCAPE || keycode == ESCAPE_MAC)
	{
		if (e->scene)
			delete_scene(e->scene);
		exit(0);
	}
	if (e->scene->mode == MOVE_MODE)
		key_hook_camera(keycode, e->scene->camera);
	else
		key_hook_objects(keycode, e->scene);
	key_hook_light(keycode, e->scene);
	key_hook_scene(keycode, e);
	print_keyhook(keycode, e);
	update_image(e);
	return (0);
}
示例#23
0
Gui::Gui ( int argc, char** argv, QWidget *parent ) :
    QMainWindow ( parent ),
    ui ( new Ui::Gui )
{
  ui->setupUi ( this );
  cvWindow = new CvWindow ( QString ( "cvWindow" ), CV_WINDOW_AUTOSIZE );

  // set the location of 'cvWindow'
  cvWindow->setParent ( ui->frame );

  readSettings();

  social_robot_gui = new SocialRobotGui ( argc, argv );
  qRegisterMetaType< Mat > ( "Mat" );
  connect ( social_robot_gui, SIGNAL ( update_image ( Mat ) ), this, SLOT ( updateImage ( Mat ) ) );
  social_robot_gui->init();
  // If the frame resizes, update the image size
  connect ( ui->frame, SIGNAL ( resizeImage ( QSize ) ), this, SLOT ( updateImageSize ( QSize ) ) );
  updateImageSize ( ui->frame->size() );
}
示例#24
0
void *count_down_thread ()
{
	gchar  buf[1024];
	int countdown = settings->update_interval;

	for (;;)
	{

		sleep(1);

		if(timmer_running == TRUE)
		{
			gdk_threads_enter ();

			if(countdown == 1)
			{
				take_photo(config->image_file);
				sleep(1);
				update_image();

				countdown = settings->update_interval;

			} else
				countdown--;

			g_ascii_dtostr(buf, sizeof (buf), countdown);
			gtk_label_set_label(GTK_LABEL(lblUpdate), buf );

			gdk_threads_leave ();


		} else {
			countdown = settings->update_interval;
		}

	}

	return NULL;

}
示例#25
0
void PropertyDisplay::on_change() {
    switch (prop_->type()) {
        case TypeLong:
            value_ = boost::lexical_cast<std::string>(prop_->get<long>());
            break;
        case TypeDouble:
            value_ = boost::lexical_cast<std::string>(prop_->get<double>());
            break;
        case TypeString:
            value_ = prop_->get<std::string>();
            break;
        case TypeImage:
            update_image();
            break;
        default:
            throw std::runtime_error("Unknown property type in PropertyDisplay::on_change()");
    }
    if (output_ != NULL) {
        output_->label(value_.c_str());
        output_->damage(0xff);
    }
}
示例#26
0
//dev function used to manually trigger image updates
static void button_press_callback( GtkWidget *widget, GdkEventKey *event, gpointer data )
{


    switch(event->keyval)
    {
    case 'a':
        //printf("%c",event->keyval);
        update_image("a.jpg");
        break;

    case 'b':
        //printf("%c",event->keyval);
        update_image("b.jpg");
        break;

    case 'c':
        //printf("%c",event->keyval);
        update_image("c.jpg");
        break;

    case 'd':
        //printf("%c",event->keyval);
        update_image("d.jpg");
        break;

    case 'e':
        //printf("%c",event->keyval);
        update_image("e.jpg");
        break;

    case 'f':
        //printf("%c",event->keyval);
        update_image("f.jpg");
        break;
    }

}
void 
fractFunc::draw(
    int rsize, int drawsize, float min_progress, float max_progress)
{
    if(debug_flags & DEBUG_QUICK_TRACE)
    {
	printf("drawing: %d\n", render_type);
    }
    reset_counts();

    // init RNG based on time before generating image
    time_t now;
    time(&now);
    srand((unsigned int)now);

    int x,y;
    int w = im->Xres();
    int h = im->Yres();

    /* reset progress indicator & clear screen */
    last_update_y = 0;
    reset_progress(min_progress);

    float mid_progress = (max_progress + min_progress)/2.0;
    set_progress_range(min_progress, mid_progress);

    // first pass - big blocks and edges
    for (y = 0 ; y < h - rsize ; y += rsize) 
    {
        // main large blocks 
        for ( x = 0 ; x< w - rsize ; x += rsize) 
        {
            worker->pixel ( x, y, drawsize, drawsize);
        }
        // extra pixels at end of lines
        for(int y2 = y; y2 < y + rsize; ++y2)
        {
            worker->row (x, y2, w-x);
        }
        if(update_image(y)) 
        {
            goto done;
        }
    }
 
    // remaining lines
    for ( ; y < h ; y++)
    {
        worker->row(0,y,w);
        if(update_image(y)) 
        {
            goto done;
        }
    }

    last_update_y = 0;
    reset_progress(0.0);
    set_progress_range(mid_progress, max_progress);

    // fill in gaps in the rsize-blocks
    for ( y = 0; y < h - rsize; y += rsize) {
        for(x = 0; x < w - rsize ; x += rsize) {
            worker->box(x,y,rsize);
        }
        if(update_image(y))
        {
            goto done;
        }
    }

 done:
    /* refresh entire image & reset progress bar */
    reset_progress(1.0);
}
示例#28
0
int main(int argc, char *argv[])
{
   char buf[256];
   PALETTE pal;
   BITMAP *image;
   BITMAP *page[2];
   BITMAP *vimage;
   IMAGE images[MAX_IMAGES];
   int num_images = 4;
   int page_num = 1;
   int done = FALSE;
   int i;

   if (allegro_init() != 0)
      return 1;
   install_keyboard(); 
   install_timer();

   /* see comments in exflip.c */
#ifdef ALLEGRO_VRAM_SINGLE_SURFACE
   if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 2 * 768 + 200) != 0) {
#else
   if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0) != 0) {
#endif
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error setting graphics mode\n%s\n", allegro_error);
      return 1;
   }

   /* read in the source graphic */
   replace_filename(buf, argv[0], "mysha.pcx", sizeof(buf));
   image = load_bitmap(buf, pal);
   if (!image) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error reading %s!\n", buf);
      return 1;
   }

   set_palette(pal);

   /* initialise the images to random positions */
   for (i=0; i<MAX_IMAGES; i++)
      init_image(images+i);

   /* create two video memory bitmaps for page flipping */
   page[0] = create_video_bitmap(SCREEN_W, SCREEN_H);
   page[1] = create_video_bitmap(SCREEN_W, SCREEN_H);

   /* create a video memory bitmap to store our picture */
   vimage = create_video_bitmap(image->w, image->h);

   if ((!page[0]) || (!page[1]) || (!vimage)) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Not enough video memory (need two 1024x768 pages "
		      "and a 320x200 image)\n");
      return 1;
   }

   /* copy the picture into offscreen video memory */
   blit(image, vimage, 0, 0, 0, 0, image->w, image->h);

   while (!done) {
      acquire_bitmap(page[page_num]);

      /* clear the screen */
      clear_bitmap(page[page_num]);

      /* draw onto it */
      for (i=0; i<num_images; i++)
	 blit(vimage, page[page_num], 0, 0, images[i].x, images[i].y,
	      vimage->w, vimage->h);

      textprintf_ex(page[page_num], font, 0, 0, 255, -1,
		    "Images: %d (arrow keys to change)", num_images);

      /* tell the user which functions are being done in hardware */
      if (gfx_capabilities & GFX_HW_FILL)
	 textout_ex(page[page_num], font, "Clear: hardware accelerated",
		    0, 16, 255, -1);
      else
	 textout_ex(page[page_num], font, "Clear: software (urgh, this "
		    "is not good!)", 0, 16, 255, -1);

      if (gfx_capabilities & GFX_HW_VRAM_BLIT)
	 textout_ex(page[page_num], font, "Blit: hardware accelerated",
		    0, 32, 255, -1);
      else
	 textout_ex(page[page_num], font, "Blit: software (urgh, this program "
		    "will run too sloooooowly without hardware acceleration!)",
		    0, 32, 255, -1);

      release_bitmap(page[page_num]);

      /* page flip */
      show_video_bitmap(page[page_num]);
      page_num = 1-page_num;

      /* deal with keyboard input */
      while (keypressed()) {
	 switch (readkey()>>8) {

	    case KEY_UP:
	    case KEY_RIGHT:
	       if (num_images < MAX_IMAGES)
		  num_images++;
	       break;

	    case KEY_DOWN:
	    case KEY_LEFT:
	       if (num_images > 0)
		  num_images--;
	       break;

	    case KEY_ESC:
	       done = TRUE;
	       break;
	 }
      }

      /* bounce the images around the screen */
      for (i=0; i<num_images; i++)
	 update_image(images+i);
   }

   destroy_bitmap(image);
   destroy_bitmap(vimage);
   destroy_bitmap(page[0]);
   destroy_bitmap(page[1]);

   return 0;
}

END_OF_MAIN()
示例#29
0
文件: testegl.c 项目: 01org/gst-omx
static gboolean
handle_queued_objects (APP_STATE_T * state)
{
  GstMiniObject *object = NULL;

  g_mutex_lock (state->queue_lock);
  if (state->flushing) {
    g_cond_broadcast (state->cond);
    goto beach;
  } else if (g_async_queue_length (state->queue) == 0) {
    goto beach;
  }

  if ((object = g_async_queue_try_pop (state->queue))) {
    if (GST_IS_BUFFER (object)) {
      GstBuffer *buffer = GST_BUFFER_CAST (object);
      update_image (state, buffer);
      render_scene (state);
      gst_buffer_unref (buffer);
      if (!SYNC_BUFFERS) {
        object = NULL;
      }
    } else if (GST_IS_QUERY (object)) {
      GstQuery *query = GST_QUERY_CAST (object);
      GstStructure *s = (GstStructure *) gst_query_get_structure (query);

      if (gst_structure_has_name (s, "eglglessink-allocate-eglimage")) {
        GstBuffer *buffer;
        GstVideoFormat format;
        gint width, height;
        GValue v = { 0, };

        if (!gst_structure_get_enum (s, "format", GST_TYPE_VIDEO_FORMAT,
                (gint *) & format)
            || !gst_structure_get_int (s, "width", &width)
            || !gst_structure_get_int (s, "height", &height)) {
          g_assert_not_reached ();
        }

        buffer =
            gst_egl_allocate_eglimage (state,
            GST_EGL_IMAGE_BUFFER_POOL (state->pool)->allocator, format,
            width, height);
        g_value_init (&v, G_TYPE_POINTER);
        g_value_set_pointer (&v, buffer);

        gst_structure_set_value (s, "buffer", &v);
        g_value_unset (&v);
      } else {
        g_assert_not_reached ();
      }
    } else if (GST_IS_EVENT (object)) {
      GstEvent *event = GST_EVENT_CAST (object);
      g_print ("\nevent %p %s\n", event,
          gst_event_type_get_name (GST_EVENT_TYPE (event)));

      switch (GST_EVENT_TYPE (event)) {
        case GST_EVENT_EOS:
          flush_internal (state);
          break;
        default:
          break;
      }
      gst_event_unref (event);
      object = NULL;
    }
  }

  if (object) {
    state->popped_obj = object;
    g_cond_broadcast (state->cond);
  }

beach:
  g_mutex_unlock (state->queue_lock);

  return FALSE;
}
示例#30
0
/////////////////////////////////////////////////////////
// startRendering
/////////////////////////////////////////////////////////
void pix_buffer_read :: startRendering()
{
  update_image();
}