⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pclgen.c

📁 openmeetings组件之GS openmeetings组件之GS openmeetings组件之GS
💻 C
📖 第 1 页 / 共 3 页
字号:
      fprintf(out, "@PJL ENTER LANGUAGE=%s\n", data->PJL_language);  }  /* PCL: Printer Reset */  fputs("\033E", out);  /* Additional initialization */  if (data->init1.length > 0)    fwrite(data->init1.str, sizeof(pcl_Octet), data->init1.length, out);  /* Page layout initialization */  fprintf(out,    "\033&l%da"	/* PCL: Page Size */    "0o"	/* PCL: Page Orientation/Orientation: portrait */    "0L",	/* PCL: Perforation Skip Mode: off. This also effectively sets		   the PCL top margin to zero. */    (int) data->size  );  /* Media source */  if (data->media_source != 0)    fprintf(out, "\033&l%dH", data->media_source);	/* PCL: Media Source */      /*  Note that a value of zero for the Media Source command means	  "eject the current page". Hence we are losing no functionality by	  reserving 0 to mean "no Media Source request". */  if (data->media_source != 2 && data->manual_feed) fputs("\033&l2H", out);   /* I am using two Media Source commands here in case the value 2 means      "manual feed from the last selected media source" on some printer. */  /*  Media destination. This is included here merely in the hope that, if a      PCL-3 printer should support such a feature, the command used is the same      as in PCL 5/6. At present, I know of no such printer. */  if (data->media_destination != 0)    fprintf(out, "\033&l%dG", data->media_destination);     /* PCL: Paper Destination (BPL02705). A value of zero means "auto select".      */  /*  Duplex. Again, I have only PCL-5 documentation for this, but in this case      I know that the DJ 970C uses the command. */  if (data->duplex != -1)    fprintf(out, "\033&l%dS", data->duplex);	/* PCL: Simplex/Duplex Print */  /* Print quality */  if (pcl_use_oldquality(data->level)) {    fprintf(out, "\033*r%dQ", data->raster_graphics_quality);      /* PCL: Raster Graphics Quality */    if (data->level > pcl_level_3plus_DJ500)      fprintf(out, "\033*o%dQ", data->shingling);	/* PCL: Set Raster Graphics Shingling/Mechanical Print Quality */    if (data->depletion != 0)     /*	According to TRG500 p. 6-32, depletion makes no sense for monochrome	data.  Besides, not all printers react to this command. Hence I'm	handing the decision to the caller. Note that permitted values are 1-5.      */      fprintf(out, "\033*o%dD", data->depletion);	/* PCL: Set Raster Graphics Depletion */  }  else    fprintf(out,      "\033&l%dM"	/* PCL: Media Type */      "\033*o%dM",	/* PCL: Print Quality */      data->media_type,      data->print_quality    );  /*  PCL: Set Dry Time/Dry Timer. This command is ignored by newer printers      and is obsolete for every printer supporting the new Media Type and Print      Quality commands. Because I am uncertain about what "current" means in      the description of the value 0 ("default dry time for the current print      quality", TRG500 p. 2-4), I'm putting the command here after the quality      commands. */  if (data->dry_time >= 0) fprintf(out, "\033&b%dT", data->dry_time);  /* End Raster Graphics. This provides a known graphics state, see     TRG500 p. 6-25, but is probably superfluous here because of the Printer     Reset command. */  send_ERG(out, data->level);  if (data->level != pcl_level_3plus_CRD_only)    /* PCL: Set Raster Graphics Resolution/Raster Resolution */    fprintf(out, "\033*t%uR", maxhres < maxvres? maxvres: maxhres);    /* If different x and y resolutions have been demanded but the printer does       not support the combination, choosing the larger value here will prevent       printing beyond the sheet---provided the printer accepts this resolution.     */  /* Set PCL unit to reciprocal of largest resolution */  if (data->level >= pcl_level_3plus_S68)    fprintf(out, "\033&u%uD", maxhres < maxvres? maxvres: maxhres);     /* PCL: Unit of Measure. This is not documented but merely mentioned in	DJ6/8. All HP drivers for newer printers I've looked at (admittedly not	many) generate this command, including a driver for the DJ 540.	Actually, as the routines here send a Move CAP Horizontal/Vertical        (PCL Units) command only for position 0, the units should be irrelevant.      */  /* Colour planes */  if (data->level != pcl_level_3plus_CRD_only &&      data->palette != pcl_no_palette && data->palette != pcl_any_palette)    fprintf(out, "\033*r%dU",	/* PCL: Set Number of Planes per Row/Simple Color */      data->palette == pcl_RGB? 3:	/* RGB palette */      -data->number_of_colorants);	/* (K)(CMY) palette */  /* Configure Raster Data */  if (needs_CRD) {    fprintf(out, "\033*g%uW"	/* PCL: Configure Raster Data */      "\002%c",		/* Format 2: Complex Direct Planar */      2 + 6*data->number_of_colorants, data->number_of_colorants);    for (j = 0; j < data->number_of_colorants; j++)      fprintf(out, "%c%c%c%c%c%c",	/*  Note that %c expects an 'int' (and converts it to 'unsigned char').	 */	colorant[j].hres/256,   colorant[j].hres%256,	colorant[j].vres/256,   colorant[j].vres%256,	colorant[j].levels/256, colorant[j].levels%256);  }  if (ferror(out)) {    fputs(ERRPREF "Unidentified system error while writing the output file.\n",      stderr);    return -1;  }  /* Additional initialization */  if (data->init2.length > 0)    fwrite(data->init2.str, sizeof(pcl_Octet), data->init2.length, out);  /* Determine and set the number of bit planes */  if (data->palette == pcl_CMY || data->palette == pcl_RGB)    data->black_planes = 0;  else data->black_planes =    pcl3_levels_to_planes(colorant[0].levels)*(colorant[0].vres/data->minvres);  data->number_of_bitplanes = 0;  for (j = 0; j < data->number_of_colorants; j++)    data->number_of_bitplanes +=      pcl3_levels_to_planes(colorant[j].levels)*	(colorant[j].vres/data->minvres);  return 0;}/******************************************************************************  Function: pcl3_begin_page  This function sets CAP on the top margin of the logical page. It may only  be called after pcl3_init_file() and not while a page is still open.******************************************************************************/int pcl3_begin_page(FILE *out, pcl_FileData *global){  fputs("\033*p0Y", out);    /* PCL: Vertical Cursor Positioning by Dots/Move CAP Vertical (PCL Units) */  return 0;}/******************************************************************************  Function: pcl3_begin_raster  This function starts raster mode at the left margin of the logical page  and at the current height.  The function may only be called within a page and not in raster mode.  The raster data structure '*data' will be checked for validity and parts of  the data may be modified. In particular, the caller should already have  allocated appropriate storage in the 'next' and, for differential compression  methods, 'previous' arrays. Until raster mode is terminated, the caller may  only modify the storage currently pointed to by the pointers in 'next' and  their corresponding length fields.******************************************************************************/int pcl3_begin_raster(FILE *out, pcl_RasterData *data){  const pcl_FileData *global = NULL;  int j;  /* Check 'data' for validity */  {    pcl_bool invalid;    invalid = (data == NULL || data->global == NULL || data->next == NULL ||      data->workspace[0] == NULL || data->workspace_allocated <= 0);    if (!invalid) {      global = data->global;      for (j = 0;	j < global->number_of_bitplanes &&	  (data->next[j].length == 0 || data->next[j].str != NULL);	j++);      invalid = j < global->number_of_bitplanes;      if (!invalid && pcl_cm_is_differential(global->compression)) {	invalid = (data->previous == NULL ||	  global->compression == pcl_cm_delta &&	    data->workspace[1] == NULL);	if (!invalid) {	  for (j = 0;	    j < global->number_of_bitplanes &&	      (data->previous[j].length == 0 || data->previous[j].str != NULL);	    j++);	  invalid = j < global->number_of_bitplanes;	}      }    }    if (invalid) {      fputs(ERRPREF "Invalid data structure passed to pcl3_begin_raster().\n",	stderr);      return +1;    }  }  /* Allocate the seed plane array */  data->seed_plane = (pcl_OctetString **)    malloc(global->number_of_bitplanes*sizeof(pcl_OctetString *));  if (data->seed_plane == NULL) {    fputs(ERRPREF "Memory allocation failure in pcl3_begin_raster().\n",      stderr);    return -1;  }  memset(data->seed_plane, 0,    global->number_of_bitplanes*sizeof(pcl_OctetString *));  /* Use the seed plane array for differential compression methods */  if (pcl_cm_is_differential(global->compression)) {    /*  HP's documentation is a bit obscure concerning what the seed plane for	a particular bit plane is. Most of the documentation talks only about	seed rows (and "rows" consist of planes), but then one suddenly comes	across a statement like "a separate seed row is maintained for each	graphic plane" (DJ6/8 p. 57). I've also never found a statement what	the seed row/plane/whatever for a bitplane in a strip group with	multiple lines or multiple planes per colorant is, except that DJ6/8	(p. 60) states explicitly that one cannot use Seed Row Source in that	situation to select it.	I therefore have to make a few assumptions. The following seem sensible:	- The PCL interpreter maintains independent "seed lines" for each	  colorant. Each line consists of independent seed planes, one for each	  bit plane in a pixel line for that colorant (i.e., there are	  pcl3_levels_to_planes(levels) seed planes for a colorant accepting	  'levels' intensity levels).	- If the current compression method (this is a global property of the	  interpreter) is a differential one, a bit plane is interpreted as a	  delta plane with respect to the corresponding bit plane in the	  current colorant's preceding line.    */    int strip;    const pcl_ColorantState *colorant = NULL;    int plane = 0;    if (global->colorant == NULL) colorant = global->colorant_array;    else colorant = global->colorant;    for (strip = 0; strip < global->number_of_colorants; strip++) {      int lines = colorant[strip].vres/global->minvres;      int planes = pcl3_levels_to_planes(colorant[strip].levels);      int l, p;      /* The first line of the colorant strip refers to the last line in the	 preceding strip. I'm assuming Seed Row Source == 0 here. */      for (p = 0; p < planes; p++, plane++)	data->seed_plane[plane] = data->previous + plane + (lines - 1)*planes;      /* Subsequent lines refer to the preceding line in the current strip	 group */      for (l = 1; l < lines; l++)	for (p = 0; p < planes; p++, plane++)	  data->seed_plane[plane] = data->next + plane - planes;    }  }  /* Start raster mode */  if (data->width > 0) {    fprintf(out, "\033*r%uS", data->width);    /* PCL: Set Raster Graphics Width/Source Raster Width. The value is the       number of pixels at the lowest horizontal resolution (see DJ6/8 p. 66).       This is reset by End Raster Graphics. */  }  fputs("\033*p0X"	/* PCL: Horizontal Cursor Positioning by Dots */	"\033*r1A", out);	  /* PCL: Start Raster Graphics: at current position */  /* After Start Raster Graphics the seed row consists of all zeroes     (DJ6/8 p. 50). */  if (pcl_cm_is_differential(global->compression))    for (j = 0; j < global->number_of_bitplanes; j++)      data->previous[j].length = 0;  fputs("\033*b", out);    /* We use combined escape sequences, all with this prefix. */  /*  The old End Raster Graphics command (with 'B') does not reset the      compression method to 'pcl_cm_none'. We could keep track of the current      compression method, but this would mean that we then have to track also      the Printer Reset command (DJ6/8 p. 55). It's easier to set the method      explicitly here. The worst which could happen is that in the case of      old printers we generate two consecutive commands the first of which is      superfluous. */  if (pcl_use_oldERG(global->level)) {    /* Raster Graphics Compression Method */    fprintf(out, "%dm", (int)global->compression);    data->current_compression = global->compression;  }  else data->current_compression = pcl_cm_none;  return 0;}/******************************************************************************  Function: pcl3_skip_groups  Routine to skip a number of strip groups. 'count' is the number of strip  groups (vertical distance in units of the reciprocal of the lowest vertical  raster resolution).  This function may only be called in raster mode.******************************************************************************/int pcl3_skip_groups(FILE *out, pcl_RasterData *data, unsigned int count){  int j;  /*  I don't know what happens with the seed row when 'count' is zero, but as      the command is superfluous in that case anyway I'm ignoring it. */  if (count == 0) return 0;  fprintf(out, "%uy", count);   /* PCL: Relative Vertical Pixel Movement/Y Offset.      The statement in DJ6/8, p. 52, that "this command zero-fills the offset      area" is incorrect. This can be seen when printing with an RGB palette on      a DJ 850C where it results in a white area, not a black one. Hence it      really skips these groups. */  /* This command has zeroed the seed row (DJ6/8 p. 52). */  if (pcl_cm_is_differential(data->global->compression))    for (j = 0; j < data->global->number_of_bitplanes; j++)      data->previous[j].length = 0;  return 0;}/******************************************************************************  Function: send_plane  This function sends a bit plane to the printer. It returns zero on success  and a non-zero value otherwise. In the latter case, an error message will  have been issued on stderr.  'final' indicates whether this is the last plane of the row or not.  'method_demanded' contains the PCL compression method desired, '*method_used'  the one actually used in the last transmission. This last variable will be  reset to the method used in this invocation.  'in' points to the octet string to be sent as plane data, 'prev' points to  the string previously sent (or whatever the reference plane for a differential  compression method is) and may be NULL if 'method_demanded' refers  to a purely "horizontal" method.  'out' is the file to which the plane should be written.  'out_bf1' and possibly 'out_bf2' are pointers to storage areas of at least  length 'out_bf_size' which can be used as scratch areas by this function.  'out_bf1' must be non-NULL.  'out_bf2' need only be non-NULL if 'method_demanded' is 'pcl_cm_delta'.  'out_bf_size' must be positive but need not be larger than 'in->length'+2.******************************************************************************/static int send_plane(pcl_bool final,  pcl_Compression method_demanded, pcl_Compression *method_used,  const pcl_OctetString *in, const pcl_OctetString *prev, FILE *out,  pcl_Octet *out_bf1, pcl_Octet *out_bf2, size_t out_bf_size){  int

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -