Exemplo n.º 1
0
    /// Skip over a scanline.
    void skip( byte_t* dst, int )
    {
        // Fire exception in case of error.
        if( setjmp( this->_mark )) { this->raise_error(); }

        // read data
        read_scanline( dst );
    }
Exemplo n.º 2
0
void oil_libpng_read_scanline(struct oil_libpng *ol, unsigned char *outbuf)
{
	switch (png_get_interlace_type(ol->rpng, ol->rinfo)) {
	case PNG_INTERLACE_NONE:
		read_scanline(ol);
		break;
	case PNG_INTERLACE_ADAM7:
		read_scanline_interlaced(ol);
		break;
	}
	oil_scale_out(&ol->os, outbuf);
}
Exemplo n.º 3
0
int
read_scanline_rgb16 (TIFF *tif, uint16 *buffer, tsize_t size)
{
  return read_scanline (tif, (tdata_t) buffer);
}
Exemplo n.º 4
0
int
read_scanline_gray8 (TIFF *tif, uint8 *buffer, tsize_t size)
{
  return read_scanline (tif, (tdata_t) buffer);
}
Exemplo n.º 5
0
bool
ImageInput::read_image (TypeDesc format, void *data,
                        stride_t xstride, stride_t ystride, stride_t zstride,
                        ProgressCallback progress_callback,
                        void *progress_callback_data)
{
    bool native = (format == TypeDesc::UNKNOWN);
    stride_t pixel_bytes = native ? (stride_t) m_spec.pixel_bytes (native)
                                  : (stride_t) (format.size()*m_spec.nchannels);
    if (native && xstride == AutoStride)
        xstride = pixel_bytes;
    m_spec.auto_stride (xstride, ystride, zstride, format, m_spec.nchannels,
                        m_spec.width, m_spec.height);
    bool ok = true;
    if (progress_callback)
        if (progress_callback (progress_callback_data, 0.0f))
            return ok;
    if (m_spec.tile_width) {
        // Tiled image

        // Locally allocate a single tile to gracefully deal with image
        // dimensions smaller than a tile, or if one of the tiles runs
        // past the right or bottom edge.  Then we copy from our tile to
        // the user data, only copying valid pixel ranges.
        stride_t tilexstride = pixel_bytes;
        stride_t tileystride = tilexstride * m_spec.tile_width;
        stride_t tilezstride = tileystride * m_spec.tile_height;
        imagesize_t tile_pixels = m_spec.tile_pixels();
        std::vector<char> pels (tile_pixels * pixel_bytes);
        for (int z = 0;  z < m_spec.depth;  z += m_spec.tile_depth)
            for (int y = 0;  y < m_spec.height;  y += m_spec.tile_height) {
                for (int x = 0;  x < m_spec.width && ok;  x += m_spec.tile_width) {
                    ok &= read_tile (x+m_spec.x, y+m_spec.y, z+m_spec.z,
                                     format, &pels[0]);
                    // Now copy out the scanlines
                    int ntz = std::min (z+m_spec.tile_depth, m_spec.depth) - z;
                    int nty = std::min (y+m_spec.tile_height, m_spec.height) - y;
                    int ntx = std::min (x+m_spec.tile_width, m_spec.width) - x;
                    for (int tz = 0;  tz < ntz;  ++tz) {
                        for (int ty = 0;  ty < nty;  ++ty) {
                            // FIXME -- doesn't work for non-contiguous scanlines
                            memcpy ((char *)data + x*xstride + (y+ty)*ystride + (z+tz)*zstride,
                                    &pels[ty*tileystride+tz*tilezstride],
                                    ntx*tilexstride);
                        }
                    }
//                    return ok; // DEBUG -- just try very first tile
                }
                if (progress_callback)
                    if (progress_callback (progress_callback_data, (float)y/m_spec.height))
                        return ok;
            }
    } else {
        // Scanline image
        for (int z = 0;  z < m_spec.depth;  ++z)
            for (int y = 0;  y < m_spec.height && ok;  ++y) {
                ok &= read_scanline (y+m_spec.y, z+m_spec.z, format,
                                     (char *)data + z*zstride + y*ystride,
                                     xstride);
                if (progress_callback && !(y & 0x0f))
                    if (progress_callback (progress_callback_data, (float)y/m_spec.height))
                        return ok;
            }
    }
    if (progress_callback)
        progress_callback (progress_callback_data, 1.0f);
    return ok;
}
Exemplo n.º 6
0
 /// Skip over a scanline.
 void skip( byte_t* dst, int )
 {
     read_scanline( dst );
 }
Exemplo n.º 7
0
 void read( byte_t* dst
          , int
          )
 {
     read_scanline( dst );
 }
Exemplo n.º 8
0
static Errcode read_256_color_frame(Rfile *rf)
/* Read and parse all the opcodes in a RND file. */
{
int opcode;
Rcel *screen = rf->screen;

	/* clear color map to zeros */
	stuff_bytes(0,screen->cmap->ctab,
				screen->cmap->num_colors * sizeof(Rgb3));

#ifdef DEBUG
	#define PRT(s) printf(s)
#else
	#define PRT(s)
#endif /* DEBUG */


	for(;;)
	{
		opcode = fgetc(rf->file);

		switch(opcode)
		{
			case EOF:
				return(Success);
   			case RND_CLEAR:   /* Clear entire display */
				pj_set_rast(screen,0);
				continue;
   			case RND_CMAPB:  /* Begin Color map */
				read_color_map(rf);
				break;
   			case RND_POLY:   /* Polygon */
				read_polygon(rf);
				break;
   			case RND_CRANGE:  /* Continous-color range */
				PRT("RND_CRANGE");
				goto bad_opcode;
   			case RND_CPOLY:   /* Continous-color polygon */
				PRT("RND_CPOLY");
				goto bad_opcode;
			case RND_WSLINE:  /* Output Scan line to driver */
				read_scanline(rf);
				break;
			case RND_RSLINE:  /* Input Scan line from driver */
				PRT("RND_RSLINE");
				goto bad_opcode;
			case RND_RCMAP:   /* Input color map rgb from driver */
				PRT("RND_RCMAP");
				goto bad_opcode;
			case RND_ETAIL:   /* i/o details for hard copy drivers */
				PRT("RND_ETAIL");
				goto bad_opcode;
			case RND_CFGREC:  /* execution time configuration record */
				PRT("RND_CFGREC");
				goto bad_opcode;
			case RND_NEWCFG:  /* new configuration record */
				PRT("RND_NEWCFG");
				goto bad_opcode;
			case RND_CHGCFG:  /* change configuration record */
				PRT("RND_CHGCFG");
				goto bad_opcode;
			case RND_SHOWCFG: /* show configuration record */
				PRT("RND_SHOWCFG");
				goto bad_opcode;
			case RND_FNAME:
				PRT("RND_FNAME");
				goto bad_opcode;
			default:
			bad_opcode:
#ifdef DEBUG
				printf("#%2d @ %06x", opcode, ftell(rf->file));
#endif /* DEBUG */
				rf->lasterr = Err_format;
				goto error;
		}
		if(rf->lasterr < Success)
			goto error;
	}
error:
	return(rf->lasterr);

#undef PRT
}