Re: drawing multiple image(.pgm) using single Ggk::Pixbuf in Gtk::Drawing area



When you draw two images, the row stride is still 360*3, but the width of the drawing area is 720 pixels.
Isn't the  expected result something like the following? (n:m means image n, row m)

1:1  1:2
1:2  1:3
1:3  1:4
........
1:639  1:640
1:640  2:1



2014-07-03 15:57, sunil skrev:
   Hey All,
               I am trying to draw live images in Gtk::DrawingArea in the
same way as they are shown in monitors at railway stations, airports, metro
etc..
 
             For current tesing purpose I have hardcoded my code.

  here it is
         Gtkk::Drawing area width=720, height=640.
         I have first.pgm and second.pgm images each having 360*640
dimesions.(Yes, i rotated it for testing purpose.) 
         These images contains one byte per pixel.
 1)  drawing fine when drwing single image.
       I just read the image into *unsigned char* buffer* of size 360*640*3.
           i have read it like this
               int bufferIndex=0; 
               int fileIndex=0; //just assume 
               for (int i=0; i<height; i++)
               {
                  for (int j=0; j&lt;width; j++)
                  {
                     //below three lines are for RGB purpose required in
Gdk::Pixbuf
                     buffer[bufferIndex++] = //File[fileIndex]; 
                     buffer[bufferIndex++] = //File[fileIndex]; 
                     buffer[bufferIndex++] = //File[fileIndex]; 
                  }
               }               

      Gdk::Colorspace colorSpace = Gdk::COLORSPACE_RGB;
      Gdk::Colorspace colorSpace = (Gdk::Colorspace)0;
      bool has_alpha = false;
      int bits_per_sample = 8;
     int rowStride = 360*3; // distance between rows in bytes
     Glib::RefPtr&lt;Gdk::Pixbuf> pixBuf =
Gdk::Pixbuf::create_from_data((const guint8 *) buffer,
       colorSpace, has_alpha, bits_per_sample, 360, 640, rowStride);
          Glib::RefPtr<Gdk::GC> gcContext;
       	pixBuf->render_to_drawable(drawingArea pointer, gcContext, 0, 0, 0 ,
0 , 360, 640, Gdk::RGB_DITHER_MAX, 0, 0);
       //It prints the image in the left half of drawing area. 
      IT IS SAME AS I EXPECTED.

 * REAL PROBLEM COMES WHEN I DRAW TWO IMAGES.*
  for that purpose I read first.pgm in buffer  and after that i read 
second.pgm (means total [360*640*3]*2  bytes)
   Now i draw it as shown int the code.
   Glib::RefPtr<Gdk::GC>gcContext;
   Gdk::Colorspace colorSpace = Gdk::COLORSPACE_RGB;
   Gdk::Colorspace colorSpace = (Gdk::Colorspace)0;
   bool has_alpha = false;
   int bits_per_sample = 8;
   int rowStride = 360*3; // distance between rows in bytes
   Glib::RefPtr<Gdk::Pixbuf> pixBuf = Gdk::Pixbuf::create_from_data((const
guint8 *) buffer,
       colorSpace, has_alpha, bits_per_sample, 720, 640, rowStride);
       pixBuf->render_to_drawable(drawingarea pointer, gcContext, 0, 0, 0 ,
0 , 720, 640, Gdk::RGB_DITHER_MAX, 0, 0);
       
  Result::
              In both half of the Gtk::Drwing area it prints first.pgm image
only???




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]