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

Function _cupsRasterReadPixels

cups/raster-stream.c:759–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

757 */
758
759unsigned /* O - Number of bytes read */
760_cupsRasterReadPixels(
761 cups_raster_t *r, /* I - Raster stream */
762 unsigned char *p, /* I - Pointer to pixel buffer */
763 unsigned len) /* I - Number of bytes to read */
764{
765 ssize_t bytes; /* Bytes read */
766 unsigned cupsBytesPerLine; /* cupsBytesPerLine value */
767 unsigned remaining; /* Bytes remaining */
768 unsigned char *ptr, /* Pointer to read buffer */
769 byte, /* Byte from file */
770 *temp; /* Pointer into buffer */
771 unsigned count; /* Repetition count */
772
773
774 DEBUG_printf(("_cupsRasterReadPixels(r=%p, p=%p, len=%u)", (void *)r, (void *)p, len));
775
776 if (r == NULL || r->mode != CUPS_RASTER_READ || r->remaining == 0 ||
777 r->header.cupsBytesPerLine == 0)
778 {
779 DEBUG_puts("1_cupsRasterReadPixels: Returning 0.");
780 return (0);
781 }
782
783 DEBUG_printf(("1_cupsRasterReadPixels: compressed=%d, remaining=%u", r->compressed, r->remaining));
784
785 if (!r->compressed)
786 {
787 /*
788 * Read without compression...
789 */
790
791 r->remaining -= len / r->header.cupsBytesPerLine;
792
793 if (cups_raster_io(r, p, len) < (ssize_t)len)
794 {
795 DEBUG_puts("1_cupsRasterReadPixels: Read error, returning 0.");
796 return (0);
797 }
798
799 /*
800 * Swap bytes as needed...
801 */
802
803 if (r->swapped &&
804 (r->header.cupsBitsPerColor == 16 ||
805 r->header.cupsBitsPerPixel == 12 ||
806 r->header.cupsBitsPerPixel == 16))
807 cups_swap(p, len);
808
809 /*
810 * Return...
811 */
812
813 DEBUG_printf(("1_cupsRasterReadPixels: Returning %u", len));
814
815 return (len);
816 }

Callers 1

cupsRasterReadPixelsFunction · 0.85

Calls 3

cups_raster_ioFunction · 0.85
cups_swapFunction · 0.85
cups_raster_readFunction · 0.85

Tested by

no test coverage detected