Changeset 15935
- Timestamp:
- Dec 27, 2007, 6:43:57 AM (18 years ago)
- Location:
- branches/eam_branch_20071222/Ohana/src/kapa2
- Files:
-
- 1 added
- 11 edited
-
Makefile (modified) (1 diff)
-
include/constants.h (modified) (1 diff)
-
include/prototypes.h (modified) (1 diff)
-
include/structures.h (modified) (2 diffs)
-
src/ButtonFunctions.c (modified) (3 diffs)
-
src/Image.c (modified) (2 diffs)
-
src/LoadPicture.c (modified) (1 diff)
-
src/Remap32.c (modified) (6 diffs)
-
src/Reorient.c (modified) (1 diff)
-
src/SetChannel.c (modified) (1 diff)
-
src/SetColorScale.c (added)
-
src/SetColormap.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071222/Ohana/src/kapa2/Makefile
r15925 r15935 77 77 $(SRC)/bDrawOverlay.$(ARCH).o $(SRC)/ButtonFunctions.$(ARCH).o \ 78 78 $(SRC)/PSimage.$(ARCH).o $(SRC)/PSPixmap.$(ARCH).o \ 79 $(SRC)/PSOverlay.$(ARCH).o $(SRC)/SetChannel.$(ARCH).o 79 $(SRC)/PSOverlay.$(ARCH).o $(SRC)/SetChannel.$(ARCH).o \ 80 $(SRC)/SetColorScale.$(ARCH).o 80 81 81 82 OBJ = $(KAPA) -
branches/eam_branch_20071222/Ohana/src/kapa2/include/constants.h
r15925 r15935 31 31 # define LABEL_MAXLEN 128 32 32 33 typedef enum { 34 KAPA_SCALE_1D, 35 KAPA_SCALE_3D 36 } KapaColorScaleMode; 37 33 38 /* label names */ 34 # define LABELX0 0 35 # define LABELY0 1 36 # define LABELX1 2 37 # define LABELY1 3 38 # define LABELUL 4 39 # define LABELUR 5 40 # define LABELLL 6 41 # define LABELLR 7 39 typedef enum { 40 LABELX0, 41 LABELY0, 42 LABELX1, 43 LABELY1, 44 LABELUL, 45 LABELUR, 46 LABELLL, 47 LABELLR 48 } KapaLabelMode; 42 49 43 50 /* EVENT_MASK consists of: -
branches/eam_branch_20071222/Ohana/src/kapa2/include/prototypes.h
r15925 r15935 140 140 141 141 int Center PROTO(()); 142 void SetColorScale PROTO((Graphic *graphic, KapaImageWidget *image)); 143 void SetColorScale1D PROTO((Graphic *graphic, KapaImageWidget *image)); 144 void SetColorScale3D PROTO((Graphic *graphic, KapaImageWidget *image)); 142 145 void Remap PROTO((Graphic *graphic, KapaImageWidget *image)); 143 146 void Remap8 PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix)); -
branches/eam_branch_20071222/Ohana/src/kapa2/include/structures.h
r15925 r15935 17 17 Colormap colormap; 18 18 unsigned long *color; // graph plotting colors 19 int Ncolors;19 int Ncolors; 20 20 21 unsigned long *pixels; // image pixel colors21 unsigned long *pixels; // image pixel colors 22 22 int Npixels; // number of pixels 23 24 int ColorScaleMode; // single colormap for all images?? 25 int nRed; 26 int nBlue; 27 int nGreen; 23 28 24 29 unsigned long fore; // basic foreground color … … 171 176 172 177 unsigned short *pixmap; // lookup table for image pixel value to pixel index 178 int nPixels; 179 173 180 KapaImageChannel *image; 174 181 KapaImageChannel channel[NCHANNELS]; -
branches/eam_branch_20071222/Ohana/src/kapa2/src/ButtonFunctions.c
r15925 r15935 18 18 SetColormap (name); 19 19 CreateColorbar (image, graphic); 20 SetColorScale (graphic, image); 20 21 Remap (graphic, image); 21 22 CreateZoom (image, graphic, 0, 0); … … 30 31 SetColormap (name); 31 32 CreateColorbar (image, graphic); 33 SetColorScale (graphic, image); 32 34 Remap (graphic, image); 33 35 CreateZoom (image, graphic, 0, 0); … … 40 42 char *name; 41 43 name = RAINBOW; 42 SetColormap ( name);44 SetColormap ("fullcolor"); 43 45 CreateColorbar (image, graphic); 46 SetColorScale (graphic, image); 44 47 Remap (graphic, image); 45 48 CreateZoom (image, graphic, 0, 0); -
branches/eam_branch_20071222/Ohana/src/kapa2/src/Image.c
r15925 r15935 33 33 } 34 34 image[0].image = &image[0].channel[0]; 35 36 image[0].nPixels = 0; 37 ALLOCATE (image[0].pixmap, unsigned short, 1); /* allocate so later free will not crash! */ 38 39 // XXXX this has been moved to graphic, which may be wrong 40 // image[0].ColorScaleMode = KAPA_SCALE_1D; 35 41 36 42 for (i = 0; i < NOVERLAYS; i++) { … … 165 171 free (image[0].overlay[i].objects); 166 172 } 167 free (image[0].image[0].matrix.buffer); 173 for (i = 0; i < NCHANNELS; i++) { 174 free (image[0].channel[i].matrix.buffer); 175 } 176 free (image[0].pixmap); 168 177 free (image[0].picture.data); 169 178 free (image[0].cmapbar.data); -
branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadPicture.c
r15925 r15935 63 63 if (!USE_XWINDOW) return (TRUE); 64 64 65 SetColorScale (graphic, image); 65 66 Remap (graphic, image); 66 67 if (DEBUG) fprintf (stderr, "remapped image\n"); -
branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c
r15925 r15935 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 # define PixelLookup(VALUE) (int)(MIN (MAX (slope * VALUE - start, 0), MaxValue))9 10 # if (0)11 static int PixelLookup(float value) {12 int out;13 out = MIN (MAX (slope * value - start, 0), MaxValue);14 return (out);15 }16 # endif17 2 18 3 void Remap32 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) { … … 25 10 int expand_in, expand_out; 26 11 unsigned int *out_pix, *out_pix2; 27 float *imdata,*in_pix, *in_pix2;12 unsigned short *in_pix, *in_pix2; 28 13 unsigned long *pixel, pixvalue; 29 14 unsigned long back; … … 36 21 } 37 22 back = graphic[0].back; 38 39 // define the color transform parameters40 MaxValue = graphic[0].Npixels - 1;41 if (image[0].image[0].range != 0.0) {42 slope = graphic[0].Npixels / image[0].image[0].range;43 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;44 } else {45 slope = 1.0;46 start = image[0].image[0].zero;47 }48 23 49 24 // set up expansions … … 98 73 99 74 out_pix = (unsigned int *) image[0].picture.data; 100 imdata = (float *) matrix[0].buffer; 101 in_pix = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 75 in_pix = &image[0].pixmap[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 102 76 103 77 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 122 96 if (expand_out == 1) { 123 97 for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) { 124 pixelN = PixelLookup(*in_pix2); 125 *out_pix = pixel[pixelN]; 98 *out_pix = pixel[*in_pix2]; 126 99 } 127 } 128 else { 100 } else { 129 101 for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) { 130 pixelN = PixelLookup(*in_pix2); 131 pixvalue = pixel[pixelN]; 102 pixvalue = pixel[*in_pix2]; 132 103 out_pix2 = out_pix; 133 104 for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) { … … 148 119 } 149 120 out_pix += (dx - i_end); 150 151 121 } 152 122 -
branches/eam_branch_20071222/Ohana/src/kapa2/src/Reorient.c
r15925 r15935 4 4 5 5 if (image[0].expand == 0) image[0].expand = 1; 6 7 if ((image[0].X == X) && (image[0].Y == Y) && (mode == 0)) { 8 Refresh (); 9 XFlush (graphic[0].display); 10 return; 11 } 6 12 7 13 switch (mode) { -
branches/eam_branch_20071222/Ohana/src/kapa2/src/SetChannel.c
r15925 r15935 25 25 if (!USE_XWINDOW) return (TRUE); 26 26 27 SetColorScale (graphic, image); 27 28 Remap (graphic, image); 28 29 if (DEBUG) fprintf (stderr, "remapped image\n"); -
branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColormap.c
r15925 r15935 13 13 int SetColormap (char *name) { 14 14 15 int i, re f1, ref2;15 int i, red, blue, green; 16 16 float scale, blueRef, redRef, greenRef; 17 17 Graphic *graphic; 18 18 19 19 graphic = GetGraphic(); 20 21 // very simple color model: evenly spaced cube 22 if (!strcasecmp (name, "fullcolor")) { 23 graphic[0].nRed = pow (graphic[0].Npixels, 0.333); 24 graphic[0].nBlue = pow (graphic[0].Npixels, 0.333); 25 graphic[0].nGreen = graphic[0].Npixels / (graphic[0].nRed * graphic[0].nBlue); 26 27 // red,green,blue are values in range 0x0000 to 0xffff 28 float redScale = 0xffff / (graphic[0].nRed - 1); 29 float blueScale = 0xffff / (graphic[0].nBlue - 1); 30 float greenScale = 0xffff / (graphic[0].nGreen - 1); 31 32 i = 0; 33 for (red = 0; red < graphic[0].nRed; red++) { 34 for (blue = 0; blue < graphic[0].nBlue; blue++) { 35 for (green = 0; green < graphic[0].nGreen; green++, i++) { 36 SETVALUE (graphic[0].cmap[i].red, red*redScale, 0, 0xffff); 37 SETVALUE (graphic[0].cmap[i].blue, blue*blueScale, 0, 0xffff); 38 SETVALUE (graphic[0].cmap[i].green, green*greenScale, 0, 0xffff); 39 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 40 } 41 } 42 } 43 44 // all other modes are 1D: set the flag: 45 graphic[0].ColorScaleMode = KAPA_SCALE_3D; 46 goto store_colors; 47 } 48 49 // all other modes are 1D: set the flag: 50 graphic[0].ColorScaleMode = KAPA_SCALE_1D; 20 51 21 52 // red,green,blue are values in range 0x0000 to 0xffff
Note:
See TracChangeset
for help on using the changeset viewer.
