Changeset 16256
- Timestamp:
- Jan 27, 2008, 1:24:12 PM (18 years ago)
- Location:
- trunk/Ohana/src/kapa2
- Files:
-
- 27 edited
-
Makefile (modified) (2 diffs)
-
include/prototypes.h (modified) (3 diffs)
-
include/structures.h (modified) (1 diff)
-
src/ButtonFunctions.c (modified) (5 diffs)
-
src/Center.c (modified) (1 diff)
-
src/CreatePicture.c (modified) (1 diff)
-
src/CreateZoom.c (modified) (1 diff)
-
src/CreateZoom16.c (modified) (1 diff)
-
src/CreateZoom24.c (modified) (1 diff)
-
src/CreateZoom32.c (modified) (6 diffs)
-
src/CreateZoom8.c (modified) (1 diff)
-
src/CursorOps.c (modified) (3 diffs)
-
src/Image.c (modified) (1 diff)
-
src/InterpretKeys.c (modified) (1 diff)
-
src/InterpretPresses.c (modified) (2 diffs)
-
src/JPEGit24.c (modified) (5 diffs)
-
src/LoadPicture.c (modified) (3 diffs)
-
src/PSPixmap.c (modified) (1 diff)
-
src/Remap.c (modified) (1 diff)
-
src/Remap16.c (modified) (2 diffs)
-
src/Remap24.c (modified) (4 diffs)
-
src/Remap32.c (modified) (3 diffs)
-
src/Remap8.c (modified) (3 diffs)
-
src/SetImageData.c (modified) (1 diff)
-
src/SetImageSize.c (modified) (1 diff)
-
src/StatusBox.c (modified) (1 diff)
-
src/UpdatePointer.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/Makefile
r16039 r16256 61 61 $(SRC)/DrawButton.$(ARCH).o $(SRC)/DrawBitmap.$(ARCH).o \ 62 62 $(SRC)/hh_hms.$(ARCH).o $(SRC)/CreateZoom.$(ARCH).o \ 63 $(SRC)/CreateZoom8.$(ARCH).o $(SRC)/CreateZoom16.$(ARCH).o \64 $(SRC)/CreateZoom24.$(ARCH).o $(SRC)/CreateZoom32.$(ARCH).o \65 63 $(SRC)/CreatePicture.$(ARCH).o $(SRC)/CreateColorbar.$(ARCH).o \ 66 64 $(SRC)/MakeColormap.$(ARCH).o $(SRC)/SetColormap.$(ARCH).o \ … … 81 79 $(SRC)/ColorHistogram.$(ARCH).o 82 80 81 #$(SRC)/CreateZoom8.$(ARCH).o $(SRC)/CreateZoom16.$(ARCH).o \ 82 #$(SRC)/CreateZoom24.$(ARCH).o $(SRC)/CreateZoom32.$(ARCH).o \ 83 83 84 OBJ = $(KAPA) 84 85 -
trunk/Ohana/src/kapa2/include/prototypes.h
r16255 r16256 146 146 int SetColorScale3D PROTO((Graphic *graphic, KapaImageWidget *image)); 147 147 void Remap PROTO((Graphic *graphic, KapaImageWidget *image)); 148 void Remap8 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));149 void Remap16 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));150 void Remap24 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));151 void Remap32 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));148 void Remap8 PROTO((Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix)); 149 void Remap16 PROTO((Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix)); 150 void Remap24 PROTO((Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix)); 151 void Remap32 PROTO((Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix)); 152 152 int LoadPicture PROTO((int sock)); 153 153 … … 171 171 void PaintTickmarks PROTO((Graphic *graphic, KapaImageWidget *image)); 172 172 173 void Picture_to_Image PROTO((double *x1, double *y1, double x2, double y2, Picture *picture)); 173 174 void Screen_to_Image PROTO((double *x1, double *y1, double x2, double y2, Picture *picture)); 175 void Image_to_Picture PROTO((double *x1, double *y1, double x2, double y2, Picture *picture)); 174 176 void Image_to_Screen PROTO((double *x1, double *y1, double x2, double y2, Picture *picture)); 177 void Picture_Lower PROTO((int *i_start, int *j_start, Matrix *matrix, Picture *picture)); 178 void Picture_Upper PROTO((int *i_end, int *j_end, Matrix *matrix, Picture *picture)); 175 179 176 180 void DragColorbar PROTO((Graphic *graphic, KapaImageWidget *image, XButtonEvent *mouse_event)); … … 214 218 void CreatePicture (KapaImageWidget *image, Graphic *graphic); 215 219 void CreateColorbar (KapaImageWidget *image, Graphic *graphic); 216 void CreateZoom ( KapaImageWidget *image, Graphic *graphic, double x, double y);220 void CreateZoom (Graphic *graphic, KapaImageWidget *image); 217 221 void UpdateStatusBox (Graphic *graphic, KapaImageWidget *image, double x, double y, double z, int mode); 218 222 219 void CreateZoom8 (KapaImageWidget *image, Graphic *graphic, double x, double y);220 void CreateZoom16 (KapaImageWidget *image, Graphic *graphic, double x, double y);221 void CreateZoom24 (KapaImageWidget *image, Graphic *graphic, double x, double y);222 void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y);223 // void CreateZoom8 (KapaImageWidget *image, Graphic *graphic, double x, double y); 224 // void CreateZoom16 (KapaImageWidget *image, Graphic *graphic, double x, double y); 225 // void CreateZoom24 (KapaImageWidget *image, Graphic *graphic, double x, double y); 226 // void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y); 223 227 224 228 int GetActiveSocket (); -
trunk/Ohana/src/kapa2/include/structures.h
r16255 r16256 94 94 int DX, DY; // size of displayed picture (must be updated with new images...) 95 95 int expand; // zoomscale 96 double X, Y; // offset of image center 97 double Xo, Yo; // reference image pixel (picture has X - Xo at center) 96 double X, Y; // center of image in picture 98 97 XImage *pix; 99 98 char *data; -
trunk/Ohana/src/kapa2/src/ButtonFunctions.c
r16255 r16256 14 14 SetColorScale (graphic, image); 15 15 Remap (graphic, image); 16 CreateZoom ( image, graphic, 0, 0);16 CreateZoom (graphic, image); 17 17 Refresh (); 18 18 XFlush (graphic[0].display); … … 25 25 SetColorScale (graphic, image); 26 26 Remap (graphic, image); 27 CreateZoom ( image, graphic, 0, 0);27 CreateZoom (graphic, image); 28 28 Refresh (); 29 29 XFlush (graphic[0].display); … … 36 36 SetColorScale (graphic, image); 37 37 Remap (graphic, image); 38 CreateZoom ( image, graphic, 0, 0);38 CreateZoom (graphic, image); 39 39 Refresh (); 40 40 XFlush (graphic[0].display); … … 44 44 int Recenter (Graphic *graphic, KapaImageWidget *image) { 45 45 46 image[0].picture.X = 0 ;47 image[0].picture.Y = 0 ;46 image[0].picture.X = 0.5*image[0].image[0].matrix.Naxis[0]; 47 image[0].picture.Y = 0.5*image[0].image[0].matrix.Naxis[1]; 48 48 49 49 Remap (graphic, image); … … 66 66 int RecenterRescale (Graphic *graphic, KapaImageWidget *image) { 67 67 68 image[0].picture.X = 0 ;69 image[0].picture.Y = 0 ;68 image[0].picture.X = 0.5*image[0].image[0].matrix.Naxis[0]; 69 image[0].picture.Y = 0.5*image[0].image[0].matrix.Naxis[1]; 70 70 image[0].picture.expand = 1; 71 71 -
trunk/Ohana/src/kapa2/src/Center.c
r16255 r16256 16 16 if (image == NULL) return (TRUE); 17 17 18 image[0].picture.X o = 0.5*image[0].image[0].matrix.Naxis[0] -X;19 image[0].picture.Y o = 0.5*image[0].image[0].matrix.Naxis[1] -Y;18 image[0].picture.X = X; 19 image[0].picture.Y = Y; 20 20 if ((zoom != 0) && (zoom != -1)) { 21 21 image[0].picture.expand = zoom; -
trunk/Ohana/src/kapa2/src/CreatePicture.c
r13479 r16256 55 55 56 56 case 32: 57 REALLOCATE (image[0]. picture.data, char, (4*image[0].picture.dx*image[0].picture.dy + 32));58 memset (image[0].picture.data, 0xbd, 4*image[0].picture.dx*image[0].picture.dy + 30);57 REALLOCATE (image[0].zoom.data, char, 4*image[0].zoom.dx*image[0].zoom.dy); 58 REALLOCATE (image[0].picture.data, char, 4*image[0].picture.dx*image[0].picture.dy); 59 59 l = (unsigned int *) image[0].picture.data; 60 60 for (i = 0; i < (image[0].picture.dx*image[0].picture.dy); i++, l++) -
trunk/Ohana/src/kapa2/src/CreateZoom.c
r13320 r16256 1 1 # include "Ximage.h" 2 2 3 void CreateZoom ( KapaImageWidget *image, Graphic *graphic, double x, double y) {3 void CreateZoom (Graphic *graphic, KapaImageWidget *image) { 4 4 5 5 switch (graphic[0].Nbits) { 6 6 case 8: 7 CreateZoom8 (image, graphic, x, y);7 Remap8 (graphic, image, &image->zoom, &image->image->matrix); 8 8 break; 9 10 9 case 16: 11 CreateZoom16 (image, graphic, x, y);10 Remap16 (graphic, image, &image->zoom, &image->image->matrix); 12 11 break; 13 14 12 case 24: 15 CreateZoom24 (image, graphic, x, y);13 Remap24 (graphic, image, &image->zoom, &image->image->matrix); 16 14 break; 17 18 15 case 32: 19 CreateZoom32 (image, graphic, x, y);16 Remap32 (graphic, image, &image->zoom, &image->image->matrix); 20 17 break; 21 18 } -
trunk/Ohana/src/kapa2/src/CreateZoom16.c
r16255 r16256 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a))3 4 static float slope = 1.0;5 static float start = 0.0;6 static int MaxValue = 255;7 8 // XXX inline this if needed9 static int PixelLookup(float value) {10 int out;11 out = MIN (MAX (slope * value - start, 0), MaxValue);12 return (out);13 }14 2 15 3 void CreateZoom16 (KapaImageWidget *image, Graphic *graphic, double x, double y) { -
trunk/Ohana/src/kapa2/src/CreateZoom24.c
r16255 r16256 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a))3 4 static float slope = 1.0;5 static float start = 0.0;6 static int MaxValue = 255;7 8 // XXX inline this if needed9 static int PixelLookup(float value) {10 int out;11 out = MIN (MAX (slope * value - start, 0), MaxValue);12 return (out);13 }14 2 15 3 void CreateZoom24 (KapaImageWidget *image, Graphic *graphic, double x, double y) { -
trunk/Ohana/src/kapa2/src/CreateZoom32.c
r16255 r16256 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a))3 2 4 3 void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y) { … … 8 7 int dropback; /* this is a bit of a kludge... */ 9 8 int dx, dy, DX, DY; 10 double expand, Sx, Sy,Ix, Iy;9 double expand, Ix, Iy; 11 10 int expand_in, expand_out; 12 11 unsigned int *out_pix, *out_pix2; … … 50 49 DY = image[0].image[0].matrix.Naxis[1]; 51 50 52 // Ix, Iy are the image coordinates of the 0,0 screen pixel53 Screen_to_Image (&Ix, &Iy, 0.0, 0.0, &image[0].picture);51 // x, y are the closest lit screen pixel to 0,0 52 Picture_Lower (&i_start, &j_start, &image[0].image[0].matrix, &image[0].zoom); 54 53 55 // Ix, Iy are now limited to valid image coordinates 56 Ix = MIN (MAX (Ix, 0), DX); 57 Iy = MIN (MAX (Iy, 0), DY); 54 // x, y are the closest lit screen pixel to dx, dy 55 Picture_Upper (&i_end, &j_end, &image[0].image[0].matrix, &image[0].zoom); 58 56 59 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 60 Image_to_Screen (&Sx, &Sy, Ix, Iy, &image[0].picture); 61 62 // i_start, j_start are now limited to valid screen coordinates 63 i_start = MIN (MAX (Sx, 0), dx); 64 j_start = MIN (MAX (Sy, 0), dy); 65 66 // Ix, Iy are the image coordinates of the 0,0 screen pixel 67 Screen_to_Image (&Ix, &Iy, dx, dy, &image[0].picture); 68 69 // Ix, Iy are now limited to valid image coordinates 70 Ix = MIN (MAX (Ix, 0), DX); 71 Iy = MIN (MAX (Iy, 0), DY); 72 73 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 74 Image_to_Screen (&Sx, &Sy, Ix, Iy, &image[0].picture); 75 76 // i_end, j_end are now limited to valid screen coordinates 77 i_end = MIN (MAX (Sx, 0), dx); 78 j_end = MIN (MAX (Sy, 0), dy); 57 // Ix,Iy are the first displayed image pixel 58 Picture_to_Image (&Ix, &Iy, i_start, j_start, &image[0].zoom); 79 59 80 60 dropback = expand_out - (i_end - i_start) % expand_out; … … 92 72 return; 93 73 } 94 95 74 96 75 /**** fill in bottom area ****/ … … 117 96 } 118 97 } else { 98 // equiv to : out_pix += (i_end - i_start) + [expand_out - (i_end - i_start) % expand_out] 119 99 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 120 100 pixvalue = pixel[*in_pix2]; … … 137 117 } 138 118 out_pix += (dx - i_end); 119 assert (out_pix - (unsigned int *)image[0].zoom.data <= dx*dy); 139 120 } 121 assert (out_pix - (unsigned int *)image[0].zoom.data <= dx*dy); 140 122 141 123 if ((j_end - j_start) % expand_out > 0) 142 124 out_pix -= (expand_out - (j_end - j_start) % expand_out); 143 125 126 assert (out_pix - (unsigned int *)image[0].zoom.data <= dx*dy); 127 144 128 /**** fill in top area ****/ 145 129 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)image[0].zoom.data < dx*dy); j++, out_pix++) { 146 130 *out_pix = back; 147 131 } 132 assert (out_pix - (unsigned int *)image[0].zoom.data <= dx*dy); 148 133 149 134 image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, -
trunk/Ohana/src/kapa2/src/CreateZoom8.c
r16255 r16256 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a))3 4 static float slope = 1.0;5 static float start = 0.0;6 static int MaxValue = 255;7 8 // XXX inline this if needed9 static int PixelLookup(float value) {10 int out;11 out = MIN (MAX (slope * value - start, 0), MaxValue);12 return (out);13 }14 2 15 3 void CreateZoom8 (KapaImageWidget *image, Graphic *graphic, double x, double y) { -
trunk/Ohana/src/kapa2/src/CursorOps.c
r16255 r16256 1 1 # include "Ximage.h" 2 2 3 void Screen_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) { 3 // input coordinates are relative to the picture bounding box 4 void Picture_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) { 4 5 5 double xs, ys,expand;6 double expand; 6 7 7 8 expand = 1.0; … … 12 13 } 13 14 14 // pixel coordinates in picture frame 15 xs = x2 - picture[0].x; 16 ys = y2 - picture[0].y; 17 18 // picture[0].X,Y is the offset relative to picture[0].Xo,Yo 19 *x1 = expand*(xs - 0.5*picture[0].dx) + picture[0].Xo - picture[0].X; 20 *y1 = expand*(ys - 0.5*picture[0].dy) + picture[0].Yo - picture[0].Y; 15 // picture[0].X,Y is the image coordinate in the center of the picture 16 *x1 = expand*(x2 - 0.5*picture[0].dx) + picture[0].X; 17 *y1 = expand*(y2 - 0.5*picture[0].dy) + picture[0].Y; 21 18 } 22 19 23 void Image_to_Screen (double *x1, double *y1, double x2, double y2, Picture *picture) { 20 // input coordinates are relative to the X window 21 void Screen_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) { 24 22 25 double xs, ys, expand; 23 double xp, yp; 24 25 // pixel coordinates in picture frame 26 xp = x2 - picture[0].x; 27 yp = y2 - picture[0].y; 28 29 Picture_to_Image (x1, y1, xp, yp, picture); 30 } 31 32 void Image_to_Picture (double *x1, double *y1, double x2, double y2, Picture *picture) { 33 34 double expand; 26 35 27 36 /* notice that here, expand is the reciprocal of the expand above */ … … 34 43 35 44 // pixel coordinates in picture frame 36 xs = expand*(x2 - picture[0].Xo + picture[0].X) + 0.5*picture[0].dx; 37 ys = expand*(y2 - picture[0].Yo + picture[0].Y) + 0.5*picture[0].dy; 45 *x1 = expand*(x2 - picture[0].X) + 0.5*picture[0].dx; 46 *y1 = expand*(y2 - picture[0].Y) + 0.5*picture[0].dy; 47 } 48 49 void Image_to_Screen (double *x1, double *y1, double x2, double y2, Picture *picture) { 50 51 double xp, yp; 52 53 Image_to_Picture (&xp, &yp, x2, y2, picture); 38 54 39 55 // pixel coordinates in screen frame 40 *x1 = x s+ picture[0].x;41 *y1 = y s+ picture[0].y;56 *x1 = xp + picture[0].x; 57 *y1 = yp + picture[0].y; 42 58 } 43 59 60 // input coordinates are relative to the picture bounding box 61 void Picture_Lower (int *i_start, int *j_start, Matrix *matrix, Picture *picture) { 62 63 double Ix, Iy, Sx, Sy; 64 65 // Ix, Iy are the image coordinates of the specified screen pixel 66 Picture_to_Image (&Ix, &Iy, 0.0, 0.0, picture); 67 68 // Ix, Iy are now limited to valid image coordinates 69 Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]); 70 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]); 71 72 // round up to nearest pixel boundary 73 if (Ix > (int)(Ix)) Ix = (int)(Ix) + 1; 74 if (Iy > (int)(Iy)) Iy = (int)(Iy) + 1; 75 76 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 77 Image_to_Picture (&Sx, &Sy, Ix, Iy, picture); 78 79 // i_start, j_start are now limited to valid screen coordinates 80 *i_start = MIN (MAX (Sx, 0), picture[0].dx); 81 *j_start = MIN (MAX (Sy, 0), picture[0].dy); 82 } 83 84 // input coordinates are relative to the picture bounding box 85 void Picture_Upper (int *i_end, int *j_end, Matrix *matrix, Picture *picture) { 86 87 double Ix, Iy, Sx, Sy; 88 89 // Ix, Iy are the image coordinates of the specified screen pixel 90 Picture_to_Image (&Ix, &Iy, picture[0].dx, picture[0].dy, picture); 91 92 // Ix, Iy are now limited to valid image coordinates 93 Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]); 94 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]); 95 96 // round down to nearest pixel boundary 97 if (Ix > (int)(Ix)) Ix = (int)(Ix); 98 if (Iy > (int)(Iy)) Iy = (int)(Iy); 99 100 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 101 Image_to_Picture (&Sx, &Sy, Ix, Iy, picture); 102 103 // i_start, j_start are now limited to valid screen coordinates 104 *i_end = MIN (MAX (Sx, 0), picture[0].dx); 105 *j_end = MIN (MAX (Sy, 0), picture[0].dy); 106 } -
trunk/Ohana/src/kapa2/src/Image.c
r16255 r16256 50 50 image[0].picture.X = 0.0; 51 51 image[0].picture.Y = 0.0; 52 image[0].picture.Xo = 0.0;53 image[0].picture.Yo = 0.0;54 52 image[0].picture.expand = 1; 55 53 56 54 image[0].zoom.X = 0.0; 57 55 image[0].zoom.Y = 0.0; 58 image[0].zoom.Xo = 0.0;59 image[0].zoom.Yo = 0.0;60 56 image[0].zoom.expand = +5; 61 57 62 58 image[0].wide.X = 0.0; 63 59 image[0].wide.Y = 0.0; 64 image[0].wide.Xo = 0.0;65 image[0].wide.Yo = 0.0;66 60 image[0].wide.expand = -5; 67 61 -
trunk/Ohana/src/kapa2/src/InterpretKeys.c
r16255 r16256 118 118 case XK_End: 119 119 image[0].picture.expand = 1; 120 Reorient (graphic, image, 0 , 0, 0);120 Reorient (graphic, image, 0.5*image[0].image[0].matrix.Naxis[0], 0.5*image[0].image[0].matrix.Naxis[1], 0); 121 121 break; 122 122 case XK_KP_Enter: 123 123 case XK_KP_Begin: 124 124 case XK_Return: 125 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, &image[0].picture); 126 X = 0.5*image[0].picture.DX - X; 127 Y = 0.5*image[0].picture.DY - Y; 125 Screen_to_Image (&X, &Y, event[0].x + 0.5, event[0].y + 0.5, &image[0].picture); 128 126 Reorient (graphic, image, X, Y, 0); 129 127 break; -
trunk/Ohana/src/kapa2/src/InterpretPresses.c
r16228 r16256 34 34 if (event[0].x > image[0].picture.x + image[0].picture.dx) goto skip_cursor; 35 35 if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor; 36 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, &image[0].picture);36 Screen_to_Image (&X, &Y, event[0].x + 0.5, event[0].y + 0.5, &image[0].picture); 37 37 38 38 XY_to_RD (&R, &D, X, Y, &image[0].image[0].coords); … … 101 101 double X, Y; 102 102 103 Screen_to_Image (&X, &Y, (double)mouse_event[0].x, (double)mouse_event[0].y, &image[0].picture); 104 X = 0.5*image[0].image[0].matrix.Naxis[0] - X; 105 Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y; 103 Screen_to_Image (&X, &Y, mouse_event[0].x + 0.5, mouse_event[0].y + 0.5, &image[0].picture); 106 104 107 105 switch (mouse_event[0].button) { -
trunk/Ohana/src/kapa2/src/JPEGit24.c
r16255 r16256 8 8 // XXX this currently writes out the jpeg for just the active image 9 9 int JPEGit24 (int sock) { 10 11 # if (0)12 10 13 11 struct jpeg_compress_struct cinfo; … … 26 24 int quality; 27 25 int expand_in, expand_out; 28 double expand, Rx, Ry, X, Y;26 double expand, Ix, Iy; 29 27 unsigned char *out_pix; 30 28 unsigned short *in_pix, *in_pix_ref; … … 95 93 DY = image[0].image[0].matrix.Naxis[1]; 96 94 97 /* X,Y are the image coordinates of the first image pixel */ 98 X = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 99 if ((int)X != X) 100 X = (int) X + 1; 101 else 102 X = (int) X; 103 Y = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 104 if ((int)Y != Y) 105 Y = (int) Y + 1; 106 else 107 Y = (int) Y; 108 109 /* Rx,Ry are the screen coordinates of the first image pixel */ 110 Rx = (X + image[0].X - 0.5*DX)/expand + 0.5*dx; 111 Ry = (Y + image[0].Y - 0.5*DY)/expand + 0.5*dy; 112 113 i_start = MIN (MAX (Rx, 0), dx - expand_out + 1); 114 j_start = MIN (MAX (Ry, 0), dy - expand_out + 1); 115 116 if (image[0].expand > 0) { 117 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-X) + Rx), 0); 118 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Y) + Ry), 0); 119 } else { 120 i_end = MAX (MIN (dx, (DX-X)/expand + Rx), 0); 121 j_end = MAX (MIN (dy, (DY-Y)/expand + Ry), 0); 122 } 95 // x, y are the closest lit screen pixel to 0,0 96 Picture_Lower (&i_start, &j_start, &image[0].image[0].matrix, &image[0].picture); 97 98 // x, y are the closest lit screen pixel to dx, dy 99 Picture_Upper (&i_end, &j_end, &image[0].image[0].matrix, &image[0].picture); 100 101 // Ix,Iy are the first displayed image pixel 102 Picture_to_Image (&Ix, &Iy, i_start, j_start, &image[0].picture); 123 103 124 104 dropback = expand_out - (i_end - i_start) % expand_out; … … 129 109 ALLOCATE (line_buffer, JSAMPLE, 3*dx); 130 110 131 in_pix_ref = &image[0].pixmap[DX*(int)MAX( Y,0) + (int)MAX(X,0)];111 in_pix_ref = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 132 112 133 113 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 233 213 jpeg_destroy_compress (&cinfo); 234 214 235 236 # endif237 215 return (TRUE); 238 216 } -
trunk/Ohana/src/kapa2/src/LoadPicture.c
r16228 r16256 9 9 KapaImageWidget *image; 10 10 Graphic *graphic; 11 double Xoffset, Yoffset; 11 12 12 13 graphic = GetGraphic (); … … 19 20 20 21 KiiSendMessage (sock, "%d", graphic->Npixels); 22 23 // when we load a new picture, use the same orientation as the old picture 24 Xoffset = 0.0; 25 Yoffset = 0.0; 26 if (image[0].image[0].matrix.size) { 27 Xoffset = image[0].picture.X - 0.5*image[0].image[0].matrix.Naxis[0]; 28 Yoffset = image[0].picture.Y - 0.5*image[0].image[0].matrix.Naxis[1]; 29 } 21 30 22 31 gfits_init_header (&header); … … 34 43 35 44 // reference point for image is the center pixel 36 image[0].picture.X o = 0.5*header.Naxis[0];37 image[0].picture.Y o = 0.5*header.Naxis[1];45 image[0].picture.X = 0.5*header.Naxis[0] + Xoffset; 46 image[0].picture.Y = 0.5*header.Naxis[1] + Yoffset; 38 47 39 48 fcntl (sock, F_SETFL, O_NONBLOCK); -
trunk/Ohana/src/kapa2/src/PSPixmap.c
r16011 r16256 1 1 # include "Ximage.h" 2 3 // XXX this stuff has been broken by the conversion to the pixmap stuff 2 4 3 5 void PSPixmap8 (Graphic *graphic, KapaImageWidget *image, FILE *f) { -
trunk/Ohana/src/kapa2/src/Remap.c
r16011 r16256 5 5 switch (graphic[0].Nbits) { 6 6 case 8: 7 Remap8 (graphic, image, &image-> image->matrix);7 Remap8 (graphic, image, &image->picture, &image->image->matrix); 8 8 break; 9 9 case 16: 10 Remap16 (graphic, image, &image-> image->matrix);10 Remap16 (graphic, image, &image->picture, &image->image->matrix); 11 11 break; 12 12 case 24: 13 Remap24 (graphic, image, &image-> image->matrix);13 Remap24 (graphic, image, &image->picture, &image->image->matrix); 14 14 break; 15 15 case 32: 16 Remap32 (graphic, image, &image-> image->matrix);16 Remap32 (graphic, image, &image->picture, &image->image->matrix); 17 17 break; 18 18 } -
trunk/Ohana/src/kapa2/src/Remap16.c
r16255 r16256 1 1 # include "Ximage.h" 2 2 3 void Remap16 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {3 void Remap16 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) { 4 4 5 # if (0)6 5 int i, j, ii, jj; 7 6 int i_start, i_end, j_start, j_end; 8 int dropback; /* this is a bit of a kludge... */7 int dropback; 9 8 int dx, dy, DX, DY; 10 double expand, Sx, Sy,Ix, Iy;9 double expand, Ix, Iy; 11 10 int expand_in, expand_out; 12 unsigned char*out_pix, *out_pix2, *data;11 unsigned short *out_pix, *out_pix2, *data; 13 12 unsigned short *in_pix, *in_pix2; 14 unsigned char *pixel1, *pixel2; 15 unsigned char pixvalue1, pixvalue2; 16 unsigned char back1, back2; 13 unsigned short *pixel, pixvalue; 14 unsigned short back; 17 15 18 ALLOCATE (pixel1, unsigned char, graphic[0].Npixels); 19 ALLOCATE (pixel2, unsigned char, graphic[0].Npixels); 16 ALLOCATE (pixel, unsigned short, graphic[0].Npixels); 20 17 21 18 // local array for pixel values (is this working??) 22 19 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 23 pixel1[i] = 0x00ff & graphic[0].cmap[i].pixel; 24 pixel2[i] = 0x00ff & (graphic[0].cmap[i].pixel >> 8); 20 pixel[i] = 0xffff & graphic[0].cmap[i].pixel; 25 21 } 26 back1 = 0x00ff & (graphic[0].back >> 0); 27 back2 = 0x00ff & (graphic[0].back >> 8); 28 29 // define the color transform parameters 30 MaxValue = graphic[0].Npixels - 1; 31 if (image[0].image[0].range != 0.0) { 32 slope = graphic[0].Npixels / image[0].image[0].range; 33 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 34 } else { 35 slope = 1.0; 36 start = image[0].image[0].zero; 37 } 22 back = 0xffff & graphic[0].back; 38 23 39 24 // set up expansions 25 assert ((picture[0].expand >= 1) || (picture[0].expand <= -2)); 40 26 expand = expand_in = expand_out = 1.0; 41 if (image[0].expand == 0) /* set up expansions */ 42 image[0].expand = 1; 43 if (image[0].expand > 0) { 44 expand = 1 / (1.0*image[0].expand); 45 expand_out = image[0].expand; 27 if (picture[0].expand > 0) { 28 expand = 1 / (1.0*picture[0].expand); 29 expand_out = picture[0].expand; 46 30 expand_in = 1; 47 31 } 48 if ( image[0].expand < 0) {49 expand = fabs((double) image[0].expand);32 if (picture[0].expand < 0) { 33 expand = fabs((double)picture[0].expand); 50 34 expand_out = 1; 51 expand_in = - image[0].expand;35 expand_in = -picture[0].expand; 52 36 } 53 37 54 38 // define the image boundaries 55 dx = image[0].picture.dx;56 dy = image[0].picture.dy;39 dx = picture[0].dx; 40 dy = picture[0].dy; 57 41 DX = matrix[0].Naxis[0]; 58 42 DY = matrix[0].Naxis[1]; 59 43 60 /* X,Y are the image coordinates of the first image pixel */ 61 Ix = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 62 if ((int)Ix != Ix) 63 Ix = (int) Ix + 1; 64 else 65 Ix = (int) Ix; 66 Iy = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 67 if ((int)Iy != Iy) 68 Iy = (int) Iy + 1; 69 else 70 Iy = (int) Iy; 44 // x, y are the closest lit screen pixel to 0,0 45 Picture_Lower (&i_start, &j_start, matrix, picture); 71 46 72 /* Sx,Sy are the screen coordinates of the first image pixel */ 73 Sx = (Ix + image[0].X - 0.5*DX)/expand + 0.5*dx; 74 Sy = (Iy + image[0].Y - 0.5*DY)/expand + 0.5*dy; 47 // x, y are the closest lit screen pixel to dx, dy 48 Picture_Upper (&i_end, &j_end, matrix, picture); 75 49 76 i_start = MIN (MAX (Sx, 0), dx - expand_out + 1); 77 j_start = MIN (MAX (Sy, 0), dy - expand_out + 1); 78 79 if (image[0].expand > 0) { 80 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-Ix) + Sx), 0); 81 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Iy) + Sy), 0); 82 } else { 83 i_end = MAX (MIN (dx, (DX-Ix)/expand + Sx), 0); 84 j_end = MAX (MIN (dy, (DY-Iy)/expand + Sy), 0); 85 } 50 // Ix,Iy are the first displayed image pixel 51 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 86 52 87 53 dropback = expand_out - (i_end - i_start) % expand_out; 88 54 if ((i_end - i_start) % expand_out == 0) dropback = 0; 89 55 90 data = out_pix = (unsigned char *) image[0].picture.data;56 data = out_pix = (unsigned short *) picture[0].data; 91 57 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 92 58 … … 94 60 95 61 /**** fill in bottom area ****/ 96 for (j = 0; j < j_start; j++) { 97 for (i = 0; i < dx; i++, out_pix+=2) { 98 out_pix[0] = back1; 99 out_pix[1] = back2; 100 } 62 for (j = 0; j < dx*j_start; j++, out_pix++) { 63 *out_pix = back; 101 64 } 102 65 103 66 for (j = j_start; j < j_end; j+= expand_out, in_pix += expand_in*DX) { 104 out_pix = &data[ 2*j*dx];67 out_pix = &data[j*dx]; 105 68 106 69 /**** fill in area to the left of the picture ****/ 107 70 for (jj = 0; (i_start > 0) && (jj < expand_out); jj++) { 108 out_pix2 = out_pix + 2*jj*dx; 109 for (i = 0; i < i_start; i++, out_pix2+=2) { 110 out_pix2[0] = back1; 111 out_pix2[1] = back2; 71 out_pix2 = out_pix + jj*dx; 72 for (i = 0; i < i_start; i++, out_pix2++) { 73 *out_pix2 = back; 112 74 } 113 75 } 114 out_pix += 2*i_start;76 out_pix += i_start; 115 77 116 78 /*** fill in the picture region ***/ 117 79 in_pix2 = in_pix; 118 80 if (expand_out == 1) { 119 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=2) { 120 out_pix[0] = pixel1[*in_pix2]; 121 out_pix[1] = pixel2[*in_pix2]; 81 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 82 *out_pix = pixel[*in_pix2]; 122 83 } 123 } 124 else { 125 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 2*expand_out) { 126 pixvalue1 = pixel1[*in_pix2]; 127 pixvalue2 = pixel2[*in_pix2]; 84 } else { 85 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 86 pixvalue = pixel[*in_pix2]; 128 87 out_pix2 = out_pix; 129 for (jj = 0; jj < expand_out; jj++, out_pix2+=2*(dx-expand_out)) { 130 for (ii = 0; ii < expand_out; ii++, out_pix2+=2) { 131 out_pix2[0] = pixvalue1; 132 out_pix2[1] = pixvalue2; 88 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { 89 for (ii = 0; ii < expand_out; ii++, out_pix2++) { 90 *out_pix2 = pixvalue; 133 91 } 134 92 } 135 93 } 136 94 } 137 out_pix -= 2*dropback;95 out_pix -= dropback; 138 96 139 97 /**** fill in area to the right of the picture ****/ 140 98 for (jj = 0; jj < expand_out; jj++) { 141 out_pix2 = out_pix + 2*jj*dx; 142 for (i = i_end; i < dx; i++, out_pix2+=2) { 143 out_pix2[0] = back1; 144 out_pix2[1] = back2; 99 out_pix2 = out_pix + jj*dx; 100 for (i = i_end; i < dx; i++, out_pix2++) { 101 *out_pix2 = back; 145 102 } 146 103 } 147 104 } 148 105 149 /*150 if ((j_end - j_start) % expand_out > 0)151 out_pix -= expand_out - (j_end - j_start) % expand_out;152 */153 154 out_pix = &data[2*j_end*dx];155 106 /**** fill in top area ****/ 107 out_pix = &data[j_end*dx]; 156 108 for (j = 0; j < (dy - j_end); j++) { 157 for (i = 0; i < dx; i++, out_pix+=2) { 158 out_pix[0] = back1; 159 out_pix[1] = back2; 109 for (i = 0; i < dx; i++, out_pix++) { 110 *out_pix = back; 160 111 } 161 112 } 162 113 163 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,164 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 16, 0);114 picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 115 picture[0].data, picture[0].dx, picture[0].dy, 16, 0); 165 116 166 free (pixel1); 167 free (pixel2); 168 169 # endif 117 free (pixel); 170 118 } 171 -
trunk/Ohana/src/kapa2/src/Remap24.c
r16255 r16256 1 1 # include "Ximage.h" 2 2 3 void Remap24 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {3 void Remap24 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) { 4 4 5 # if (0)6 5 int i, j, ii, jj; 7 6 int i_start, i_end, j_start, j_end; 8 int dropback, extra; /* this is a bit of a kludge... */7 int dropback, extra; 9 8 int dx, dy, DX, DY; 10 double expand, Sx, Sy,Ix, Iy;9 double expand, Ix, Iy; 11 10 int expand_in, expand_out; 12 11 unsigned char *out_pix, *out_pix2, *data; … … 31 30 32 31 // set up expansions 32 assert ((picture[0].expand >= 1) || (picture[0].expand <= -2)); 33 33 expand = expand_in = expand_out = 1.0; 34 if ( image[0].expand == 0) /* set up expansions */35 image[0].expand = 1;36 if ( image[0].expand > 0) {37 expand = 1 / (1.0* image[0].expand);38 expand_out = image[0].expand;34 if (picture[0].expand == 0) /* set up expansions */ 35 picture[0].expand = 1; 36 if (picture[0].expand > 0) { 37 expand = 1 / (1.0*picture[0].expand); 38 expand_out = picture[0].expand; 39 39 expand_in = 1; 40 40 } 41 if ( image[0].expand < 0) {42 expand = fabs((double) image[0].expand);41 if (picture[0].expand < 0) { 42 expand = fabs((double)picture[0].expand); 43 43 expand_out = 1; 44 expand_in = - image[0].expand;44 expand_in = -picture[0].expand; 45 45 } 46 46 47 dx = image[0].picture.dx;48 dy = image[0].picture.dy;47 dx = picture[0].dx; 48 dy = picture[0].dy; 49 49 DX = matrix[0].Naxis[0]; 50 50 DY = matrix[0].Naxis[1]; 51 52 // each row is padded to a 4-byte word 51 53 extra = 4 - (dx * 3) % 4; 52 54 53 /* X,Y are the image coordinates of the first image pixel */ 54 Ix = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 55 if ((int)Ix != Ix) 56 Ix = (int) Ix + 1; 57 else 58 Ix = (int) Ix; 59 Iy = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 60 if ((int)Iy != Iy) 61 Iy = (int) Iy + 1; 62 else 63 Iy = (int) Iy; 55 // x, y are the closest lit screen pixel to 0,0 56 Picture_Lower (&i_start, &j_start, matrix, picture); 64 57 65 /* Sx,Sy are the screen coordinates of the first image pixel */ 66 Sx = (Ix + image[0].X - 0.5*DX)/expand + 0.5*dx; 67 Sy = (Iy + image[0].Y - 0.5*DY)/expand + 0.5*dy; 58 // x, y are the closest lit screen pixel to dx, dy 59 Picture_Upper (&i_end, &j_end, matrix, picture); 68 60 69 i_start = MIN (MAX (Sx, 0), dx - expand_out + 1); 70 j_start = MIN (MAX (Sy, 0), dy - expand_out + 1); 71 72 if (image[0].expand > 0) { 73 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-Ix) + Sx), 0); 74 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Iy) + Sy), 0); 75 } else { 76 i_end = MAX (MIN (dx, (DX-Ix)/expand + Sx), 0); 77 j_end = MAX (MIN (dy, (DY-Iy)/expand + Sy), 0); 78 } 61 // Ix,Iy are the first displayed image pixel 62 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 79 63 80 64 dropback = expand_out - (i_end - i_start) % expand_out; 81 65 if ((i_end - i_start) % expand_out == 0) dropback = 0; 82 83 data = out_pix = (unsigned char *) image[0].picture.data;66 67 data = out_pix = (unsigned char *) picture[0].data; 84 68 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 85 69 … … 146 130 } 147 131 148 /* 149 if ((j_end - j_start) % expand_out > 0) 150 out_pix -= expand_out - (j_end - j_start) % expand_out; 151 */ 152 132 /**** fill in top area ****/ 153 133 out_pix = &data[j_end*(3*dx+extra)]; 154 /**** fill in top area ****/155 134 for (j = 0; j < (dy - j_end); j++) { 156 135 for (i = 0; i < dx; i++, out_pix+=3) { … … 162 141 } 163 142 164 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,165 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 32, 0);143 picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 144 picture[0].data, picture[0].dx, picture[0].dy, 32, 0); 166 145 167 146 free (pixel1); 168 147 free (pixel2); 169 148 free (pixel3); 170 171 # endif172 149 } 173 -
trunk/Ohana/src/kapa2/src/Remap32.c
r16255 r16256 1 1 # include "Ximage.h" 2 2 3 void Remap32 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {3 void Remap32 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) { 4 4 5 5 int i, j, ii, jj; 6 6 int i_start, i_end, j_start, j_end; 7 int dropback; /* this is a bit of a kludge... */7 int dropback; 8 8 int dx, dy, DX, DY; 9 double expand, Sx, Sy,Ix, Iy;9 double expand, Ix, Iy; 10 10 int expand_in, expand_out; 11 11 unsigned int *out_pix, *out_pix2; … … 23 23 24 24 // set up expansions 25 assert (( image[0].picture.expand >= 1) || (image[0].picture.expand <= -2));25 assert ((picture[0].expand >= 1) || (picture[0].expand <= -2)); 26 26 expand = expand_in = expand_out = 1.0; 27 if ( image[0].picture.expand > 0) {28 expand = 1 / (1.0* image[0].picture.expand);29 expand_out = image[0].picture.expand;27 if (picture[0].expand > 0) { 28 expand = 1 / (1.0*picture[0].expand); 29 expand_out = picture[0].expand; 30 30 expand_in = 1; 31 31 } 32 if ( image[0].picture.expand < 0) {33 expand = fabs((double) image[0].picture.expand);32 if (picture[0].expand < 0) { 33 expand = fabs((double)picture[0].expand); 34 34 expand_out = 1; 35 expand_in = - image[0].picture.expand;35 expand_in = -picture[0].expand; 36 36 } 37 37 38 38 // define the image sizes 39 dx = image[0].picture.dx;40 dy = image[0].picture.dy;39 dx = picture[0].dx; 40 dy = picture[0].dy; 41 41 DX = matrix[0].Naxis[0]; 42 42 DY = matrix[0].Naxis[1]; 43 43 44 // Ix, Iy are the image coordinates of the 0,0 screen pixel45 Screen_to_Image (&Ix, &Iy, 0.0, 0.0, &image[0].picture);44 // x, y are the closest lit screen pixel to 0,0 45 Picture_Lower (&i_start, &j_start, matrix, picture); 46 46 47 // Ix, Iy are now limited to valid image coordinates 48 Ix = MIN (MAX (Ix, 0), DX); 49 Iy = MIN (MAX (Iy, 0), DY); 47 // x, y are the closest lit screen pixel to dx, dy 48 Picture_Upper (&i_end, &j_end, matrix, picture); 50 49 51 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 52 Image_to_Screen (&Sx, &Sy, Ix, Iy, &image[0].picture); 53 54 // i_start, j_start are now limited to valid screen coordinates 55 i_start = MIN (MAX (Sx, 0), dx); 56 j_start = MIN (MAX (Sy, 0), dy); 57 58 // Ix, Iy are the image coordinates of the 0,0 screen pixel 59 Screen_to_Image (&Ix, &Iy, dx, dy, &image[0].picture); 60 61 // Ix, Iy are now limited to valid image coordinates 62 Ix = MIN (MAX (Ix, 0), DX); 63 Iy = MIN (MAX (Iy, 0), DY); 64 65 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 66 Image_to_Screen (&Sx, &Sy, Ix, Iy, &image[0].picture); 67 68 // i_end, j_end are now limited to valid screen coordinates 69 i_end = MIN (MAX (Sx, 0), dx); 70 j_end = MIN (MAX (Sy, 0), dy); 50 // Ix,Iy are the first displayed image pixel 51 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 71 52 72 53 dropback = expand_out - (i_end - i_start) % expand_out; 73 54 if ((i_end - i_start) % expand_out == 0) dropback = 0; 74 55 75 out_pix = (unsigned int *) image[0].picture.data;56 out_pix = (unsigned int *) picture[0].data; 76 57 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 77 58 … … 127 108 128 109 /**** fill in top area ****/ 129 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *) image[0].picture.data < dx*dy); j++, out_pix++) {110 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)picture[0].data < dx*dy); j++, out_pix++) { 130 111 *out_pix = back; 131 112 } 132 113 133 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,134 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 32, 0);114 picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 115 picture[0].data, picture[0].dx, picture[0].dy, 32, 0); 135 116 136 117 free (pixel); -
trunk/Ohana/src/kapa2/src/Remap8.c
r16255 r16256 1 1 # include "Ximage.h" 2 2 3 void Remap8 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {3 void Remap8 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) { 4 4 5 # if (0)6 5 int i, j, ii, jj; 7 6 int i_start, i_end, j_start, j_end; 8 int dropback; /* this is a bit of a kludge... */9 int dx, dy, DX, DY , pixelN;10 double expand, Sx, Sy,Ix, Iy;7 int dropback; 8 int dx, dy, DX, DY; 9 double expand, Ix, Iy; 11 10 int expand_in, expand_out; 12 11 unsigned char *out_pix, *out_pix2; 13 12 unsigned short *in_pix, *in_pix2; 14 unsigned long*pixel, pixvalue;15 unsigned longback;13 unsigned char *pixel, pixvalue; 14 unsigned char back; 16 15 17 ALLOCATE (pixel, unsigned long, graphic[0].Npixels);16 ALLOCATE (pixel, unsigned char, graphic[0].Npixels); 18 17 19 18 // local array for pixel values 20 19 for (i = 0; i < graphic[0].Npixels; i++) { 21 pixel[i] = graphic[0].cmap[i].pixel;20 pixel[i] = 0xff & graphic[0].cmap[i].pixel; 22 21 } 23 back = graphic[0].back;22 back = 0xff & graphic[0].back; 24 23 25 24 // set up expansions 25 assert ((picture[0].expand >= 1) || (picture[0].expand <= -2)); 26 26 expand = expand_in = expand_out = 1.0; 27 if ( image[0].expand == 0) /* set up expansions */28 image[0].expand = 1;29 if ( image[0].expand > 0) {30 expand = 1 / (1.0* image[0].expand);31 expand_out = image[0].expand;27 if (picture[0].expand == 0) /* set up expansions */ 28 picture[0].expand = 1; 29 if (picture[0].expand > 0) { 30 expand = 1 / (1.0*picture[0].expand); 31 expand_out = picture[0].expand; 32 32 expand_in = 1; 33 33 } 34 if ( image[0].expand < 0) {35 expand = fabs((double) image[0].expand);34 if (picture[0].expand < 0) { 35 expand = fabs((double)picture[0].expand); 36 36 expand_out = 1; 37 expand_in = - image[0].expand;37 expand_in = -picture[0].expand; 38 38 } 39 39 40 40 // define the image boundaries 41 dx = image[0].picture.dx;42 dy = image[0].picture.dy;41 dx = picture[0].dx; 42 dy = picture[0].dy; 43 43 DX = matrix[0].Naxis[0]; 44 44 DY = matrix[0].Naxis[1]; 45 45 46 /* X,Y are the image coordinates of the first image pixel */ 47 Ix = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 48 if ((int)Ix != Ix) 49 Ix = (int) Ix + 1; 50 else 51 Ix = (int) Ix; 52 Iy = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 53 if ((int)Iy != Iy) 54 Iy = (int) Iy + 1; 55 else 56 Iy = (int) Iy; 46 // x, y are the closest lit screen pixel to 0,0 47 Picture_Lower (&i_start, &j_start, matrix, picture); 57 48 58 /* Sx,Sy are the screen coordinates of the first image pixel */ 59 Sx = (Ix + image[0].X - 0.5*DX)/expand + 0.5*dx; 60 Sy = (Iy + image[0].Y - 0.5*DY)/expand + 0.5*dy; 49 // x, y are the closest lit screen pixel to dx, dy 50 Picture_Upper (&i_end, &j_end, matrix, picture); 61 51 62 i_start = MIN (MAX (Sx, 0), dx - expand_out + 1); 63 j_start = MIN (MAX (Sy, 0), dy - expand_out + 1); 64 65 if (image[0].expand > 0) { 66 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-Ix) + Sx), 0); 67 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Iy) + Sy), 0); 68 } else { 69 i_end = MAX (MIN (dx, (DX-Ix)/expand + Sx), 0); 70 j_end = MAX (MIN (dy, (DY-Iy)/expand + Sy), 0); 71 } 52 // Ix,Iy are the first displayed image pixel 53 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 72 54 73 55 dropback = expand_out - (i_end - i_start) % expand_out; 74 56 if ((i_end - i_start) % expand_out == 0) dropback = 0; 75 57 76 out_pix = (unsigned char *) image[0].picture.data;58 out_pix = (unsigned char *) picture[0].data; 77 59 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 78 60 … … 80 62 81 63 /**** fill in bottom area ****/ 82 for (j = 0; j < dx*j_start; j++, out_pix++) 64 for (j = 0; j < dx*j_start; j++, out_pix++) { 83 65 *out_pix = back; 66 } 84 67 85 68 for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) { … … 128 111 129 112 /**** fill in top area ****/ 130 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned char *) image[0].picture.data < dx*dy); j++, out_pix++) {113 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned char *)picture[0].data < dx*dy); j++, out_pix++) { 131 114 *out_pix = back; 132 115 } 133 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 134 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 8, 0); 135 136 # endif 116 picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 117 picture[0].data, picture[0].dx, picture[0].dy, 8, 0); 118 free (pixel); 137 119 } 138 -
trunk/Ohana/src/kapa2/src/SetImageData.c
r16228 r16256 125 125 image = section->image; 126 126 127 Screen_to_Image (&Xmin, &Ymin, 0.0, 0.0, &image[0].picture);128 Screen_to_Image (&Xmax, &Ymax, image[0].picture.dx, image[0].picture.dy, &image[0].picture);127 Picture_to_Image (&Xmin, &Ymin, 0.0, 0.0, &image[0].picture); 128 Picture_to_Image (&Xmax, &Ymax, image[0].picture.dx, image[0].picture.dy, &image[0].picture); 129 129 130 130 KiiSendMessage (sock, "%g %g %g %g", Xmin, Xmax, Ymin, Ymax); -
trunk/Ohana/src/kapa2/src/SetImageSize.c
r16011 r16256 319 319 CreatePicture (image, graphic); 320 320 CreateColorbar (image, graphic); 321 CreateZoom ( image, graphic, 0, 0);321 CreateZoom (graphic, image); 322 322 } 323 323 Remap (graphic, image); -
trunk/Ohana/src/kapa2/src/StatusBox.c
r16255 r16256 11 11 y = 0.5*image[0].image[0].matrix.Naxis[1]; 12 12 // z = -1; 13 image[0].zoom. x= x;14 image[0].zoom. y= y;13 image[0].zoom.X = x; 14 image[0].zoom.Y = y; 15 15 // image[0].z = z; 16 16 } else { 17 x = image[0].zoom. x;18 y = image[0].zoom. y;17 x = image[0].zoom.X; 18 y = image[0].zoom.Y; 19 19 // z = image[0].z; 20 20 } -
trunk/Ohana/src/kapa2/src/UpdatePointer.c
r16255 r16256 19 19 20 20 data = (float *) image[0].image[0].matrix.buffer; 21 Screen_to_Image (&x, &y, (double)event[0].x, (double)event[0].y, &image[0].picture);21 Screen_to_Image (&x, &y, event[0].x + 0.5, event[0].y + 0.5, &image[0].picture); 22 22 23 23 z = -1; … … 35 35 XFlush (graphic[0].display); 36 36 37 CreateZoom ( image, graphic, x, y);37 CreateZoom (graphic, image); 38 38 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 39 39 image[0].zoom.pix, 0, 0,
Note:
See TracChangeset
for help on using the changeset viewer.
