Changeset 16270
- Timestamp:
- Feb 1, 2008, 10:23:33 AM (18 years ago)
- Location:
- trunk/Ohana/src/kapa2
- Files:
-
- 1 added
- 10 edited
-
Makefile (modified) (1 diff)
-
include/prototypes.h (modified) (1 diff)
-
include/structures.h (modified) (1 diff)
-
src/ButtonFunctions.c (modified) (4 diffs)
-
src/CreatePicture.c (modified) (4 diffs)
-
src/CreateWide.c (added)
-
src/CursorOps.c (modified) (6 diffs)
-
src/Image.c (modified) (4 diffs)
-
src/LoadPicture.c (modified) (3 diffs)
-
src/Remap32.c (modified) (8 diffs)
-
src/SetImageSize.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/Makefile
r16256 r16270 77 77 $(SRC)/PSOverlay.$(ARCH).o $(SRC)/SetChannel.$(ARCH).o \ 78 78 $(SRC)/SetColorScale.$(ARCH).o $(SRC)/ColorCube.$(ARCH).o \ 79 $(SRC)/ColorHistogram.$(ARCH).o 79 $(SRC)/ColorHistogram.$(ARCH).o $(SRC)/CreateWide.$(ARCH).o 80 80 81 81 #$(SRC)/CreateZoom8.$(ARCH).o $(SRC)/CreateZoom16.$(ARCH).o \ -
trunk/Ohana/src/kapa2/include/prototypes.h
r16256 r16270 219 219 void CreateColorbar (KapaImageWidget *image, Graphic *graphic); 220 220 void CreateZoom (Graphic *graphic, KapaImageWidget *image); 221 void CreateWide (Graphic *graphic, KapaImageWidget *image); 221 222 void UpdateStatusBox (Graphic *graphic, KapaImageWidget *image, double x, double y, double z, int mode); 222 223 -
trunk/Ohana/src/kapa2/include/structures.h
r16256 r16270 95 95 int expand; // zoomscale 96 96 double X, Y; // center of image in picture 97 char flipx, flipy; // parity (0 = +; 1 = -) 97 98 XImage *pix; 98 99 char *data; -
trunk/Ohana/src/kapa2/src/ButtonFunctions.c
r16256 r16270 15 15 Remap (graphic, image); 16 16 CreateZoom (graphic, image); 17 CreateWide (graphic, image); 17 18 Refresh (); 18 19 XFlush (graphic[0].display); … … 26 27 Remap (graphic, image); 27 28 CreateZoom (graphic, image); 29 CreateWide (graphic, image); 28 30 Refresh (); 29 31 XFlush (graphic[0].display); … … 37 39 Remap (graphic, image); 38 40 CreateZoom (graphic, image); 41 CreateWide (graphic, image); 39 42 Refresh (); 40 43 XFlush (graphic[0].display); … … 79 82 int ToggleDEG (Graphic *graphic, KapaImageWidget *image) { 80 83 84 image[0].picture.flipy = !image[0].picture.flipy; 85 image[0].zoom.flipy = !image[0].zoom.flipy; 86 image[0].wide.flipy = !image[0].wide.flipy; 81 87 image[0].DecimalDegrees = image[0].DecimalDegrees ^ TRUE; 82 88 StatusBox (graphic, image); -
trunk/Ohana/src/kapa2/src/CreatePicture.c
r16256 r16270 12 12 switch (graphic[0].Nbits) { 13 13 case 8: 14 REALLOCATE (image[0].wide.data, char, image[0].wide.dx*image[0].wide.dy); 15 REALLOCATE (image[0].zoom.data, char, image[0].zoom.dx*image[0].zoom.dy); 14 16 REALLOCATE (image[0].picture.data, char, image[0].picture.dx*image[0].picture.dy); 15 17 c = (unsigned char *) image[0].picture.data; … … 21 23 22 24 case 16: 25 REALLOCATE (image[0].wide.data, char, 2*image[0].wide.dx*image[0].wide.dy); 26 REALLOCATE (image[0].zoom.data, char, 2*image[0].zoom.dx*image[0].zoom.dy); 23 27 REALLOCATE (image[0].picture.data, char, 2*image[0].picture.dy*image[0].picture.dx); 24 28 c = (unsigned char *) image[0].picture.data; … … 37 41 case 24: 38 42 extra = 4 - (image[0].picture.dx * 3) % 4; 43 REALLOCATE (image[0].wide.data, char, image[0].wide.dy*(3*image[0].wide.dx+extra)); 44 REALLOCATE (image[0].zoom.data, char, image[0].zoom.dy*(3*image[0].zoom.dx+extra)); 39 45 REALLOCATE (image[0].picture.data, char, image[0].picture.dy*(3*image[0].picture.dx+extra)); 40 46 c = (unsigned char *) image[0].picture.data; … … 55 61 56 62 case 32: 63 REALLOCATE (image[0].wide.data, char, 4*image[0].wide.dx*image[0].wide.dy); 57 64 REALLOCATE (image[0].zoom.data, char, 4*image[0].zoom.dx*image[0].zoom.dy); 58 65 REALLOCATE (image[0].picture.data, char, 4*image[0].picture.dx*image[0].picture.dy); -
trunk/Ohana/src/kapa2/src/CursorOps.c
r16256 r16270 4 4 void Picture_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) { 5 5 6 double expand ;6 double expand, dx, dy; 7 7 8 8 expand = 1.0; … … 13 13 } 14 14 15 // pixel coordinates in picture frame 16 dx = expand*(x2 - 0.5*picture[0].dx); 17 dy = expand*(y2 - 0.5*picture[0].dy); 18 15 19 // 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;20 *x1 = picture[0].flipx ? picture[0].X - dx : picture[0].X + dx; 21 *y1 = picture[0].flipy ? picture[0].Y - dy : picture[0].Y + dy; 18 22 } 19 23 … … 32 36 void Image_to_Picture (double *x1, double *y1, double x2, double y2, Picture *picture) { 33 37 34 double expand ;38 double expand, dx, dy; 35 39 36 40 /* notice that here, expand is the reciprocal of the expand above */ … … 43 47 44 48 // pixel coordinates in picture frame 45 *x1 = expand*(x2 - picture[0].X) + 0.5*picture[0].dx; 46 *y1 = expand*(y2 - picture[0].Y) + 0.5*picture[0].dy; 49 dx = picture[0].flipx ? picture[0].X - x2 : x2 - picture[0].X; 50 dy = picture[0].flipy ? picture[0].Y - y2 : y2 - picture[0].Y; 51 52 *x1 = expand*dx + 0.5*picture[0].dx; 53 *y1 = expand*dy + 0.5*picture[0].dy; 47 54 } 48 55 … … 70 77 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]); 71 78 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; 79 // round up (down) to nearest pixel boundary 80 if (Ix > (int)(Ix)) { 81 Ix = picture[0].flipx ? (int)(Ix) : (int)(Ix) + 1; 82 } 83 if (Iy > (int)(Iy)) { 84 Iy = picture[0].flipy ? (int)(Iy) : (int)(Iy) + 1; 85 } 75 86 76 87 // Sx, Sy are the screen coordinates of the Ix,Iy pixel … … 94 105 Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]); 95 106 96 // round down to nearest pixel boundary 97 if (Ix > (int)(Ix)) Ix = (int)(Ix); 98 if (Iy > (int)(Iy)) Iy = (int)(Iy); 107 // round down (up) to nearest pixel boundary 108 if (Ix > (int)(Ix)) { 109 Ix = picture[0].flipx ? (int)(Ix) + 1 : (int)(Ix); 110 } 111 if (Iy > (int)(Iy)) { 112 Iy = picture[0].flipy ? (int)(Iy) + 1: (int)(Iy); 113 } 99 114 100 115 // Sx, Sy are the screen coordinates of the Ix,Iy pixel -
trunk/Ohana/src/kapa2/src/Image.c
r16256 r16270 51 51 image[0].picture.Y = 0.0; 52 52 image[0].picture.expand = 1; 53 image[0].picture.flipx = FALSE; 54 image[0].picture.flipy = FALSE; 53 55 54 56 image[0].zoom.X = 0.0; 55 57 image[0].zoom.Y = 0.0; 56 58 image[0].zoom.expand = +5; 59 image[0].zoom.flipx = FALSE; 60 image[0].zoom.flipy = FALSE; 57 61 58 62 image[0].wide.X = 0.0; 59 63 image[0].wide.Y = 0.0; 60 64 image[0].wide.expand = -5; 65 image[0].wide.flipx = FALSE; 66 image[0].wide.flipy = FALSE; 61 67 62 68 image[0].location = 4; … … 67 73 ALLOCATE (image[0].cmapbar.data, char, 1); /* allocate so later free will not crash! */ 68 74 ALLOCATE (image[0].zoom.data, char, 1); /* allocate so later free will not crash! */ 75 ALLOCATE (image[0].wide.data, char, 1); /* allocate so later free will not crash! */ 69 76 70 77 InitButtonSize (&image[0].PS_button, PS_width, PS_height, PS_bits); … … 147 154 image[0].cmapbar.x, image[0].cmapbar.y, 148 155 image[0].cmapbar.dx, image[0].cmapbar.dy); 156 157 XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, 158 image[0].wide.pix, 0, 0, 159 image[0].wide.x, image[0].wide.y, 160 image[0].wide.dx, image[0].wide.dy); 149 161 150 162 CrossHairs (graphic, &image[0].zoom); … … 188 200 free (image[0].cmapbar.data); 189 201 free (image[0].zoom.data); 202 free (image[0].wide.data); 190 203 191 204 free (image); -
trunk/Ohana/src/kapa2/src/LoadPicture.c
r16256 r16270 9 9 KapaImageWidget *image; 10 10 Graphic *graphic; 11 double Xoffset, Yoffset ;11 double Xoffset, Yoffset, wx; 12 12 13 13 graphic = GetGraphic (); … … 46 46 image[0].picture.Y = 0.5*header.Naxis[1] + Yoffset; 47 47 48 // choose expand for wide to guarantee we fit: 49 wx = MAX ((header.Naxis[0] / (float) image[0].wide.dx), (header.Naxis[1] / (float) image[0].wide.dy)); 50 if (wx > 1.0) { 51 image[0].wide.expand = -wx; 52 } else { 53 image[0].wide.expand = 1.0 / wx; 54 } 55 image[0].wide.X = 0.5*header.Naxis[0]; 56 image[0].wide.Y = 0.5*header.Naxis[1]; 57 48 58 fcntl (sock, F_SETFL, O_NONBLOCK); 49 59 … … 78 88 SetColorScale (graphic, image); 79 89 Remap (graphic, image); 90 CreateWide (graphic, image); 80 91 if (DEBUG) fprintf (stderr, "remapped image\n"); 81 92 Refresh (); -
trunk/Ohana/src/kapa2/src/Remap32.c
r16256 r16270 1 1 # include "Ximage.h" 2 3 # ifndef ISWAP 4 # define ISWAP(X,Y) {int tmp=(X); (X) = (Y); (Y) = tmp;} 5 # endif 2 6 3 7 void Remap32 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) { … … 5 9 int i, j, ii, jj; 6 10 int i_start, i_end, j_start, j_end; 7 int dropback ;11 int dropback, inDX, inDY; 8 12 int dx, dy, DX, DY; 9 13 double expand, Ix, Iy; … … 48 52 Picture_Upper (&i_end, &j_end, matrix, picture); 49 53 54 if (i_end < i_start) ISWAP (i_start, i_end); 55 if (j_end < j_start) ISWAP (j_start, j_end); 56 50 57 // Ix,Iy are the first displayed image pixel 51 58 Picture_to_Image (&Ix, &Iy, i_start, j_start, picture); 59 Ix = MIN (MAX (0, Ix), DX - 1); 60 Iy = MIN (MAX (0, Iy), DY - 1); 61 // XXX not completely consistent with the i_start, i_end range... 62 63 // we need to offset because i_start points to the bottom edge of Ix 64 // if (picture[0].flipx) Ix -= 1.0; 65 // if (picture[0].flipy) Iy -= 1.0; 66 67 inDX = picture[0].flipx ? -1 : +1; 68 inDY = picture[0].flipy ? -1 : +1; 52 69 53 70 dropback = expand_out - (i_end - i_start) % expand_out; … … 64 81 } 65 82 66 for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) {83 for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += inDY*expand_in*DX) { 67 84 68 85 /**** fill in area to the left of the picture ****/ … … 78 95 in_pix2 = in_pix; 79 96 if (expand_out == 1) { 80 for (i = i_start; i < i_end; i++, in_pix2 +=expand_in, out_pix++) {97 for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) { 81 98 *out_pix = pixel[*in_pix2]; 82 99 } 83 100 } else { 84 for (i = i_start; i < i_end; i+= expand_out, in_pix2 ++, out_pix+= expand_out) {101 for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) { 85 102 pixvalue = pixel[*in_pix2]; 86 103 out_pix2 = out_pix; … … 94 111 out_pix -= dropback; 95 112 113 // assert (in_pix2 - image[0].pixmap <= DX*DY); 114 // assert (in_pix2 - image[0].pixmap >= 0); 115 // assert (in_pix - image[0].pixmap <= DX*DY); 116 // assert (in_pix - image[0].pixmap >= 0); 117 96 118 /**** fill in area to the right of the picture ****/ 97 119 for (jj = 0; jj < expand_out; jj++) { … … 102 124 } 103 125 out_pix += (dx - i_end); 126 // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy); 127 // assert (out_pix - (unsigned int *)picture[0].data >= 0); 104 128 } 105 129 … … 107 131 out_pix -= expand_out - (j_end - j_start) % expand_out; 108 132 133 // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy); 134 // assert (out_pix - (unsigned int *)picture[0].data >= 0); 135 109 136 /**** fill in top area ****/ 110 137 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)picture[0].data < dx*dy); j++, out_pix++) { -
trunk/Ohana/src/kapa2/src/SetImageSize.c
r16256 r16270 109 109 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 110 110 image[0].recenter_button.y = image[0].PS_button.y; 111 112 // XXX zoom should scale somewhat with the image? (with a min and a max) 113 // XXX actually, it is limited by the buttons and status region 114 image[0].wide.dx = ZOOM_X; 115 image[0].wide.dy = ZOOM_Y; 116 image[0].wide.x = image[0].recenter_button.x + image[0].recenter_button.dx + PAD1; 117 image[0].wide.y = image[0].PS_button.y; 111 118 break; 112 119 … … 177 184 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 178 185 image[0].recenter_button.y = image[0].PS_button.y; 186 187 // XXX zoom should scale somewhat with the image? (with a min and a max) 188 // XXX actually, it is limited by the buttons and status region 189 image[0].wide.dx = ZOOM_X; 190 image[0].wide.dy = ZOOM_Y; 191 image[0].wide.x = image[0].PS_button.x; 192 image[0].wide.y = image[0].PS_button.y + BUTTON_HEIGHT + PAD1; 179 193 break; 180 194 … … 243 257 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 244 258 image[0].recenter_button.y = image[0].PS_button.y; 259 260 // XXX zoom should scale somewhat with the image? (with a min and a max) 261 // XXX actually, it is limited by the buttons and status region 262 image[0].wide.dx = ZOOM_X; 263 image[0].wide.dy = ZOOM_Y; 264 image[0].wide.x = image[0].recenter_button.x + image[0].recenter_button.dx + PAD1; 265 image[0].wide.y = image[0].PS_button.y; 245 266 break; 246 267 … … 309 330 image[0].recenter_button.x = image[0].heat_button.x + image[0].heat_button.dx + PAD1; 310 331 image[0].recenter_button.y = image[0].PS_button.y; 332 333 // XXX zoom should scale somewhat with the image? (with a min and a max) 334 // XXX actually, it is limited by the buttons and status region 335 image[0].wide.dx = ZOOM_X; 336 image[0].wide.dy = ZOOM_Y; 337 image[0].wide.x = image[0].PS_button.x; 338 image[0].wide.y = image[0].PS_button.y + BUTTON_HEIGHT + PAD1; 311 339 break; 312 340 … … 320 348 CreateColorbar (image, graphic); 321 349 CreateZoom (graphic, image); 350 CreateWide (graphic, image); 322 351 } 323 352 Remap (graphic, image);
Note:
See TracChangeset
for help on using the changeset viewer.
