Changeset 5700 for trunk/Ohana/src/kii/button/PSit.c
- Timestamp:
- Dec 5, 2005, 3:55:45 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/kii/button/PSit.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kii/button/PSit.c
r2466 r5700 27 27 } 28 28 29 if (!USE_XWINDOW) { 30 fprintf (stderr, "PS not working yet\n"); 31 return (TRUE); 32 } 33 29 34 scale = MIN ((500.0/(double)layout[0].picture.dx), (700.0/(double)layout[0].picture.dy)); 30 35 if (!Raw) { … … 63 68 64 69 /******** First we draw the picture itself ********/ 70 /* in !USE_XWINDOW, we'll have to change this to use the JPEG function */ 65 71 switch (graphic[0].Nbits) { 66 72 case 8: … … 107 113 } 108 114 115 void ConvertPixmap (Layout *layout, File *f) { 116 117 /* set up expansions */ 118 expand = expand_in = expand_out = 1.0; 119 if (layout[0].expand == 0) 120 layout[0].expand = 1; 121 if (layout[0].expand > 0) { 122 expand = 1 / (1.0*layout[0].expand); 123 expand_out = layout[0].expand; 124 expand_in = 1; 125 } 126 if (layout[0].expand < 0) { 127 expand = fabs((double)layout[0].expand); 128 expand_out = 1; 129 expand_in = -layout[0].expand; 130 } 131 132 dx = layout[0].picture.dx; 133 dy = layout[0].picture.dy; 134 DX = layout[0].matrix.Naxis[0]; 135 DY = layout[0].matrix.Naxis[1]; 136 137 /* X,Y are the image coordinates of the first image pixel */ 138 X = MAX(0.5*(DX - dx*expand) - layout[0].X, 0); 139 if ((int)X != X) 140 X = (int) X + 1; 141 else 142 X = (int) X; 143 Y = MAX(0.5*(DY - dy*expand) - layout[0].Y, 0); 144 if ((int)Y != Y) 145 Y = (int) Y + 1; 146 else 147 Y = (int) Y; 148 149 /* Rx,Ry are the screen coordinates of the first image pixel */ 150 Rx = (X + layout[0].X - 0.5*DX)/expand + 0.5*dx; 151 Ry = (Y + layout[0].Y - 0.5*DY)/expand + 0.5*dy; 152 153 i_start = MIN (MAX (Rx, 0), dx - expand_out + 1); 154 j_start = MIN (MAX (Ry, 0), dy - expand_out + 1); 155 156 if (layout[0].expand > 0) { 157 i_end = MAX (MIN (i_start + ((int)(expand*(dx-i_start)))/expand, expand_out*(DX-X) + Rx), 0); 158 j_end = MAX (MIN (j_start + ((int)(expand*(dy-j_start)))/expand, expand_out*(DY-Y) + Ry), 0); 159 } else { 160 i_end = MAX (MIN (dx, (DX-X)/expand + Rx), 0); 161 j_end = MAX (MIN (dy, (DY-Y)/expand + Ry), 0); 162 } 163 164 dropback = expand_out - (i_end - i_start) % expand_out; 165 if ((i_end - i_start) % expand_out == 0) dropback = 0; 166 167 /* output line buffer */ 168 ALLOCATE (line_buffer, char, dx); 169 170 in_pix_ref = (unsigned char *) (layout[0].matrix.buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0); 171 172 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ 173 174 Nchar = 255.0; 175 Npix = layout[0].Npixels; 176 frac = Nchar / Npix; 177 178 /**** fill in bottom area ****/ 179 out_pix = line_buffer; 180 for (i = 0; i < dx; i++, out_pix++) { 181 *out_pix = WHITE; 182 } 183 for (j = 0; j < j_start; j++) { 184 for (i = 0; i < dx; i++) { 185 fprintf (f, "%02x", val); 186 if ((Npt % 40) == 0) { 187 fprintf (f, "\n"); 188 } 189 } 190 } 191 192 /*** fill in the image data region ***/ 193 for (j = j_start; j < j_end; j+= expand_out, in_pix_ref += expand_in*DX) { 194 195 /* create one output image line */ 196 in_pix = in_pix_ref; 197 out_pix = line_buffer; 198 199 /**** fill in area to the left of the picture ****/ 200 for (i = 0; i < i_start; i++, out_pix+=3) { 201 *out_pix = WHITE; 202 } 203 204 /*** fill in the picture region ***/ 205 for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) { 206 for (ii = 0; ii < expand_out; ii++, out_pix++) { 207 *out_pix = *in_pix*frac; 208 } 209 } 210 211 /**** fill in area to the right of the picture ****/ 212 for (i = i_end; i < dx; i++, out_pix++) { 213 *out_pix = WHITE; 214 } 215 216 /* write out the image line expand_out times */ 217 for (j = 0; j < expand_out; j++) { 218 for (i = 0; i < dx; i++) { 219 fprintf (f, "%02x", val); 220 if ((Npt % 40) == 0) { 221 fprintf (f, "\n"); 222 } 223 } 224 } 225 } 226 227 /**** fill in top area ****/ 228 out_pix = line_buffer; 229 for (i = 0; i < dx; i++, out_pix++) { 230 *out_pix = WHITE; 231 } 232 for (j = j_end; j < dy; j++) { 233 for (i = 0; i < dx; i++) { 234 fprintf (f, "%02x", val); 235 if ((Npt % 40) == 0) { 236 fprintf (f, "\n"); 237 } 238 } 239 } 240 } 241 109 242 void ConvertPixmap8 (Layout *layout, FILE *f) { 110 243
Note:
See TracChangeset
for help on using the changeset viewer.
