[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

183.0. "HELP XCreateImage and XPutImage problem" by OSL01::TOREO () Mon Feb 13 1989 05:51

    Hello out there!
    
    I'm having a bit of a problem. I'm doing a system to simulate the
    transmission of seismic waves and to draw snapshots of the waves
    I use XCreateImage and XPutImage.
    
    The problem is: To do this I have to create an array of images.
    At a later time I write the array of Images to a window, one at
    a time. However something goes wrong in my images because alle 
    images in the array are one and the same, namely the last one 
    created. The data for the images are read from a file 6000 blocks
    large, one chunk at a time and then fed into an Image. 
    
    The code goes something like this
    
    XImage *Image[40];
    .
    .
    main( argc, argv )
    {
    .
    .                          
    unsigned char Data[256][300];
    .
    .                                                    
    for ( i = 0; i < 40; i++ )   
       {
          fread( Data, 300, 256, FilePointer );
          CreateImage( Data, i )
       }
    .
    .
    for ( j = 0; j < 40; j++ )
       XPutImage( Dpy, Window, GC, Image[j], 0,0,0,0,300,256 );
    .
    .
    }
    
    static void CreateImage( Data, C )
    unsigned char Data[256][300];
    int C;
    {
    .
    .
        Image[C] = XCreateImage( Dpy, Window, DefaultDepthOfScreen(Scr),
                                 ZPixmap, 0, Data, 300, 256, 16, 0 );
    } 
     
    
    No matter how many images I create only the last read data are fed
    into the Image. That is Image[i]->data does not change and only
    the last snapshot is thrown at the screen. The question is:
    
    1) Am I missing an obvious point ?
    2) Am I missing a more obscure point ?
    3) Can I do this ?
    3) Am I just a stupid fool who hasn't grasped what Images are all
       about ?
    
    
                                                Rgds. ToreO...
    

T.RTitleUserPersonal
Name
DateLines
183.1All images pointing to the same dataISLAV::OLAVDo it in parallel!Sat Feb 18 1989 08:2613
The XImage data structure contains a pointer to the image data. In your case
all the 40 images are pointing to the same data object (Data[256][300]). You
need another dimension on the Data array (for example Data[40][256][300]) and
do something like this:

    for ( i = 0; i < 40; i++ )   
       {
          fread( Data[i], 300, 256, FilePointer );
          CreateImage( Data[i], i )
       }

Olav