IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 22, 2007, 12:23:09 PM (19 years ago)
Author:
eugene
Message:

upgrading to kapa 2.0 API, upgrades to dvo user interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/src/JPEGit24.c

    r13320 r13479  
    66# define WHITE_B 255
    77
    8 // XXX this currently writes out the jpeg for the active image
    9 int JPEGit24 () {
     8static float slope = 1.0;
     9static float start = 0.0;
     10static int MaxValue = 255;
     11
     12// XXX inline this if needed
     13static 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
     20int JPEGit24 (int sock) {
    1021
    1122  struct jpeg_compress_struct cinfo;
     
    2132  int i_start, i_end, j_start, j_end;
    2233  int dropback;  /* this is a bit of a kludge... */
    23   int dx, dy, DX, DY;
     34  int dx, dy, DX, DY, pixelN;
    2435  int status, Nbytes, quality;
    2536  int expand_in, expand_out;
    2637  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;
    2840  unsigned char pixel1[256], pixel2[256], pixel3[256];
    2941  char filename[1024];
    3042  FILE *f;
    3143
     44  /* expect a line telling the number of bytes and a filename */
     45  KiiScanMessage (sock, "%s", filename);
     46
    3247  graphic = GetGraphic();
    3348  section = GetActiveSection();
    3449  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);
    3851
    3952  /***** JPEG init calls */
     
    6982  }
    7083
     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
    7194  expand = expand_in = expand_out = 1.0;
    7295  if (image[0].expand == 0) /* set up expansions */
     
    122145  ALLOCATE (line_buffer, JSAMPLE, 3*dx);
    123146
    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)];
    125149
    126150  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    153177    /*** fill in the picture region ***/
    154178    for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) {
     179      pixelN = PixelLookup(*in_pix);
    155180      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];
    159184      }
    160185    }
Note: See TracChangeset for help on using the changeset viewer.