IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16391


Ignore:
Timestamp:
Feb 9, 2008, 10:11:49 AM (18 years ago)
Author:
eugene
Message:

added byte swap, fixed a bug

Location:
trunk/Ohana/src/kapa2/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/src/Remap16.c

    r16256 r16391  
    11# include "Ximage.h"
     2
     3# define MY_SWAP_BYTE(W) { \
     4  char tmp, *X; \
     5  X = (char *) &W; \
     6  tmp = X[0]; X[0] = X[1]; X[1] = tmp; }
    27
    38void Remap16 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) {
     
    1318  unsigned short *pixel, pixvalue;
    1419  unsigned short back;
     20  int swap_client, swap_server, swap_bytes;
    1521
    1622  ALLOCATE (pixel, unsigned short, graphic[0].Npixels);
     23
     24# ifdef BYTE_SWAP
     25  swap_client = 1;
     26# else
     27  swap_client = 0;
     28# endif 
     29
     30  swap_server = ImageByteOrder (graphic[0].display);
     31  swap_bytes = !(swap_client ^ swap_server);
    1732
    1833  // local array for pixel values (is this working??)
    1934  for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */
    2035    pixel[i] = 0xffff &  graphic[0].cmap[i].pixel;
     36    if (swap_bytes) MY_SWAP_BYTE (pixel[i]);
    2137  }
    2238  back = 0xffff & graphic[0].back;
     39  if (swap_bytes) MY_SWAP_BYTE (back);
     40  // XXX not certain this is the correct solution...
    2341
    2442  // set up expansions
  • trunk/Ohana/src/kapa2/src/Remap32.c

    r16389 r16391  
    11# include "Ximage.h"
     2
     3# define MY_SWAP_INT(A,B) { int tmp; tmp = A; A = B; B = tmp; }
    24
    35# define MY_SWAP_WORD(W) { \
     
    6668  Picture_Upper (&i_end, &j_end, matrix, picture);
    6769
    68   if (i_end < i_start) ISWAP (i_start, i_end);
    69   if (j_end < j_start) ISWAP (j_start, j_end);
     70  if (i_end < i_start) MY_SWAP_INT (i_start, i_end);
     71  if (j_end < j_start) MY_SWAP_INT (j_start, j_end);
    7072
    7173  // Ix,Iy are the first displayed image pixel
Note: See TracChangeset for help on using the changeset viewer.