Changeset 5852 for trunk/Ohana/src/kii/picture/NewPicture.c
- Timestamp:
- Dec 27, 2005, 3:23:01 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/kii/picture/NewPicture.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kii/picture/NewPicture.c
r5700 r5852 1 1 # include "Ximage.h" 2 # define SCAN \3 status = read (layout[0].Ximage, buffer, 16); \4 buffer[16] = 0; \5 sscanf (buffer, "%*s %d", &Nbytes); \6 status = read (layout[0].Ximage, buffer, Nbytes); \7 buffer[status] = 0; /* make the string easy to parse */ \8 (DEBUG) && fprintf (stderr, "buffer: <%s>\n", buffer); \9 2 10 3 int NewPicture (Graphic *graphic, Layout *layout) { 11 4 12 5 Header header; 13 char buffer[1024],*buff;14 int status, bytes_left, Nbytes;6 char *buff; 7 int status, bytes_left, socket; 15 8 16 fits_free_matrix (&layout[0].matrix); 17 sprintf (buffer, "NCOLOR: %6d ", layout[0].Npixels); 18 write (layout[0].Ximage, buffer, 16); 9 socket = layout[0].Ximage; 19 10 20 fcntl (layout[0].Ximage, F_SETFL, !O_NONBLOCK); 11 KiiSendMessage (socket, "%d", layout[0].Npixels); 12 13 fcntl (socket, F_SETFL, !O_NONBLOCK); 21 14 22 15 header.Naxes = 2; 23 SCAN;24 sscanf (buffer, "%d %d %d %d %lf %lf",25 &header.Naxis[0], &header.Naxis[1], &header.bitpix,26 &header.unsign, &header.bzero, &header.bscale);27 16 28 SCAN; 29 sscanf (buffer, "%lf %lf %lf %lf %d", &layout[0].zero, &layout[0].range, &layout[0].min, &layout[0].max, &header.size); 17 KiiScanMessage (socket, "%d %d %d %d %lf %lf", &header.Naxis[0], &header.Naxis[1]); 18 KiiScanMessage (socket, "%d %d %d %d %lf %lf", &header.bitpix, &header.unsign, &header.bzero, &header.bscale); 19 KiiScanMessage (socket, "%lf %lf", &layout[0].zero, &layout[0].range); 20 KiiScanMessage (socket, "%lf %lf %d", &layout[0].min, &layout[0].max, &header.size); 21 KiiScanMessage (socket, "%lf %f %f %f %f", &layout[0].coords.crval1, &layout[0].coords.crpix1, &layout[0].coords.cdelt1, &layout[0].coords.pc1_1, &layout[0].coords.pc1_2); 22 KiiScanMessage (socket, "%lf %f %f %f %f", &layout[0].coords.crval2, &layout[0].coords.crpix2, &layout[0].coords.cdelt2, &layout[0].coords.pc2_1, &layout[0].coords.pc2_2); 23 24 KiiScanMessage (socket, "%s %s %s", layout[0].coords.ctype, layout[0].file, layout[0].buffer_name); 30 25 31 SCAN; 32 sscanf (buffer, "%lf %f %f %f %f", &layout[0].coords.crval1, &layout[0].coords.crpix1, &layout[0].coords.cdelt1, &layout[0].coords.pc1_1, &layout[0].coords.pc1_2); 33 34 SCAN; 35 sscanf (buffer, "%lf %f %f %f %f", &layout[0].coords.crval2, &layout[0].coords.crpix2, &layout[0].coords.cdelt2, &layout[0].coords.pc2_1, &layout[0].coords.pc2_2); 36 37 SCAN; 38 sscanf (buffer, "%s %s %s", layout[0].coords.ctype, layout[0].file, layout[0].buffer_name); 39 26 fits_free_matrix (&layout[0].matrix); 40 27 fits_create_matrix (&header, &layout[0].matrix); 41 28 42 fcntl ( layout[0].Ximage, F_SETFL, O_NONBLOCK);29 fcntl (socket, F_SETFL, O_NONBLOCK); 43 30 44 31 status = 1; … … 47 34 layout[0].matrix.size = 0; 48 35 while (bytes_left > 0) { 49 status = read ( layout[0].Ximage, buff, bytes_left);36 status = read (socket, buff, bytes_left); 50 37 if (status == 0) { /* No more pipe */ 51 38 fprintf (stderr, "error: pipe closed\n"); … … 59 46 } 60 47 61 (DEBUG) &&fprintf (stderr, "read %d bytes\n", layout[0].matrix.size);48 if (DEBUG) fprintf (stderr, "read %d bytes\n", layout[0].matrix.size); 62 49 /* it it not obvious this condition should kill kii, but ... */ 63 50 if (layout[0].matrix.size != header.size) { … … 69 56 70 57 Remap (graphic, layout, &layout[0].matrix); 71 (DEBUG) &&fprintf (stderr, "remapped image\n");58 if (DEBUG) fprintf (stderr, "remapped image\n"); 72 59 Refresh (graphic, layout, 0); 73 (DEBUG) &&fprintf (stderr, "refreshed\n");60 if (DEBUG) fprintf (stderr, "refreshed\n"); 74 61 XFlush (graphic[0].display); 75 62
Note:
See TracChangeset
for help on using the changeset viewer.
