Changeset 16228
- Timestamp:
- Jan 24, 2008, 5:45:18 PM (18 years ago)
- Location:
- trunk/Ohana/src/kapa2
- Files:
-
- 20 edited
-
include/structures.h (modified) (2 diffs)
-
src/ButtonFunctions.c (modified) (2 diffs)
-
src/Center.c (modified) (1 diff)
-
src/CreateZoom32.c (modified) (3 diffs)
-
src/CrossHairs.c (modified) (1 diff)
-
src/CursorOps.c (modified) (2 diffs)
-
src/Image.c (modified) (1 diff)
-
src/InterpretKeys.c (modified) (2 diffs)
-
src/InterpretPresses.c (modified) (2 diffs)
-
src/LoadPicture.c (modified) (1 diff)
-
src/PSOverlay.c (modified) (1 diff)
-
src/PaintOverlay.c (modified) (1 diff)
-
src/Remap16.c (modified) (6 diffs)
-
src/Remap24.c (modified) (6 diffs)
-
src/Remap32.c (modified) (3 diffs)
-
src/Remap8.c (modified) (5 diffs)
-
src/Reorient.c (modified) (3 diffs)
-
src/SetImageData.c (modified) (1 diff)
-
src/UpdatePointer.c (modified) (3 diffs)
-
src/bDrawOverlay.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/include/structures.h
r16039 r16228 90 90 91 91 typedef struct { 92 int dx, dy, x, y; 92 int x, y; // location of picture in graphic 93 int dx, dy; // size of picture 94 int DX, DY; // size of displayed picture (must be updated with new images...) 95 int expand; // zoomscale 96 double Xo, Yo; // image pixel at screen center 93 97 XImage *pix; 94 98 char *data; … … 183 187 int DecimalDegrees; 184 188 185 double X, Y; /* image pixel at screen center */ 186 int expand; /* zoomscale */ 187 double x, y, z; /* last pointer coords */ 189 // double X, Y; /* image pixel at screen center */ 190 // double x, y, z; /* last pointer coords */ 188 191 189 192 Overlay overlay[NOVERLAYS]; -
trunk/Ohana/src/kapa2/src/ButtonFunctions.c
r16039 r16228 56 56 int Rescale (Graphic *graphic, KapaImageWidget *image) { 57 57 58 image[0]. expand = 1;58 image[0].picture.expand = 1; 59 59 Remap (graphic, image); 60 60 Refresh (); … … 66 66 int RecenterRescale (Graphic *graphic, KapaImageWidget *image) { 67 67 68 image[0]. X = 0;69 image[0]. Y = 0;70 image[0]. expand = 1;68 image[0].picture.X = 0; 69 image[0].picture.Y = 0; 70 image[0].picture.expand = 1; 71 71 72 72 Remap (graphic, image); -
trunk/Ohana/src/kapa2/src/Center.c
r16011 r16228 16 16 if (image == NULL) return (TRUE); 17 17 18 image[0]. X = 0.5*image[0].image[0].matrix.Naxis[0] - X;19 image[0]. Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y;18 image[0].picture.X = 0.5*image[0].image[0].matrix.Naxis[0] - X; 19 image[0].picture.Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y; 20 20 if ((zoom != 0) && (zoom != -1)) { 21 image[0]. expand = zoom;21 image[0].picture.expand = zoom; 22 22 } 23 23 -
trunk/Ohana/src/kapa2/src/CreateZoom32.c
r16061 r16228 8 8 int dropback; /* this is a bit of a kludge... */ 9 9 int dx, dy, DX, DY; 10 double expand, zoomscale, Rx, Ry;10 double expand, zoomscale, Ix, Iy; 11 11 int expand_in, expand_out; 12 12 unsigned int *out_pix, *out_pix2; … … 40 40 DY = image[0].image[0].matrix.Naxis[1]; 41 41 42 /* Rx,Ry are the screen coordinates of the first image pixel */ 43 Rx = x - expand*(int)(0.5*(dx + 1)) + 1; 44 Ry = y - expand*(int)(0.5*(dy + 1)) + 1; 42 /* Ix,Iy are the image coordinates of the first image pixel */ 43 // x,y is the image coordinate of the zoombox center 44 Ix = x - expand*(int)(0.5*(dx + 1)) + 1; 45 Iy = y - expand*(int)(0.5*(dy + 1)) + 1; 45 46 46 i_start = MIN (MAX (- Rx / expand, (1 - FRAC(Rx)) / expand), dx - expand_out + 1);47 j_start = MIN (MAX (- Ry / expand, (1 - FRAC(Ry)) / expand), dy - expand_out + 1);48 i_end = MAX (MIN ((DX- Rx) / expand, dx - expand_out + 1), 0);49 j_end = MAX (MIN ((DY- Ry) / expand, dy - expand_out + 1), 0);47 i_start = MIN (MAX (-Ix / expand, (1 - FRAC(Ix)) / expand), dx - expand_out + 1); 48 j_start = MIN (MAX (-Iy / expand, (1 - FRAC(Iy)) / expand), dy - expand_out + 1); 49 i_end = MAX (MIN ((DX-Ix) / expand, dx - expand_out + 1), 0); 50 j_end = MAX (MIN ((DY-Iy) / expand, dy - expand_out + 1), 0); 50 51 51 52 dropback = expand_out - (i_end - i_start) % expand_out; … … 53 54 54 55 out_pix = (unsigned int *) image[0].zoom.data; 55 in_pix = &image[0].pixmap[DX*(int)MAX( Ry,0) + (int)MAX(Rx,0)];56 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 56 57 57 58 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ -
trunk/Ohana/src/kapa2/src/CrossHairs.c
r13320 r16228 7 7 double zoomscale; 8 8 9 zoomscale = MAX (5, image[0].expand + 5);9 zoomscale = image[0].zoom; 10 10 x0 = (zoomscale) * (0.5 * (ZOOM_X + 1) / zoomscale - 2.5) + image[0].zoom.x; 11 11 x5 = (zoomscale) * (0.5 * (ZOOM_X + 1) / zoomscale - 0.5) + image[0].zoom.x; -
trunk/Ohana/src/kapa2/src/CursorOps.c
r16011 r16228 1 1 # include "Ximage.h" 2 2 3 void Screen_to_Image (double *x1, double *y1, double x2, double y2, KapaImageWidget *image) {3 void Screen_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) { 4 4 5 5 double expand; 6 6 7 7 expand = 1.0; 8 if (image[0].expand > 0) { 9 expand = 1 / (1.0*image[0].expand); 10 } 11 if (image[0].expand < 0) { 12 expand = fabs((double)image[0].expand); 8 if (picture[0].expand > 0) { 9 expand = 1 / (1.0*picture[0].expand); 10 } else { 11 expand = fabs((double)picture[0].expand); 13 12 } 14 13 15 *x1 = expand*(x2 - image[0].picture.x - 0.5*image[0].picture.dx) + 0.5*image[0].image[0].matrix.Naxis[0] - image[0].X; 16 *y1 = expand*(y2 - image[0].picture.y - 0.5*image[0].picture.dy) + 0.5*image[0].image[0].matrix.Naxis[1] - image[0].Y; 17 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; 18 21 } 19 22 20 void Image_to_Screen (double *x1, double *y1, double x2, double y2, KapaImageWidget *image) {23 void Image_to_Screen (double *x1, double *y1, double x2, double y2, Picture *picture) { 21 24 22 25 double expand; … … 24 27 /* notice that here, expand is the reciprocal of the expand above */ 25 28 expand = 1.0; 26 if (image[0].expand > 0) { 27 expand = abs(image[0].expand); 28 } 29 if (image[0].expand < 0) { 30 expand = 1 / ((double)abs(image[0].expand)); 29 if (picture[0].expand > 0) { 30 expand = picture[0].expand; 31 } else { 32 expand = 1 / fabs((double)image[0].expand); 31 33 } 32 34 33 *x1 = (x2 - 0.5*image[0].image[0].matrix.Naxis[0] + image[0].X) * expand + image[0].picture.x + 0.5*image[0].picture.dx; 34 *y1 = (y2 - 0.5*image[0].image[0].matrix.Naxis[1] + image[0].Y) * expand + image[0].picture.y + 0.5*image[0].picture.dy; 35 35 // 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; 38 39 // pixel coordinates in screen frame 40 *x1 = xs + picture[0].x; 41 *y1 = ys + picture[0].y; 36 42 } 37 43 -
trunk/Ohana/src/kapa2/src/Image.c
r16011 r16228 47 47 } 48 48 49 image[0].X = 0.0; 50 image[0].Y = 0.0; 51 image[0].expand = 1; 49 // set the center and expansion for the pictures: 50 image[0].picture.X = 0.0; 51 image[0].picture.Y = 0.0; 52 image[0].picture.expand = 1; 53 54 image[0].zoom.X = 0.0; 55 image[0].zoom.Y = 0.0; 56 image[0].zoom.expand = +5; 57 58 image[0].wide.X = 0.0; 59 image[0].wide.Y = 0.0; 60 image[0].wide.expand = -5; 61 52 62 image[0].location = 4; 53 63 -
trunk/Ohana/src/kapa2/src/InterpretKeys.c
r16039 r16228 60 60 if (event[0].x > image[0].picture.x + image[0].picture.dx) goto skip_cursor; 61 61 if (event[0].y > image[0].picture.y + image[0].picture.dy) goto skip_cursor; 62 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, image);62 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, &image[0].picture); 63 63 XY_to_RD (&R, &D, X, Y, &image[0].image[0].coords); 64 64 … … 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);126 X = 0.5*image[0]. image[0].matrix.Naxis[0]- X;127 Y = 0.5*image[0]. image[0].matrix.Naxis[1]- Y;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; 128 128 Reorient (graphic, image, X, Y, 0); 129 129 break; -
trunk/Ohana/src/kapa2/src/InterpretPresses.c
r16011 r16228 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);36 Screen_to_Image (&X, &Y, (double)event[0].x, (double)event[0].y, &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);103 Screen_to_Image (&X, &Y, (double)mouse_event[0].x, (double)mouse_event[0].y, &image[0].picture); 104 104 X = 0.5*image[0].image[0].matrix.Naxis[0] - X; 105 105 Y = 0.5*image[0].image[0].matrix.Naxis[1] - Y; -
trunk/Ohana/src/kapa2/src/LoadPicture.c
r16011 r16228 32 32 gfits_free_matrix (&image[0].image[0].matrix); 33 33 gfits_create_matrix (&header, &image[0].image[0].matrix); 34 35 // reference point for image is the center pixel 36 image[0].picture.Xo = 0.5*header.Naxis[0]; 37 image[0].picture.Yo = 0.5*header.Naxis[1]; 34 38 35 39 fcntl (sock, F_SETFL, O_NONBLOCK); -
trunk/Ohana/src/kapa2/src/PSOverlay.c
r15620 r16228 16 16 } 17 17 18 Image_to_Screen (&X0, &Y0, 0.0, 0.0, image);18 Image_to_Screen (&X0, &Y0, 0.0, 0.0, &image[0].picture); 19 19 X0 -= image[0].picture.x; 20 20 Y0 -= image[0].picture.y; -
trunk/Ohana/src/kapa2/src/PaintOverlay.c
r15620 r16228 18 18 } 19 19 20 Image_to_Screen (&X0, &Y0, 0.0, 0.0, image);20 Image_to_Screen (&X0, &Y0, 0.0, 0.0, &image[0].picture); 21 21 22 22 Xmin = image[0].picture.x; -
trunk/Ohana/src/kapa2/src/Remap16.c
r16011 r16228 1 1 # include "Ximage.h" 2 3 static float slope = 1.0;4 static float start = 0.0;5 static int MaxValue = 255;6 7 // XXX inline this if needed8 static int PixelLookup(float value) {9 int out;10 out = MIN (MAX (slope * value - start, 0), MaxValue);11 return (out);12 }13 2 14 3 void Remap16 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 17 6 int i_start, i_end, j_start, j_end; 18 7 int dropback; /* this is a bit of a kludge... */ 19 int dx, dy, DX, DY , pixelN;20 double expand, Rx, Ry, X, Y;8 int dx, dy, DX, DY; 9 double expand, Sx, Sy, Ix, Iy; 21 10 int expand_in, expand_out; 22 11 unsigned char *out_pix, *out_pix2, *data; 23 float *imdata,*in_pix, *in_pix2;24 unsigned char pixel1[256], pixel2[256];12 unsigned short *in_pix, *in_pix2; 13 unsigned char *pixel1, *pixel2; 25 14 unsigned char pixvalue1, pixvalue2; 26 unsigned long back;27 15 unsigned char back1, back2; 28 16 17 ALLOCATE (pixel1, unsigned char, graphic[0].Npixels); 18 ALLOCATE (pixel2, unsigned char, graphic[0].Npixels); 19 29 20 // local array for pixel values (is this working??) 30 for (i = 0; i < 256; i++) { /* set up pixel array */21 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 31 22 pixel1[i] = 0x00ff & graphic[0].cmap[i].pixel; 32 23 pixel2[i] = 0x00ff & (graphic[0].cmap[i].pixel >> 8); 33 24 } 34 back = graphic[0].back; 35 back1 = 0x00ff & back; 36 back2 = 0x00ff & (back >> 8); 25 back1 = 0x00ff & (graphic[0].back >> 0); 26 back2 = 0x00ff & (graphic[0].back >> 8); 37 27 38 28 // define the color transform parameters … … 68 58 69 59 /* X,Y are the image coordinates of the first image pixel */ 70 X= MAX(0.5*(DX - dx*expand) - image[0].X, 0);71 if ((int) X != X)72 X = (int) X+ 1;60 Ix = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 61 if ((int)Ix != Ix) 62 Ix = (int) Ix + 1; 73 63 else 74 X = (int) X;75 Y= MAX(0.5*(DY - dy*expand) - image[0].Y, 0);76 if ((int) Y != Y)77 Y = (int) Y+ 1;64 Ix = (int) Ix; 65 Iy = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 66 if ((int)Iy != Iy) 67 Iy = (int) Iy + 1; 78 68 else 79 Y = (int) Y;69 Iy = (int) Iy; 80 70 81 /* Rx,Ry are the screen coordinates of the first image pixel */82 Rx = (X+ image[0].X - 0.5*DX)/expand + 0.5*dx;83 Ry = (Y+ image[0].Y - 0.5*DY)/expand + 0.5*dy;71 /* Sx,Sy are the screen coordinates of the first image pixel */ 72 Sx = (Ix + image[0].X - 0.5*DX)/expand + 0.5*dx; 73 Sy = (Iy + image[0].Y - 0.5*DY)/expand + 0.5*dy; 84 74 85 i_start = MIN (MAX ( Rx, 0), dx - expand_out + 1);86 j_start = MIN (MAX ( Ry, 0), dy - expand_out + 1);75 i_start = MIN (MAX (Sx, 0), dx - expand_out + 1); 76 j_start = MIN (MAX (Sy, 0), dy - expand_out + 1); 87 77 88 78 if (image[0].expand > 0) { 89 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX- X) + Rx), 0);90 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY- Y) + Ry), 0);79 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-Ix) + Sx), 0); 80 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Iy) + Sy), 0); 91 81 } else { 92 i_end = MAX (MIN (dx, (DX- X)/expand + Rx), 0);93 j_end = MAX (MIN (dy, (DY- Y)/expand + Ry), 0);82 i_end = MAX (MIN (dx, (DX-Ix)/expand + Sx), 0); 83 j_end = MAX (MIN (dy, (DY-Iy)/expand + Sy), 0); 94 84 } 95 85 … … 98 88 99 89 data = out_pix = (unsigned char *) image[0].picture.data; 100 imdata = (float *) matrix[0].buffer; 101 in_pix = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 90 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 102 91 103 92 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 128 117 if (expand_out == 1) { 129 118 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=2) { 130 pixelN = PixelLookup(*in_pix2); 131 out_pix[0] = pixel1[pixelN]; 132 out_pix[1] = pixel2[pixelN]; 119 out_pix[0] = pixel1[*in_pix2]; 120 out_pix[1] = pixel2[*in_pix2]; 133 121 } 134 122 } 135 123 else { 136 124 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 2*expand_out) { 137 pixelN = PixelLookup(*in_pix2); 138 pixvalue1 = pixel1[pixelN]; 139 pixvalue2 = pixel2[pixelN]; 125 pixvalue1 = pixel1[*in_pix2]; 126 pixvalue2 = pixel2[*in_pix2]; 140 127 out_pix2 = out_pix; 141 128 for (jj = 0; jj < expand_out; jj++, out_pix2+=2*(dx-expand_out)) { … … 175 162 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 176 163 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 16, 0); 164 165 free (pixel1); 166 free (pixel2); 177 167 } 178 168 -
trunk/Ohana/src/kapa2/src/Remap24.c
r16011 r16228 1 1 # include "Ximage.h" 2 3 static float slope = 1.0;4 static float start = 0.0;5 static int MaxValue = 255;6 7 // XXX inline this if needed8 static int PixelLookup(float value) {9 int out;10 out = MIN (MAX (slope * value - start, 0), MaxValue);11 return (out);12 }13 2 14 3 void Remap24 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 17 6 int i_start, i_end, j_start, j_end; 18 7 int dropback, extra; /* this is a bit of a kludge... */ 19 int dx, dy, DX, DY , pixelN;20 double expand, Rx, Ry, X, Y;8 int dx, dy, DX, DY; 9 double expand, Sx, Sy, Ix, Iy; 21 10 int expand_in, expand_out; 22 11 unsigned char *out_pix, *out_pix2, *data; 23 float *imdata,*in_pix, *in_pix2;24 unsigned char pixel1[256], pixel2[256], pixel3[256];12 unsigned short *in_pix, *in_pix2; 13 unsigned char *pixel1, *pixel2, *pixel3; 25 14 unsigned char pixvalue1, pixvalue2, pixvalue3; 26 unsigned long back;27 15 unsigned char back1, back2, back3; 28 16 17 ALLOCATE (pixel1, unsigned char, graphic[0].Npixels); 18 ALLOCATE (pixel2, unsigned char, graphic[0].Npixels); 19 ALLOCATE (pixel3, unsigned char, graphic[0].Npixels); 20 29 21 // local arrays for pixel values 30 for (i = 0; i < 256; i++) { /* set up pixel array */22 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 31 23 pixel1[i] = 0x0000ff & graphic[0].cmap[i].pixel; 32 24 pixel2[i] = 0x0000ff & (graphic[0].cmap[i].pixel >> 8); 33 25 pixel3[i] = 0x0000ff & (graphic[0].cmap[i].pixel >> 16); 34 26 } 35 back = graphic[0].back; 36 back1 = 0x0000ff & back; 37 back2 = 0x0000ff & (back >> 8); 38 back3 = 0x0000ff & (back >> 16); 39 40 // define the color transform parameters 41 MaxValue = graphic[0].Npixels - 1; 42 if (image[0].image[0].range != 0.0) { 43 slope = graphic[0].Npixels / image[0].image[0].range; 44 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range; 45 } else { 46 slope = 1.0; 47 start = image[0].image[0].zero; 48 } 27 back1 = 0x0000ff & (graphic[0].back >> 0); 28 back2 = 0x0000ff & (graphic[0].back >> 8); 29 back3 = 0x0000ff & (graphic[0].back >> 16); 49 30 50 31 // set up expansions … … 70 51 71 52 /* X,Y are the image coordinates of the first image pixel */ 72 X= MAX(0.5*(DX - dx*expand) - image[0].X, 0);73 if ((int) X != X)74 X = (int) X+ 1;53 Ix = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 54 if ((int)Ix != Ix) 55 Ix = (int) Ix + 1; 75 56 else 76 X = (int) X;77 Y= MAX(0.5*(DY - dy*expand) - image[0].Y, 0);78 if ((int) Y != Y)79 Y = (int) Y+ 1;57 Ix = (int) Ix; 58 Iy = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 59 if ((int)Iy != Iy) 60 Iy = (int) Iy + 1; 80 61 else 81 Y = (int) Y;62 Iy = (int) Iy; 82 63 83 /* Rx,Ry are the screen coordinates of the first image pixel */84 Rx = (X+ image[0].X - 0.5*DX)/expand + 0.5*dx;85 Ry = (Y+ image[0].Y - 0.5*DY)/expand + 0.5*dy;64 /* Sx,Sy are the screen coordinates of the first image pixel */ 65 Sx = (Ix + image[0].X - 0.5*DX)/expand + 0.5*dx; 66 Sy = (Iy + image[0].Y - 0.5*DY)/expand + 0.5*dy; 86 67 87 i_start = MIN (MAX ( Rx, 0), dx - expand_out + 1);88 j_start = MIN (MAX ( Ry, 0), dy - expand_out + 1);68 i_start = MIN (MAX (Sx, 0), dx - expand_out + 1); 69 j_start = MIN (MAX (Sy, 0), dy - expand_out + 1); 89 70 90 71 if (image[0].expand > 0) { 91 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX- X) + Rx), 0);92 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY- Y) + Ry), 0);72 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-Ix) + Sx), 0); 73 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Iy) + Sy), 0); 93 74 } else { 94 i_end = MAX (MIN (dx, (DX- X)/expand + Rx), 0);95 j_end = MAX (MIN (dy, (DY- Y)/expand + Ry), 0);75 i_end = MAX (MIN (dx, (DX-Ix)/expand + Sx), 0); 76 j_end = MAX (MIN (dy, (DY-Iy)/expand + Sy), 0); 96 77 } 97 78 … … 100 81 101 82 data = out_pix = (unsigned char *) image[0].picture.data; 102 imdata = (float *) matrix[0].buffer; 103 in_pix = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 83 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 104 84 105 85 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 133 113 if (expand_out == 1) { 134 114 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=3) { 135 pixelN = PixelLookup(*in_pix2); 136 out_pix[0] = pixel1[pixelN]; 137 out_pix[1] = pixel2[pixelN]; 138 out_pix[2] = pixel3[pixelN]; 115 out_pix[0] = pixel1[*in_pix2]; 116 out_pix[1] = pixel2[*in_pix2]; 117 out_pix[2] = pixel3[*in_pix2]; 139 118 } 140 119 } else { 141 120 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 3*expand_out) { 142 pixelN = PixelLookup(*in_pix2); 143 pixvalue1 = pixel1[pixelN]; 144 pixvalue2 = pixel2[pixelN]; 145 pixvalue3 = pixel3[pixelN]; 121 pixvalue1 = pixel1[*in_pix2]; 122 pixvalue2 = pixel2[*in_pix2]; 123 pixvalue3 = pixel3[*in_pix2]; 146 124 out_pix2 = out_pix; 147 125 for (jj = 0; jj < expand_out; jj++, out_pix2+=3*(dx-expand_out)+extra) { … … 185 163 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 186 164 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 32, 0); 165 166 free (pixel1); 167 free (pixel2); 168 free (pixel3); 187 169 } 188 170 -
trunk/Ohana/src/kapa2/src/Remap32.c
r16061 r16228 7 7 int dropback; /* this is a bit of a kludge... */ 8 8 int dx, dy, DX, DY; 9 double expand, Rx, Ry, X, Y;9 double expand, Sx, Sy, Ix, Iy; 10 10 int expand_in, expand_out; 11 11 unsigned int *out_pix, *out_pix2; … … 43 43 DY = matrix[0].Naxis[1]; 44 44 45 /* X,Y are the image coordinates of the first image pixel */ 46 X = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 47 if ((int)X != X) 48 X = (int) X + 1; 49 else 50 X = (int) X; 51 Y = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 52 if ((int)Y != Y) 53 Y = (int) Y + 1; 54 else 55 Y = (int) Y; 45 // Ix, Iy are the image coordinates of the 0,0 screen pixel 46 Screen_to_Image (&Ix, &Iy, 0.0, 0.0, &image[0].picture); 56 47 57 / * Rx,Ry are the screen coordinates of the first image pixel */58 Rx = (X + image[0].X - 0.5*DX)/expand + 0.5*dx;59 Ry = (Y + image[0].Y - 0.5*DY)/expand + 0.5*dy;48 // Ix, Iy are now limited to valid image coordinates 49 Ix = MIN (MAX (Ix, 0), DX); 50 Iy = MIN (MAX (Iy, 0), DY); 60 51 61 i_start = MIN (MAX (Rx, 0), dx - expand_out + 1); 62 j_start = MIN (MAX (Ry, 0), dy - expand_out + 1); 63 64 if (image[0].expand > 0) { 65 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-X) + Rx), 0); 66 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Y) + Ry), 0); 67 } else { 68 i_end = MAX (MIN (dx, (DX-X)/expand + Rx), 0); 69 j_end = MAX (MIN (dy, (DY-Y)/expand + Ry), 0); 70 } 52 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 53 Image_to_Screen (&Sx, &Sy, Ix, Iy, &image[0].picture); 54 55 // i_start, j_start are now limited to valid screen coordinates 56 i_start = MIN (MAX (Sx, 0), dx); 57 j_start = MIN (MAX (Sy, 0), dy); 58 59 // Ix, Iy are the image coordinates of the 0,0 screen pixel 60 Screen_to_Image (&Ix, &Iy, dx, dy, &image[0].picture); 61 62 // Ix, Iy are now limited to valid image coordinates 63 Ix = MIN (MAX (Ix, 0), DX); 64 Iy = MIN (MAX (Iy, 0), DY); 65 66 // Sx, Sy are the screen coordinates of the Ix,Iy pixel 67 Image_to_Screen (&Sx, &Sy, Ix, Iy, &image[0].picture); 68 69 // i_end, j_end are now limited to valid screen coordinates 70 i_end = MIN (MAX (Sx, 0), dx); 71 j_end = MIN (MAX (Sy, 0), dy); 71 72 72 73 dropback = expand_out - (i_end - i_start) % expand_out; … … 74 75 75 76 out_pix = (unsigned int *) image[0].picture.data; 76 in_pix = &image[0].pixmap[DX*(int)MAX( Y,0) + (int)MAX(X,0)];77 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 77 78 78 79 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ -
trunk/Ohana/src/kapa2/src/Remap8.c
r16011 r16228 1 1 # include "Ximage.h" 2 3 static float slope = 1.0;4 static float start = 0.0;5 static int MaxValue = 255;6 7 // XXX inline this if needed8 static int PixelLookup(float value) {9 int out;10 out = MIN (MAX (slope * value - start, 0), MaxValue);11 return (out);12 }13 2 14 3 void Remap8 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 18 7 int dropback; /* this is a bit of a kludge... */ 19 8 int dx, dy, DX, DY, pixelN; 20 double expand, Rx, Ry, X, Y;9 double expand, Sx, Sy, Ix, Iy; 21 10 int expand_in, expand_out; 22 11 unsigned char *out_pix, *out_pix2; 23 float *imdata,*in_pix, *in_pix2;24 unsigned long pixel[256], pixvalue;12 unsigned short *in_pix, *in_pix2; 13 unsigned long *pixel, pixvalue; 25 14 unsigned long back; 26 15 16 ALLOCATE (pixel, unsigned long, graphic[0].Npixels); 17 27 18 // local array for pixel values 28 for (i = 0; i < 256; i++) {19 for (i = 0; i < graphic[0].Npixels; i++) { 29 20 pixel[i] = graphic[0].cmap[i].pixel; 30 21 } 31 22 back = graphic[0].back; 32 33 // define the color transform parameters34 MaxValue = graphic[0].Npixels - 1;35 if (image[0].image[0].range != 0.0) {36 slope = graphic[0].Npixels / image[0].image[0].range;37 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;38 } else {39 slope = 1.0;40 start = image[0].image[0].zero;41 }42 23 43 24 // set up expansions … … 63 44 64 45 /* X,Y are the image coordinates of the first image pixel */ 65 X= MAX(0.5*(DX - dx*expand) - image[0].X, 0);66 if ((int) X != X)67 X = (int) X+ 1;46 Ix = MAX(0.5*(DX - dx*expand) - image[0].X, 0); 47 if ((int)Ix != Ix) 48 Ix = (int) Ix + 1; 68 49 else 69 X = (int) X;70 Y= MAX(0.5*(DY - dy*expand) - image[0].Y, 0);71 if ((int) Y != Y)72 Y = (int) Y+ 1;50 Ix = (int) Ix; 51 Iy = MAX(0.5*(DY - dy*expand) - image[0].Y, 0); 52 if ((int)Iy != Iy) 53 Iy = (int) Iy + 1; 73 54 else 74 Y = (int) Y;55 Iy = (int) Iy; 75 56 76 /* Rx,Ry are the screen coordinates of the first image pixel */77 Rx = (X+ image[0].X - 0.5*DX)/expand + 0.5*dx;78 Ry = (Y+ image[0].Y - 0.5*DY)/expand + 0.5*dy;57 /* Sx,Sy are the screen coordinates of the first image pixel */ 58 Sx = (Ix + image[0].X - 0.5*DX)/expand + 0.5*dx; 59 Sy = (Iy + image[0].Y - 0.5*DY)/expand + 0.5*dy; 79 60 80 i_start = MIN (MAX ( Rx, 0), dx - expand_out + 1);81 j_start = MIN (MAX ( Ry, 0), dy - expand_out + 1);61 i_start = MIN (MAX (Sx, 0), dx - expand_out + 1); 62 j_start = MIN (MAX (Sy, 0), dy - expand_out + 1); 82 63 83 64 if (image[0].expand > 0) { 84 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX- X) + Rx), 0);85 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY- Y) + Ry), 0);65 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-Ix) + Sx), 0); 66 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Iy) + Sy), 0); 86 67 } else { 87 i_end = MAX (MIN (dx, (DX- X)/expand + Rx), 0);88 j_end = MAX (MIN (dy, (DY- Y)/expand + Ry), 0);68 i_end = MAX (MIN (dx, (DX-Ix)/expand + Sx), 0); 69 j_end = MAX (MIN (dy, (DY-Iy)/expand + Sy), 0); 89 70 } 90 71 … … 93 74 94 75 out_pix = (unsigned char *) image[0].picture.data; 95 imdata = (float *) matrix[0].buffer; 96 in_pix = &imdata[(int)(DX*(int)MAX(Y,0) + (int)MAX(X,0))]; 76 in_pix = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 97 77 98 78 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 117 97 if (expand_out == 1) { 118 98 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 119 pixelN = PixelLookup(*in_pix2); 120 *out_pix = pixel[pixelN]; 99 *out_pix = pixel[*in_pix2]; 121 100 } 122 101 } else { 123 102 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 124 pixelN = PixelLookup(*in_pix2); 125 pixvalue = pixel[pixelN]; 103 pixvalue = pixel[*in_pix2]; 126 104 out_pix2 = out_pix; 127 105 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { -
trunk/Ohana/src/kapa2/src/Reorient.c
r16011 r16228 3 3 void Reorient (Graphic *graphic, KapaImageWidget *image, double X, double Y, int mode) { 4 4 5 if (image[0].expand == 0) image[0].expand = 1;5 Picture *picture; 6 6 7 if ((image[0].X == X) && (image[0].Y == Y) && (mode == 0)) { 7 picture = &image[0].picture; 8 9 if (picture[0].expand == 0) picture[0].expand = 1; 10 11 if ((picture[0].X == X) && (picture[0].Y == Y) && (mode == 0)) { 8 12 Refresh (); 9 13 XFlush (graphic[0].display); … … 13 17 switch (mode) { 14 18 case 0: 15 if (( image[0].X != X) || (image[0].Y != Y)) {16 image[0].X = X;17 image[0].Y = Y;19 if ((picture[0].X != X) || (picture[0].Y != Y)) { 20 picture[0].X = X; 21 picture[0].Y = Y; 18 22 } 19 23 break; 20 24 case -1: 21 image[0].expand--; 22 if ((image[0].expand == 0) || (image[0].expand == -1)) 23 image[0].expand = -2; 24 if (image[0].expand < -30) { 25 fprintf (stderr, "can't get smaller!\n"); 26 image[0].expand = -30; 27 return; 28 } 29 image[0].X = X; 30 image[0].Y = Y; 25 picture[0].expand--; 26 if ((picture[0].expand == 0) || (picture[0].expand == -1)) picture[0].expand = -2; 27 picture[0].X = X; 28 picture[0].Y = Y; 31 29 break; 32 30 case +1: 33 image[0].expand++; 34 if ((image[0].expand == 0) || (image[0].expand == -1)) 35 image[0].expand = 1; 36 if (image[0].expand > 30) { 37 fprintf (stderr, "can't get bigger!\n"); 38 image[0].expand = 30; 39 return; 40 } 41 image[0].X = X; 42 image[0].Y = Y; 31 picture[0].expand++; 32 if ((picture[0].expand == 0) || (picture[0].expand == -1)) picture[0].expand = 1; 33 picture[0].X = X; 34 picture[0].Y = Y; 43 35 break; 44 36 } … … 49 41 XFlush (graphic[0].display); 50 42 } 51 52 # if (0) /* the "warp" function seems to be a problem on SUNs for some reason */53 XQueryPointer (graphic[0].display, graphic[0].window, &dummy1, &dummy1, &dummy2, &dummy2, &x, &y, &dummy3);54 if ((x > image[0].picture.x) && (x < image[0].picture.x + image[0].picture.dx) &&55 (y > image[0].picture.y) && (y < image[0].picture.y + image[0].picture.dy) &&56 ((mouse_event[0].button == 2) || (mouse_event[0].button == 3))) {57 XWarpPointer (graphic[0].display, None, graphic[0].window, 0, 0, 0, 0,58 image[0].picture.x + 0.5*image[0].picture.dx,59 image[0].picture.y + 0.5*image[0].picture.dy);60 }61 # endif62 -
trunk/Ohana/src/kapa2/src/SetImageData.c
r16011 r16228 125 125 image = section->image; 126 126 127 Screen_to_Image (&Xmin, &Ymin, 0.0, 0.0, image);128 Screen_to_Image (&Xmax, &Ymax, image[0].picture.dx, image[0].picture.dy, image);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); 129 129 130 130 KiiSendMessage (sock, "%g %g %g %g", Xmin, Xmax, Ymin, Ymax); -
trunk/Ohana/src/kapa2/src/UpdatePointer.c
r16011 r16228 1 1 # include "Ximage.h" 2 # define FRAC(a) ((a) - (int)(a))3 2 4 3 int UpdatePointer (Graphic *graphic, XMotionEvent *event) { … … 20 19 21 20 data = (float *) image[0].image[0].matrix.buffer; 22 Screen_to_Image (&x, &y, (double)event[0].x, (double)event[0].y, image);21 Screen_to_Image (&x, &y, (double)event[0].x, (double)event[0].y, &image[0].picture); 23 22 24 23 z = -1; … … 30 29 31 30 skip: 32 image[0].x = x; 33 image[0].y = y; 34 image[0].z = z; 31 image[0].zoom.X = x; 32 image[0].zoom.Y = Y; 35 33 36 34 UpdateStatusBox (graphic, image, x, y, z, 0); -
trunk/Ohana/src/kapa2/src/bDrawOverlay.c
r15620 r16228 24 24 } 25 25 26 Image_to_Screen (&X0, &Y0, 0.0, 0.0, image);26 Image_to_Screen (&X0, &Y0, 0.0, 0.0, &image[0].picture); 27 27 X0 -= image[0].picture.x; 28 28 Y0 -= image[0].picture.y;
Note:
See TracChangeset
for help on using the changeset viewer.
