MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cupsRasterWriteHeader

Function _cupsRasterWriteHeader

cups/raster-stream.c:1016–1185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1014 */
1015
1016unsigned /* O - 1 on success, 0 on failure */
1017_cupsRasterWriteHeader(
1018 cups_raster_t *r) /* I - Raster stream */
1019{
1020 DEBUG_printf(("_cupsRasterWriteHeader(r=%p)", (void *)r));
1021
1022 DEBUG_printf(("1_cupsRasterWriteHeader: cupsColorSpace=%s", _cupsRasterColorSpaceString(r->header.cupsColorSpace)));
1023 DEBUG_printf(("1_cupsRasterWriteHeader: cupsBitsPerColor=%u", r->header.cupsBitsPerColor));
1024 DEBUG_printf(("1_cupsRasterWriteHeader: cupsBitsPerPixel=%u", r->header.cupsBitsPerPixel));
1025 DEBUG_printf(("1_cupsRasterWriteHeader: cupsBytesPerLine=%u", r->header.cupsBytesPerLine));
1026 DEBUG_printf(("1_cupsRasterWriteHeader: cupsWidth=%u", r->header.cupsWidth));
1027 DEBUG_printf(("1_cupsRasterWriteHeader: cupsHeight=%u", r->header.cupsHeight));
1028
1029 /*
1030 * Compute the number of raster lines in the page image...
1031 */
1032
1033 if (!cups_raster_update(r))
1034 {
1035 DEBUG_puts("1_cupsRasterWriteHeader: Unable to update parameters, returning 0.");
1036 return (0);
1037 }
1038
1039 if (r->mode == CUPS_RASTER_WRITE_APPLE)
1040 {
1041 if (r->header.HWResolution[0] == 0 || r->header.HWResolution[1] == 0)
1042 return (0);
1043
1044 r->rowheight = r->header.HWResolution[0] / r->header.HWResolution[1];
1045
1046 if (r->header.HWResolution[0] != (r->rowheight * r->header.HWResolution[1]))
1047 return (0);
1048 }
1049 else
1050 r->rowheight = 1;
1051
1052 /*
1053 * Write the raster header...
1054 */
1055
1056 if (r->mode == CUPS_RASTER_WRITE_PWG)
1057 {
1058 /*
1059 * PWG raster data is always network byte order with much of the page header
1060 * zeroed.
1061 */
1062
1063 cups_page_header2_t fh; /* File page header */
1064
1065 memset(&fh, 0, sizeof(fh));
1066 strlcpy(fh.MediaClass, "PwgRaster", sizeof(fh.MediaClass));
1067 strlcpy(fh.MediaColor, r->header.MediaColor, sizeof(fh.MediaColor));
1068 strlcpy(fh.MediaType, r->header.MediaType, sizeof(fh.MediaType));
1069 strlcpy(fh.OutputType, r->header.OutputType, sizeof(fh.OutputType));
1070 strlcpy(fh.cupsRenderingIntent, r->header.cupsRenderingIntent,
1071 sizeof(fh.cupsRenderingIntent));
1072 strlcpy(fh.cupsPageSizeName, r->header.cupsPageSizeName,
1073 sizeof(fh.cupsPageSizeName));

Callers 2

cupsRasterWriteHeaderFunction · 0.85
cupsRasterWriteHeader2Function · 0.85

Calls 3

cups_raster_updateFunction · 0.85
cups_raster_ioFunction · 0.85

Tested by

no test coverage detected