Пример #1
0
 void CImgWidget::setImage32(cimg_library::CImg<uint32> * im,int nbRounds)
     {
     std::lock_guard<std::recursive_mutex> lock(_mutim);
     if ((nbRounds<=0)||(im == nullptr) || (im->width() == 0) || (im->height() == 0) || (im->spectrum()<3))
         {
         if (_offbuf != ((Fl_Offscreen)0)) { fl_delete_offscreen((Fl_Offscreen)(_offbuf)); }
         _offbuf = (Fl_Offscreen)0;
         _ox = 0; _oy = 0;
         redraw();
         return;
         }
     if (!_initdraw) // prevent FLTK bug on linux
         {
         delete _saved_im; _saved_im = nullptr;
         delete _saved_im32; _saved_im32 = nullptr;
         _saved_im32 = new cimg_library::CImg<uint32>(*im, false);
         _saved_nbRounds = nbRounds;
         return;
         }
     const int nox = im->width();
     const int noy = im->height();
     if ((nox != _ox) || (noy != _oy))
         {
         if (_offbuf != ((Fl_Offscreen)0)) { fl_delete_offscreen((Fl_Offscreen)(_offbuf)); }
         _offbuf = fl_create_offscreen(nox, noy);
         _ox = nox; _oy = noy;
         MTOOLS_ASSERT(_offbuf != ((Fl_Offscreen)0));
         }
     fl_begin_offscreen((Fl_Offscreen)(_offbuf));
     auto data = std::pair<cimg_library::CImg<uint32>*, int>(im, nbRounds);
     fl_draw_image(_drawLine_callback32, &data, 0, 0, (int)_ox, (int)_oy, 3);
     fl_end_offscreen();
     return;
     }
Пример #2
0
void
imWindow::drawit()
{
  if (!shown()) return;

  struct image_cb_data cbd;
  make_current();

  if (pixelType == MONOCHROME)
    {
      if (gamma > 0.0 && gamma < 1.0)
	{
	  cbd.pdata = pixelData;
	  cbd.ndisp = ndisp;
	  cbd.linesize = linesize;
	  cbd.skip = skipw;
	  cbd.gtab = gamtab;
	  fl_draw_image_mono(gamma_image_cb_fn, (void *)&cbd, xoff, yoff, width, height, 1);
	}
      else
        fl_draw_image_mono(pixelData, xoff, yoff, width, height, skipw, linesize);
    }
  else if (pixelType == RGB24)
    {
      if (gamma > 0.0 && gamma < 1.0)
	{
	  cbd.pdata = pixelData;
	  cbd.ndisp = ndisp;
	  cbd.linesize = linesize*3;
	  cbd.skip = skipw*3;
	  cbd.gtab = gamtab;
	  fl_draw_image(gamma_color_image_cb_fn, (void *)&cbd, xoff, yoff, width, height, 3);
	}
      else
	fl_draw_image(pixelData, xoff, yoff, width, height, skipw*3, linesize*3);
    }

  else if (pixelType == DISPARITY)
    {
      cbd.pdata = pixelData;
      cbd.ndisp = ndisp;
      cbd.linesize = linesize;
      cbd.skip = skipw;
      fl_draw_image(disp_image_cb_fn, (void *)&cbd, xoff, yoff, width, height, 3);
    }
}
Пример #3
0
///////////////////////////////////////////////////////////////////////////////
//
//      Draw the window contents.
//
///////////////////////////////////////////////////////////////////////////////
void ImageWidget::draw()
{
    if (!m_pImage)          // Don't do anything if the image is empty.
    	return;
    
    unsigned char   *rgb;
    rgb = m_pImage->To_RGB(); // Convert the pre-multiplied RGBA image into RGB.
    unsigned int imageX = x() + (w() > m_pImage->width) ? (w() - m_pImage->width) / 2 : 0;
    fl_draw_image(rgb, imageX, y() + c_border * 2 + c_buttonHeight, m_pImage->width, m_pImage->height, 3);
    delete[] rgb;
}// draw
Пример #4
0
 virtual void draw() {
   for (int i=0; i<w(); i++) {
     const float *rgb = app->scene->color_value(i*MAPCLRS/w()+REGCLRS);
     unsigned char r = (unsigned char)(255*rgb[0]);
     unsigned char g = (unsigned char)(255*rgb[1]);
     unsigned char b = (unsigned char)(255*rgb[2]);
     for (int j=0; j<h(); j++) {
       data[3*w()*j + 3*i + 0] = r;
       data[3*w()*j + 3*i + 1] = g;
       data[3*w()*j + 3*i + 2] = b;
     }
   }
   fl_draw_image(data, x(), y(), w(), h());
 }
Пример #5
0
void ImageView::RasterDraw()
{
	m_mutex.Lock();

	if (m_curByteImage.is_contiguous() && m_curByteImage.size() > 0)
	{
		fl_draw_image_mono(m_curByteImage.top_left_ptr(), 0, 0, 
			m_curByteImage.ni(), m_curByteImage.nj());
	}
	else if (m_curRGBImage.is_contiguous())
	{
		fl_draw_image((const unsigned char*) m_curRGBImage.top_left_ptr(), 0, 0, 
			m_curRGBImage.ni(), m_curRGBImage.nj());
	}

	m_mutex.Release();
}
Пример #6
0
void Magnify_Widget::draw()
{
    const Box2i & geom = frame_geom();

    const int w = _data.w();
    const int h = _data.h();
    const int c = _data.channels();

    fl_draw_image(
        _data.data(),
        geom.x,
        geom.y,
        w,
        h,
        c,
        static_cast<int>(_data.bytes_scanline()));

    Frame::draw();
}
Пример #7
0
void Fl_FrameBuffer_Widget::draw()
{
	Fl::lock();
	fl_color(FL_BACKGROUND_COLOR);
	fl_rectf(x(), y(), w(), h());
	if(m_image)
	{
		boost::shared_ptr<const Aqsis::CqMixedImageBuffer> buf = m_image->displayBuffer();
		if(buf)
		{
			fl_draw_image(buf->rawData(),
				x()+m_image->originX(), y()+m_image->originY(),
				buf->width(), buf->height(),
				buf->channelList().numChannels(),
				0); // draw image
		}
	}
	else
	{
		fl_color(FL_FOREGROUND_COLOR);
		fl_draw("No Image", x(), y(), w(), h(), FL_ALIGN_CENTER, 0, 0);
	}
	Fl::unlock();
}
Пример #8
0
void NavWin::draw()
{
  if (im)
    fl_draw_image(im, 0,0,nw,nh);
  drawOverlay();
}
Пример #9
0
void
NavWin::drawPot(NavFn *nav)
{
  float *pot = nav->potarr;
  COSTTYPE *cst = nav->costarr;
  int width = nav->nx;
  int height = nav->ny;

  // params
  pw = width;
  ph = height;

  // figure out decimation or expansion to fit
  dec = 1;
  inc = 1;

  if (width >= nw/2)
    {
      int ww = width; 
      while (ww > nw)
	{
	  dec++;
	  ww = width/dec;
	}

      int hh = height/dec;
      while (hh > nh)
	{
	  dec++;
	  hh = height/dec;
	}

      if (im == NULL)
	im = new uchar[nw*nh*3];


      // draw potential
      for (int i=0; i<height-dec+1; i+=dec)
	{
	  float *pp = pot + i*width;
	  uchar *ii = im + 3*i/dec * nw;
	  for (int j=0; j<width-dec+1; j+=dec, pp+=dec)
	    {
	      int v;
	      if (*pp > maxval)
		v = 255;
	      else
		v = (int)((*pp/maxval) * 255.0);
	      *ii++ = v;
	      *ii++ = v;
	      *ii++ = v;
	    }
	}


      // draw obstacles
      for (int i=0; i<height-dec+1; i+=dec)
	{
	  COSTTYPE *pp = cst + i*width;
	  uchar *ii = im + 3*i/dec * nw;
	  for (int j=0; j<width-dec+1; j+=dec, pp+=dec, ii+=3)
	    {
	      if (*pp >= COST_OBS)
		{
		  *ii =     120;
		  *(ii+1) = 60;
		  *(ii+2) = 60;
		}
	    }
	}

    }

  else				// expand
    {
      int ww = width; 
      while (ww < nw/2)
	{
	  inc++;
	  ww = width*inc;
	}

      int hh = height*inc;
      while (hh < nh/2)
	{
	  inc++;
	  hh = height*inc;
	}

      if (im == NULL)
	im = new uchar[nw*nh*3];

      for (int i=0; i<height; i++)
	{
	  float *pp = pot + i*width;
	  uchar *ii = im + 3*i*inc * nw;
	  for (int j=0; j<width; j++, pp++)
	    {
	      int v;
	      if (*pp > maxval)
		v = 255;
	      else
		v = (int)((*pp/maxval) * 255.0);
	      for (int k=0; k<inc; k++)
		{
		  uchar *iii = ii + 3*j*inc + 3*k*nw;
		  for (int kk=0; kk<inc; kk++)
		    {
		      *iii++ = v;
		      *iii++ = v;
		      *iii++ = v;
		    }
		}
	    }
	}
    }


  make_current();
  fl_draw_image(im, 0,0,nw,nh);

  if (pc)
    delete [] pc;
  pce = nav->curPe;
  pc = new int[pce];
  memcpy(pc, nav->curP, pce*sizeof(int));

  if (pn)
    delete [] pn;
  pne = nav->nextPe;
  pn = new int[pne];
  memcpy(pn, nav->nextP, pne*sizeof(int));

  if (po)
    delete [] po;
  poe = nav->overPe;
  po = new int[poe];
  memcpy(po, nav->overP, poe*sizeof(int));

  // start and goal
  goal[0] = nav->goal[0];
  goal[1] = nav->goal[1];
  start[0] = nav->start[0];
  start[1] = nav->start[1];

  // path
  if (nav->npath > 0)
    {
      pathlen = nav->npath;
      if (pathbuflen < pathlen)
	{
	  pathbuflen = pathlen;
	  if (path) delete [] path;
	  path = new int[pathbuflen];
	}
      for (int i=0; i<pathlen; i++)
	path[i] = width*(int)(nav->pathy[i])+(int)(nav->pathx[i]);
    }

  drawOverlay();

  redraw();
}
Пример #10
0
 FL_EXPORT_C(void,flc_draw_image_cb_with_d)(Fl_Draw_Image_Cb cb,void* data,int X,int Y,int W,int H,int D){
   fl_draw_image(cb,data,X,Y,W,H,D);
 }
Пример #11
0
 FL_EXPORT_C(void,flc_draw_image_cb)(Fl_Draw_Image_Cb cb,void* data,int X,int Y,int W,int H){
   fl_draw_image(cb,data,X,Y,W,H,3);
 }
Пример #12
0
 FL_EXPORT_C(void,flc_draw_image_buf_with_l)(const uchar* buf,int X,int Y,int W,int H,int L){
   fl_draw_image(buf,X,Y,W,H,3,L);
 }
Пример #13
0
 FL_EXPORT_C(void,flc_draw_image_buf_with_d)(const uchar* buf,int X,int Y,int W,int H,int D){
   fl_draw_image(buf,X,Y,W,H,D,0);
 }
Пример #14
0
void Canvas::draw() {
    if (image != NULL) {
        fl_draw_image(image, 0, 0, width, height, delta);
    }
}
Пример #15
0
static void get_next_frame(void*)
{
    static int repositioning = 0;
    IplImage* frame = 0;
    double new_pos = video_pos->value();
    
    if( (new_pos-old_pos >= 1e-10 || new_pos-old_pos <= -1e-10) && !repositioning)
    {
        video_window->redraw();
        cvSetCaptureProperty( capture, CV_CAP_PROP_POS_AVI_RATIO, new_pos );
        new_pos = cvGetCaptureProperty( capture, CV_CAP_PROP_POS_AVI_RATIO );
        printf("Repositioning\n");
        repositioning = 1;
    }
    else
    {
        new_pos = cvGetCaptureProperty( capture, CV_CAP_PROP_POS_AVI_RATIO );
        video_pos->value(new_pos);
        repositioning = 0;
    }
    old_pos = new_pos;
    frame = cvQueryFrame( capture );

    if( frame == 0 && is_avi )
    {
        cb_Stop(0,0);
        return;
    }

    if( video_window && frame )
    {
        if( video_window->w() < frame->width || video_window->h() < frame->height )
            root_window->size( (short)(frame->width + 40), (short)(frame->height + 150));

        CvRect rect = { video_window->x(), video_window->y(),
                        frame->width, frame->height };
        
        if( !video_image || video_image->width < rect.width ||
            video_image->height < rect.height )
        {
            cvReleaseImage( &video_image );
            video_image = cvCreateImage( cvSize( rect.width, rect.height ), 8, 3 );
        }

        cvSetImageROI( video_image, cvRect(0,0,rect.width, rect.height));
        if( frame->origin == 1 )
            cvFlip( frame, video_image, 0 );
        else
            cvCopy( frame, video_image, 0 );

        DetectAndDrawFaces( video_image );
        if( writer && is_recorded )
        {
            cvWriteToAVI( writer, video_image );
        }
        cvCvtColor( video_image, video_image, CV_RGB2BGR );

        uchar* data = 0;
        int step = 0;
        CvSize size;
        cvGetRawData( video_image, &data, &step, &size );

        video_window->redraw();
        fl_draw_image( (uchar*)data, video_window->x(), video_window->y(),
                       size.width, size.height, 3, step );
    }

    if( started )
    {
        double cur_frame_stamp = get_time_accurate();
        // update fps
        if( fps < 0 )
            fps = 1000/(cur_frame_stamp - prev_frame_stamp);
        else
            fps = (1-fps_alpha)*fps + fps_alpha*1000/(cur_frame_stamp - prev_frame_stamp);
        prev_frame_stamp = cur_frame_stamp;
        sprintf( fps_buffer, "FPS: %5.1f", fps );
        fps_box->label( fps_buffer );
        fps_box->redraw();
        if( total_frames > 0 )
        {
            if( --total_frames == 0 )
                if( !is_loopy )
                    cb_Exit(0,0);
                else
                {
                    total_frames = total_frames0;
                    cvSetCaptureProperty( capture, CV_CAP_PROP_POS_FRAMES, start_pos );
                }
        }
        Fl::add_timeout( timeout, get_next_frame, 0 );
    }
}
Пример #16
0
void image_window::draw() {
  if (mono)
    fl_draw_image_mono(ibuffer+1,0,0,width,height,depth,linedelta);
  else
    fl_draw_image(ibuffer,0,0,width,height,depth,linedelta);
}
Пример #17
0
void BMCanvas::draw()
{
	paint();
	fl_draw_image(Draw_Image_Cb, this, x(), y(), w(), h());
}
Пример #18
0
 FL_EXPORT_C(void,flc_draw_image_buf)(const uchar* buf,int X,int Y,int W,int H){
   fl_draw_image(buf,X,Y,W,H,3,0);
 }