Changeset 13479 for trunk/Ohana/src/kapa2/src/JPEGit24.c
- Timestamp:
- May 22, 2007, 12:23:09 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/kapa2/src/JPEGit24.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa2/src/JPEGit24.c
r13320 r13479 6 6 # define WHITE_B 255 7 7 8 // XXX this currently writes out the jpeg for the active image 9 int JPEGit24 () { 8 static float slope = 1.0; 9 static float start = 0.0; 10 static int MaxValue = 255; 11 12 // XXX inline this if needed 13 static int PixelLookup(float value) { 14 int out; 15 out = MIN (MAX (slope * value - start, 0), MaxValue); 16 return (out); 17 } 18 19 // XXX this currently writes out the jpeg for just the active image 20 int JPEGit24 (int sock) { 10 21 11 22 struct jpeg_compress_struct cinfo; … … 21 32 int i_start, i_end, j_start, j_end; 22 33 int dropback; /* this is a bit of a kludge... */ 23 int dx, dy, DX, DY ;34 int dx, dy, DX, DY, pixelN; 24 35 int status, Nbytes, quality; 25 36 int expand_in, expand_out; 26 37 double expand, Rx, Ry, X, Y; 27 unsigned char *out_pix, *in_pix, *in_pix_ref; 38 unsigned char *out_pix; 39 float *imdata, *in_pix, *in_pix_ref; 28 40 unsigned char pixel1[256], pixel2[256], pixel3[256]; 29 41 char filename[1024]; 30 42 FILE *f; 31 43 44 /* expect a line telling the number of bytes and a filename */ 45 KiiScanMessage (sock, "%s", filename); 46 32 47 graphic = GetGraphic(); 33 48 section = GetActiveSection(); 34 49 image = section->image; 35 36 /* expect a line telling the number of bytes and a filename */ 37 KiiScanMessage (sock, "%s", filename); 50 if (image == NULL) return (TRUE); 38 51 39 52 /***** JPEG init calls */ … … 69 82 } 70 83 84 // define the color transform parameters 85 MaxValue = graphic[0].Npixels - 1; 86 if (image[0].range != 0.0) { 87 slope = graphic[0].Npixels / image[0].range; 88 start = graphic[0].Npixels * image[0].zero / image[0].range; 89 } else { 90 slope = 1.0; 91 start = image[0].zero; 92 } 93 71 94 expand = expand_in = expand_out = 1.0; 72 95 if (image[0].expand == 0) /* set up expansions */ … … 122 145 ALLOCATE (line_buffer, JSAMPLE, 3*dx); 123 146 124 in_pix_ref = (unsigned char *) (image[0].matrix.buffer) + DX*(int)MAX(Y,0) + (int)MAX(X,0); 147 imdata = (float *) image[0].matrix.buffer; 148 in_pix_ref = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)]; 125 149 126 150 /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/ … … 153 177 /*** fill in the picture region ***/ 154 178 for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) { 179 pixelN = PixelLookup(*in_pix); 155 180 for (ii = 0; ii < expand_out; ii++, out_pix+=3) { 156 out_pix[0] = pixel1[ *in_pix];157 out_pix[1] = pixel2[ *in_pix];158 out_pix[2] = pixel3[ *in_pix];181 out_pix[0] = pixel1[pixelN]; 182 out_pix[1] = pixel2[pixelN]; 183 out_pix[2] = pixel3[pixelN]; 159 184 } 160 185 }
Note:
See TracChangeset
for help on using the changeset viewer.
