Changeset 32646
- Timestamp:
- Nov 10, 2011, 5:42:14 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20111110/Ohana/src/kapa2
- Files:
-
- 3 edited
-
include/prototypes.h (modified) (1 diff)
-
src/PSPixmap.c (modified) (2 diffs)
-
src/PSimage.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111110/Ohana/src/kapa2/include/prototypes.h
r30606 r32646 126 126 void PSPixmap24 PROTO((Graphic *graphic, KapaImageWidget *image, FILE *f)); 127 127 void PSPixmap32 PROTO((Graphic *graphic, KapaImageWidget *image, FILE *f)); 128 void PSPixmap_3byte PROTO((Graphic *graphic, KapaImageWidget *image, FILE *f)); 128 129 129 130 /* kapa bDraw Functions */ -
branches/eam_branches/ipp-20111110/Ohana/src/kapa2/src/PSPixmap.c
r16256 r32646 1 1 # include "Ximage.h" 2 3 // XXX this stuff has been broken by the conversion to the pixmap stuff4 2 5 3 void PSPixmap8 (Graphic *graphic, KapaImageWidget *image, FILE *f) { … … 146 144 } 147 145 148 # if (0) 149 // XXX needs work! 150 void PSPixmap32_RGB (Graphic *graphic, KapaImageWidget *image, FILE *f) { 151 152 int i, k, m, val; 153 double Nchar, Npix, start, slope, frac; 154 unsigned int *buff; 155 unsigned long back; 156 unsigned char 157 158 ALLOCATE (pixelR, unsigned char, graphic[0].Npixels); 159 ALLOCATE (pixelG, unsigned char, graphic[0].Npixels); 160 ALLOCATE (pixelB, unsigned char, graphic[0].Npixels); 146 # define WHITE_R 255 147 # define WHITE_G 255 148 # define WHITE_B 255 149 150 void PSPixmap_3byte (Graphic *graphic, KapaImageWidget *image, FILE *f) { 151 152 int i, j, ii, jj; 153 int i_start, i_end, j_start, j_end; 154 int I_start, J_start; 155 int dropback; /* this is a bit of a kludge... */ 156 int dx, dy, DX, DY, inDX, inDY, Xs, Ys; 157 int expand_in, expand_out; 158 double expand, Ix, Iy; 159 unsigned short *in_pix, *in_pix_ref; 160 unsigned char *pixel1, *pixel2, *pixel3; 161 162 if (image == NULL) return; 163 164 ALLOCATE (pixel1, unsigned char, graphic[0].Npixels); 165 ALLOCATE (pixel2, unsigned char, graphic[0].Npixels); 166 ALLOCATE (pixel3, unsigned char, graphic[0].Npixels); 161 167 162 168 /** cmap[i].pixel must be defined even if X is not used **/ 163 169 for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */ 164 pixelR[i] = graphic[0].cmap[i].red >> 8; 165 pixelG[i] = graphic[0].cmap[i].green >> 8; 166 pixelB[i] = graphic[0].cmap[i].blue >> 8; 167 } 168 169 for (i = 0; i < image[0].picture.dy; i++) { 170 for (k = 0; k < image[0].picture.dx; k++, buff++) { 171 if (*buff == back) 172 val = Nchar; 173 else { 174 for (m = 0; (graphic[0].cmap[m].pixel != *buff) && (m < Npix); m++); 175 val = Nchar - frac * MIN (MAX (start + m * slope, 0), Npix); 176 } 177 fprintf (f, "%02x", val); 178 if (!((k+1) % 40)) fprintf (f, "\n"); 179 } 180 fprintf (f, "\n"); 181 buff -= 2*image[0].picture.dx; 182 } 183 return; 184 } 185 # endif 170 pixel1[i] = graphic[0].cmap[i].red >> 8; 171 pixel2[i] = graphic[0].cmap[i].green >> 8; 172 pixel3[i] = graphic[0].cmap[i].blue >> 8; 173 } 174 175 assert ((image[0].picture.expand >= 1) || (image[0].picture.expand <= -2)); 176 expand = expand_in = expand_out = 1.0; 177 if (image[0].picture.expand > 0) { 178 expand = 1 / (1.0*image[0].picture.expand); 179 expand_out = image[0].picture.expand; 180 expand_in = 1; 181 } 182 if (image[0].picture.expand < 0) { 183 expand = fabs((double)image[0].picture.expand); 184 expand_out = 1; 185 expand_in = -image[0].picture.expand; 186 } 187 188 Xs = image[0].picture.x; 189 Ys = image[0].picture.y; 190 dx = image[0].picture.dx; 191 dy = image[0].picture.dy; 192 DX = image[0].image[0].matrix.Naxis[0]; 193 DY = image[0].image[0].matrix.Naxis[1]; 194 195 // i_start, j_start are the closest lit screen pixel to 0,0 196 // I_start, J_start are the image pixel corresponding to i_start, j_start 197 Picture_Lower (&i_start, &j_start, &I_start, &J_start, &image[0].image[0].matrix, &image[0].picture); 198 199 // i_end, j_end are the closest lit screen pixel to dx, dy 200 // I_end, J_end are the image pixel corresponding to i_end, j_end 201 Picture_Upper (&i_end, &j_end, i_start, j_start, &image[0].image[0].matrix, &image[0].picture); 202 203 assert (i_start <= i_end); 204 assert (j_start <= j_end); 205 206 Ix = image[0].picture.flipx ? I_start - 1 : I_start; 207 Iy = image[0].picture.flipy ? J_start - 1 : J_start; 208 209 inDX = image[0].picture.flipx ? -1 : +1; 210 inDY = image[0].picture.flipy ? -1 : +1; 211 212 dropback = expand_out - (i_end - i_start) % expand_out; 213 if ((i_end - i_start) % expand_out == 0) dropback = 0; 214 215 in_pix_ref = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)]; 216 217 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ 218 219 // add in occasional return chars 220 221 /**** fill in bottom area ****/ 222 for (j = 0; j < j_start; j++) { 223 for (i = 0; i < dx; i++) { 224 fprintf (f, "%02x%02x%02x", WHITE_R, WHITE_G, WHITE_B); 225 } 226 } 227 228 // probably could do this all smarter with scale operations in PS... 229 230 /*** fill in the image data region ***/ 231 for (j = j_start; j < j_end; j+= expand_out, in_pix_ref += inDY*expand_in*DX) { 232 233 // repeat the section below 'expand_out' times 234 for (jj = 0; jj < expand_out; jj++) { 235 236 /* create one output image line */ 237 in_pix = in_pix_ref; 238 239 /**** fill in area to the left of the picture ****/ 240 for (i = 0; i < i_start; i++) { 241 fprintf (f, "%02x%02x%02x", WHITE_R, WHITE_G, WHITE_B); 242 } 243 244 /*** fill in the picture region ***/ 245 for (i = i_start; i < i_end; i+=expand_out, in_pix += inDX*expand_in) { 246 for (ii = 0; ii < expand_out; ii++) { 247 fprintf (f, "%02x%02x%02x", pixel1[*in_pix], pixel2[*in_pix], pixel3[*in_pix]); 248 } 249 } 250 251 /**** fill in area to the right of the picture ****/ 252 for (i = i_end; i < dx; i++) { 253 fprintf (f, "%02x%02x%02x", WHITE_R, WHITE_G, WHITE_B); 254 } 255 } 256 } 257 258 /**** fill in top area ****/ 259 for (j = j_end; j < dy; j++) { 260 for (i = 0; i < dx; i++) { 261 fprintf (f, "%02x%02x%02x", WHITE_R, WHITE_G, WHITE_B); 262 } 263 } 264 265 free (pixel1); 266 free (pixel2); 267 free (pixel3); 268 269 return; 270 } -
branches/eam_branches/ipp-20111110/Ohana/src/kapa2/src/PSimage.c
r29938 r32646 13 13 graphic = GetGraphic(); 14 14 15 // Update this to generate color PS images: I need to test if the image if color or BW (based 16 // on the colormap). If it is a color image, I need to generate a 24 bit image. the header 17 // should look the same (Nx Ny 8 [1 0 0 1 0 0]) but then it should finish with "false 3 18 // colorimage" instead of just "image" (see ../doc/color.image.s for an example). the hex 19 // string needs to have RGB represented as chars (2 hex chars per R,G,B). 20 // the values come from the following map: image[0].pixmap[i] -> cmap[pixel].red -> R (0-255) 21 15 22 fprintf (f, " newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto closepath\n\n", 16 23 (int) image[0].picture.x, graphic->dy - (int) image[0].picture.y, … … 21 28 fprintf (f, "%d %d translate\n", (int) image[0].picture.x, graphic->dy - (int) image[0].picture.y - image[0].picture.dy); 22 29 fprintf (f, "%d %d 8\n", image[0].picture.dx, image[0].picture.dy); 23 fprintf (f, "[1 0 0 1 0 0]\n"); 30 fprintf (f, "[1 0 0 -1 0 %d]\n", image[0].picture.dy); 31 // write out the image in normal order, but flip in PS 32 33 # if (0) 34 24 35 fprintf (f, "{currentfile %d string readhexstring pop} image\n\n", image[0].picture.dx); 36 PSPixmap_1byte (graphic, image, f); 25 37 26 /******** First we draw the picture itself ********/ 27 /* in !USE_XWINDOW, we'll have to change this to use the JPEG function */ 28 switch (graphic[0].Nbits) { 29 case 8: 30 PSPixmap8 (graphic, image, f); 31 break; 32 case 16: 33 PSPixmap16 (graphic, image, f); 34 break; 35 case 24: 36 PSPixmap24 (graphic, image, f); 37 break; 38 case 32: 39 PSPixmap32 (graphic, image, f); 40 break; 41 } 38 # else 39 40 fprintf (f, "{currentfile %d string readhexstring pop} false 3 colorimage\n\n", 3*image[0].picture.dx); 41 PSPixmap_3byte (graphic, image, f); 42 43 # endif 42 44 43 45 fprintf (f, "grestore %% end of image\n");
Note:
See TracChangeset
for help on using the changeset viewer.
