| 210 | */ |
| 211 | |
| 212 | int /* O - 1 on success, 0 on failure */ |
| 213 | _cupsRasterInitPWGHeader( |
| 214 | cups_page_header2_t *h, /* I - Page header */ |
| 215 | pwg_media_t *media, /* I - PWG media information */ |
| 216 | const char *type, /* I - PWG raster type string */ |
| 217 | int xdpi, /* I - Cross-feed direction (horizontal) resolution */ |
| 218 | int ydpi, /* I - Feed direction (vertical) resolution */ |
| 219 | const char *sides, /* I - IPP "sides" option value */ |
| 220 | const char *sheet_back) /* I - Transform for back side or @code NULL@ for none */ |
| 221 | { |
| 222 | if (!h || !media || !type || xdpi <= 0 || ydpi <= 0) |
| 223 | { |
| 224 | _cupsRasterAddError("%s", strerror(EINVAL)); |
| 225 | return (0); |
| 226 | } |
| 227 | |
| 228 | /* |
| 229 | * Initialize the page header... |
| 230 | */ |
| 231 | |
| 232 | memset(h, 0, sizeof(cups_page_header2_t)); |
| 233 | |
| 234 | strlcpy(h->cupsPageSizeName, media->pwg, sizeof(h->cupsPageSizeName)); |
| 235 | |
| 236 | h->PageSize[0] = (unsigned)(72 * media->width / 2540); |
| 237 | h->PageSize[1] = (unsigned)(72 * media->length / 2540); |
| 238 | |
| 239 | /* This never gets written but is needed for some applications */ |
| 240 | h->cupsPageSize[0] = 72.0f * media->width / 2540.0f; |
| 241 | h->cupsPageSize[1] = 72.0f * media->length / 2540.0f; |
| 242 | |
| 243 | h->ImagingBoundingBox[2] = h->PageSize[0]; |
| 244 | h->ImagingBoundingBox[3] = h->PageSize[1]; |
| 245 | |
| 246 | h->HWResolution[0] = (unsigned)xdpi; |
| 247 | h->HWResolution[1] = (unsigned)ydpi; |
| 248 | |
| 249 | h->cupsWidth = (unsigned)(media->width * xdpi / 2540); |
| 250 | h->cupsHeight = (unsigned)(media->length * ydpi / 2540); |
| 251 | |
| 252 | if (h->cupsWidth > 0x00ffffff || h->cupsHeight > 0x00ffffff) |
| 253 | { |
| 254 | _cupsRasterAddError("Raster dimensions too large."); |
| 255 | return (0); |
| 256 | } |
| 257 | |
| 258 | h->cupsInteger[CUPS_RASTER_PWG_ImageBoxRight] = h->cupsWidth; |
| 259 | h->cupsInteger[CUPS_RASTER_PWG_ImageBoxBottom] = h->cupsHeight; |
| 260 | |
| 261 | /* |
| 262 | * Colorspace and bytes per line... |
| 263 | */ |
| 264 | |
| 265 | if (!strcmp(type, "adobe-rgb_8")) |
| 266 | { |
| 267 | h->cupsBitsPerColor = 8; |
| 268 | h->cupsBitsPerPixel = 24; |
| 269 | h->cupsColorSpace = CUPS_CSPACE_ADOBERGB; |
no test coverage detected