XForms: pixel value from XImage & flimage...

From: Yann Guichoux (guichoux@shom.fr)
Date: Thu Mar 09 2000 - 10:26:19 EST

  • Next message: Steve Lamont: "Re: XForms: pixel value from XImage & flimage..."

    # To subscribers of the xforms list from Yann Guichoux <guichoux@shom.fr> :

    Hi,

    I'm trying to convert an XImage to an flimage (still trying !!!)
    I 've almost succeded ! my last problem is coming from pixel values .
     
    the flimage type i'm using is FL_IMAGE_CI.

    i'm creating an ximage with XGetImage(pixmap)

    then, i use XGetPixel() to get pixel values from the XImage and
    i fill the flimage->ci array with these pixel values :

    fl_image->ci[j][i]=XGetPixel(ximage,i,j);

    but the pixelvalues i get by this way are not corresponding to the good
    index into the lookup table defined in flimage structure.
    ( red_lut green_lut blue_lut arrays )

    How should i process to convert pixel values from the ximage to color
    index in the lookup table ??

    here is a piece of code i wrote :

            /*** first getting the ximage ***/

    x_image=XGetImage(ap->_dpy,carte->get_win(),200,200,300,300,AllPlanes,ZPixmap);

            /*** then initialising the flimage ***/

            fl_image=flimage_alloc();
            fl_image->type=FL_IMAGE_CI;
            fl_image->w=ximage->width;
            fl_image->h=ximage->height;
            fl_image->map_len=256;
            flimage_getmem(fl_image);
            

            /*** filling the look up table ***/

            for (i=0;i<fl_image->map_len;i++)
            {
                    
                    fl_getmcolor(IDCOL1+i,&red,&green,&blue); <--- i think my problem is
    coming from here
                    fl_image->red_lut[i]=(short)red; With XGetPixel() i'm not getting the
    good index in my colormap
                    fl_image->green_lut[i]=(short)green;
                    fl_image->blue_lut[i]=(short)blue;
            }

            /*** filling the color Index array ***/

            for (i=0; i<ximage->width; i++)
                    for (j=0; j<ximage->height ; j++)
                    {
                            
            
                            fl_image->ci[j][i]=XGetPixel(x_image,i,j);
                                                    
                    }

             /*** saving the image file ***/

            flimage_dump(fl_image,"./test.gif","gif);

    how should i do to make it works ???

    thanks for any help...

    YG
    _________________________________________________
    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    http://bob.usuhs.mil/mailserv/xforms.html
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Thu Mar 09 2000 - 10:34:11 EST