Re: Display streaming JPGs

This is how I have done it. I use the libjpeg and
decompress the image data thru jpeg_read_scanlines().
It puts one line of image in the memory pointed by
buffer. I do the same for all the scanlines. At the
same time I keep putting it into the rgbbuf. The
rgbbub is a buffer reserving three bytes per pixel,
for whole of the image. I do the memcpy() and place
these pixes in the rgbbuf. Then I call
gdk_draw_rgb_image to render the picture on the

Here are some sample lines from my code:

guchar *rgbbuf;
struct jpeg_decompress_struct cinfo;
 rgbbuf = (unsigned char *) malloc( imgwidth *
imgheight * 3);

 while (cinfo.output_scanline < cinfo.output_height)
     ptr = nscanline * row_stride;
     jpeg_read_scanlines (&cinfo, buffer, 1);
     memcpy( &rgbbuf[ptr], (guchar *) buffer[0], bpix
* cinfo.output_width);
//da is actually drawing_area widget

 gdk_draw_rgb_image (da->window,
da->style->fg_gc[GTK_STATE_NORMAL], x, y,
    imgwidth, imgheight, GDK_RGB_DITHER_MAX, (guchar
*) rgbbuf, imgwidth * 3 );

//your message
I'd need to display some (256x256) JPG files retrieved
from a database
Encoding to/from text is not the issue. The issue is
making gdk-pixbuf
load'em whithout having to write a file. Is it

Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

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