Changeset 16009
- Timestamp:
- Jan 4, 2008, 4:00:13 PM (18 years ago)
- Location:
- branches/eam_branch_20071222/Ohana/src
- Files:
-
- 1 added
- 13 edited
-
kapa2/include/constants.h (modified) (1 diff)
-
kapa2/include/prototypes.h (modified) (1 diff)
-
kapa2/src/CheckPipe.c (modified) (1 diff)
-
kapa2/src/CreateZoom32.c (modified) (11 diffs)
-
kapa2/src/JPEGit24.c (modified) (4 diffs)
-
kapa2/src/PSPixmap.c (modified) (1 diff)
-
kapa2/src/Remap32.c (modified) (4 diffs)
-
kapa2/src/SetChannel.c (modified) (1 diff)
-
kapa2/src/SetColorScale.c (modified) (2 diffs)
-
libkapa/include/kapa.h (modified) (1 diff)
-
libkapa/src/KiiPicture.c (modified) (1 diff)
-
opihi/cmd.data/Makefile (modified) (1 diff)
-
opihi/cmd.data/init.c (modified) (2 diffs)
-
opihi/cmd.data/tvcolors.c (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071222/Ohana/src/kapa2/include/constants.h
r15996 r16009 14 14 15 15 // XXX for the moment, this is set to match the values in SetColorScale3D_CC 16 # define NPIXELS_STATIC 300016 # define NPIXELS_STATIC 4600 17 17 18 18 # define PAD1 3 -
branches/eam_branch_20071222/Ohana/src/kapa2/include/prototypes.h
r15996 r16009 71 71 int GetImageCoords PROTO((int sock)); 72 72 int GetImageRange PROTO((int sock)); 73 int SetChannel (int sock); 74 int SetColormapFromPipe (int sock); 73 75 74 76 int LoadVectorData PROTO((int sock, KapaGraphWidget *graph, int N, char *type)); -
branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckPipe.c
r15925 r16009 274 274 } 275 275 276 if (!strcmp (word, "CMAP")) { 277 status = SetColormapFromPipe (sock); 278 KiiSendCommand (sock, 4, "DONE"); 279 FINISHED (status); 280 } 281 276 282 if (!strcmp (word, "SAVE")) { 277 283 status = SaveOverlay (sock); -
branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom32.c
r15925 r16009 1 1 # include "Ximage.h" 2 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 3 15 4 void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y) { … … 22 11 int expand_in, expand_out; 23 12 unsigned int *out_pix, *out_pix2; 24 float *imdata,*in_pix, *in_pix2;25 unsigned long pixel[256], pixvalue;13 unsigned short *in_pix, *in_pix2; 14 unsigned long *pixel, pixvalue; 26 15 unsigned long back; 27 16 … … 33 22 } 34 23 35 for (i = 0; i < 256; i++) { /* set up pixel array */ 24 ALLOCATE (pixel, unsigned long, graphic[0].Npixels); 25 26 // local array for pixel values 27 for (i = 0; i < graphic[0].Npixels; i++) { 36 28 pixel[i] = graphic[0].cmap[i].pixel; 37 29 } 38 30 back = graphic[0].back; 39 40 // define the color transform parameters41 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 }49 31 50 32 zoomscale = MAX (5, image[0].expand + 5); … … 57 39 DX = image[0].image[0].matrix.Naxis[0]; 58 40 DY = image[0].image[0].matrix.Naxis[1]; 41 42 /* Rx,Ry are the screen coordinates of the first image pixel */ 59 43 Rx = x - expand*(int)(0.5*(dx + 1)) + 1; 60 44 Ry = y - expand*(int)(0.5*(dy + 1)) + 1; … … 64 48 i_end = MAX (MIN ((DX-Rx) / expand, dx - expand_out + 1), 0); 65 49 j_end = MAX (MIN ((DY-Ry) / expand, dy - expand_out + 1), 0); 50 66 51 dropback = expand_out - (i_end - i_start) % expand_out; 67 52 if ((i_end - i_start) % expand_out == 0) dropback = 0; 68 53 69 54 out_pix = (unsigned int *) image[0].zoom.data; 70 imdata = (float *) image[0].image[0].matrix.buffer; 71 in_pix = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 55 in_pix = &image[0].pixmap[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)]; 72 56 73 57 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 78 62 return; 79 63 } 80 64 81 65 82 66 /**** fill in bottom area ****/ 83 67 for (j = 0; j < dx*j_start; j++, out_pix++) { 84 out_pix[0]= back;68 *out_pix = back; 85 69 } 86 70 … … 88 72 89 73 /**** fill in area to the left of the picture ****/ 90 for (jj = 0; jj < expand_out; jj++) {74 for (jj = 0; (i_start > 0) && (jj < expand_out); jj++) { 91 75 out_pix2 = out_pix + jj*dx; 92 76 for (i = 0; i < i_start; i++, out_pix2++) { 93 out_pix[0]= back;77 *out_pix2 = back; 94 78 } 95 79 } … … 100 84 if (expand_out == 1) { 101 85 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 102 pixelN = PixelLookup(*in_pix2); 103 out_pix[0] = pixel[pixelN]; 86 *out_pix = pixel[*in_pix2]; 104 87 } 105 } 106 else { 88 } else { 107 89 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 108 pixelN = PixelLookup(*in_pix2); 109 pixvalue = pixel[pixelN]; 90 pixvalue = pixel[*in_pix2]; 110 91 out_pix2 = out_pix; 111 92 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { 112 93 for (ii = 0; ii < expand_out; ii++, out_pix2++) { 113 out_pix2[0]= pixvalue;94 *out_pix2 = pixvalue; 114 95 } 115 96 } … … 117 98 } 118 99 out_pix -= dropback; 119 120 100 121 101 /**** fill in area to the right of the picture ****/ … … 123 103 out_pix2 = out_pix + jj*dx; 124 104 for (i = i_end; i < dx; i++, out_pix2++) { 125 out_pix2[0]= back;105 *out_pix2 = back; 126 106 } 127 107 } … … 134 114 /**** fill in top area ****/ 135 115 for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)image[0].zoom.data < dx*dy); j++, out_pix++) { 136 out_pix[0]= back;116 *out_pix = back; 137 117 } 138 118 139 out_pix = (unsigned int *)image[0].zoom.data;140 119 image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 141 120 image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 32, 0); 142 121 122 free (pixel); 143 123 } -
branches/eam_branch_20071222/Ohana/src/kapa2/src/JPEGit24.c
r15925 r16009 37 37 double expand, Rx, Ry, X, Y; 38 38 unsigned char *out_pix; 39 float *imdata,*in_pix, *in_pix_ref;40 unsigned char pixel1[256], pixel2[256], pixel3[256];39 unsigned short *in_pix, *in_pix_ref; 40 unsigned char *pixel1, *pixel2, *pixel3; 41 41 char filename[1024]; 42 42 FILE *f; … … 75 75 jpeg_start_compress (&cinfo, TRUE); 76 76 77 ALLOCATE (pixel1, unsigned char, graphic[0].Npixels); 78 ALLOCATE (pixel2, unsigned char, graphic[0].Npixels); 79 ALLOCATE (pixel3, unsigned char, graphic[0].Npixels); 80 77 81 /** cmap[i].pixel must be defined even if X is not used **/ 78 for (i = 0; i < 256; i++) { /* set up pixel array */82 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 79 83 pixel1[i] = graphic[0].cmap[i].red >> 8; 80 84 pixel2[i] = graphic[0].cmap[i].green >> 8; 81 85 pixel3[i] = graphic[0].cmap[i].blue >> 8; 82 }83 84 // define the color transform parameters85 MaxValue = graphic[0].Npixels - 1;86 if (image[0].image[0].range != 0.0) {87 slope = graphic[0].Npixels / image[0].image[0].range;88 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;89 } else {90 slope = 1.0;91 start = image[0].image[0].zero;92 86 } 93 87 … … 145 139 ALLOCATE (line_buffer, JSAMPLE, 3*dx); 146 140 147 imdata = (float *) image[0].image[0].matrix.buffer; 148 in_pix_ref = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 141 in_pix_ref = &image[0].pixmap[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 149 142 150 143 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 177 170 /*** fill in the picture region ***/ 178 171 for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) { 179 pixelN = PixelLookup(*in_pix);180 172 for (ii = 0; ii < expand_out; ii++, out_pix+=3) { 181 out_pix[0] = pixel1[ pixelN];182 out_pix[1] = pixel2[ pixelN];183 out_pix[2] = pixel3[ pixelN];173 out_pix[0] = pixel1[*in_pix]; 174 out_pix[1] = pixel2[*in_pix]; 175 out_pix[2] = pixel3[*in_pix]; 184 176 } 185 177 } -
branches/eam_branch_20071222/Ohana/src/kapa2/src/PSPixmap.c
r15925 r16009 143 143 return; 144 144 } 145 146 # if (0) 147 // XXX needs work! 148 void PSPixmap32_RGB (Graphic *graphic, KapaImageWidget *image, FILE *f) { 149 150 int i, k, m, val; 151 double Nchar, Npix, start, slope, frac; 152 unsigned int *buff; 153 unsigned long back; 154 unsigned char 155 156 ALLOCATE (pixelR, unsigned char, graphic[0].Npixels); 157 ALLOCATE (pixelG, unsigned char, graphic[0].Npixels); 158 ALLOCATE (pixelB, unsigned char, graphic[0].Npixels); 159 160 /** cmap[i].pixel must be defined even if X is not used **/ 161 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 162 pixelR[i] = graphic[0].cmap[i].red >> 8; 163 pixelG[i] = graphic[0].cmap[i].green >> 8; 164 pixelB[i] = graphic[0].cmap[i].blue >> 8; 165 } 166 167 for (i = 0; i < image[0].picture.dy; i++) { 168 for (k = 0; k < image[0].picture.dx; k++, buff++) { 169 if (*buff == back) 170 val = Nchar; 171 else { 172 for (m = 0; (graphic[0].cmap[m].pixel != *buff) && (m < Npix); m++); 173 val = Nchar - frac * MIN (MAX (start + m * slope, 0), Npix); 174 } 175 fprintf (f, "%02x", val); 176 if (!((k+1) % 40)) fprintf (f, "\n"); 177 } 178 fprintf (f, "\n"); 179 buff -= 2*image[0].picture.dx; 180 } 181 return; 182 } 183 # endif -
branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c
r15935 r16009 42 42 DX = matrix[0].Naxis[0]; 43 43 DY = matrix[0].Naxis[1]; 44 44 45 /* X,Y are the image coordinates of the first image pixel */ 45 46 X = MAX(0.5*(DX - dx*expand) - image[0].X, 0); … … 78 79 79 80 /**** fill in bottom area ****/ 80 for (j = 0; j < dx*j_start; j++, out_pix++) 81 for (j = 0; j < dx*j_start; j++, out_pix++) { 81 82 *out_pix = back; 83 } 82 84 83 85 for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) { … … 128 130 *out_pix = back; 129 131 } 132 130 133 image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0, 131 134 image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 32, 0); … … 133 136 free (pixel); 134 137 } 135 -
branches/eam_branch_20071222/Ohana/src/kapa2/src/SetChannel.c
r15935 r16009 34 34 return (TRUE); 35 35 } 36 37 int SetColormapFromPipe (int sock) { 38 39 Graphic *graphic; 40 Section *section; 41 KapaImageWidget *image; 42 char colormap[256]; 43 int status; 44 45 graphic = GetGraphic (); 46 section = GetActiveSection(); 47 if (section->image == NULL) { 48 section->image = InitImageWidget (); 49 SetSectionSizes (section); 50 } 51 image = section->image; 52 53 KiiScanMessage (sock, "%s", colormap); 54 55 status = SetColormap (colormap); 56 if (!status) fprintf (stderr, "unknown colormap %s\n", colormap); 57 58 SetColorScale (graphic, image); 59 Remap (graphic, image); 60 Refresh (); 61 XFlush (graphic[0].display); 62 63 return (TRUE); 64 } -
branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColorScale.c
r15996 r16009 170 170 CCSplitNodeIterate (cube, 0, 2); 171 171 172 // need to allocate at least 1184 pixels 173 // 64, 288, 512, 736, 960, 1184 174 for (i = 0; i < 8; i++) { 172 // need to allocate at least 64 + NPASS*7*NSPLIT pixels (overestimate if 64 < NSPLIT) 173 # define NPASS 5 174 # define NSPLIT 128 175 176 for (i = 0; i < NPASS; i++) { 175 177 // generate histogram 176 178 ColorHistogram (image, cube); … … 186 188 187 189 // split nodes with more than value[n] 188 Nmin = MAX (0, Nvalues - 50);190 Nmin = MAX (0, Nvalues - NSPLIT); 189 191 CCNodeDivideLimit (cube, values[Nmin]); 190 192 free (values); -
branches/eam_branch_20071222/Ohana/src/libkapa/include/kapa.h
r15926 r16009 125 125 /* KiiPicture.c */ 126 126 int KiiSetChannel (int fd, int channel); 127 int KiiSetColormap (int fd, char *colormap); 127 128 int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords); 128 129 int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords); -
branches/eam_branch_20071222/Ohana/src/libkapa/src/KiiPicture.c
r15926 r16009 5 5 KiiSendCommand (fd, 4, "CHAN"); /* tell kapa to look for the incoming image */ 6 6 KiiSendMessage (fd, "%1d", channel); 7 8 KiiWaitAnswer (fd, "DONE"); 9 return (TRUE); 10 } 11 12 int KiiSetColormap (int fd, char *colormap) { 13 14 KiiSendCommand (fd, 4, "CMAP"); /* tell kapa to look for the incoming image */ 15 KiiSendMessage (fd, "%s", colormap); 7 16 8 17 KiiWaitAnswer (fd, "DONE"); -
branches/eam_branch_20071222/Ohana/src/opihi/cmd.data/Makefile
r15927 r16009 114 114 $(SRC)/tv.$(ARCH).o \ 115 115 $(SRC)/tvchannel.$(ARCH).o \ 116 $(SRC)/tvcolors.$(ARCH).o \ 116 117 $(SRC)/tvcontour.$(ARCH).o \ 117 118 $(SRC)/tvgrid.$(ARCH).o \ -
branches/eam_branch_20071222/Ohana/src/opihi/cmd.data/init.c
r15927 r16009 97 97 int tv PROTO((int, char **)); 98 98 int tvchannel PROTO((int, char **)); 99 int tvcolors PROTO((int, char **)); 99 100 int tvcontour PROTO((int, char **)); 100 101 int tvgrid PROTO((int, char **)); … … 216 217 {"tv", tv, "display an image on the Kii window"}, 217 218 {"tvchannel", tvchannel, "set the current tv channel"}, 219 {"tvcolors", tvcolors, "set the tv colormap"}, 218 220 {"tvcontour", tvcontour, "send contour to overlay"}, 219 221 {"tvgrid", tvgrid, "wait until return is typed"},
Note:
See TracChangeset
for help on using the changeset viewer.
