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
Gtk::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<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<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 the same as I expected, but there is an issue when I try to 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 in 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);
In both halves, first.pgm is printed.