当前位置: 首页>>代码示例>>C++>>正文


C++ TIFFReadScanline函数代码示例

本文整理汇总了C++中TIFFReadScanline函数的典型用法代码示例。如果您正苦于以下问题:C++ TIFFReadScanline函数的具体用法?C++ TIFFReadScanline怎么用?C++ TIFFReadScanline使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TIFFReadScanline函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_tiff_greyscale_scanline

static int read_tiff_greyscale_scanline (TIFF *tiff, tiff_format_t format, tiff_data_config_t *data_config,
                                  uint32 row, uint32 scanlineSize, int sample_count, int band,
                                  tdata_t *tif_buf)
{
  switch (format) {
    case SCANLINE_TIFF:
      if (data_config->planar_config == PLANARCONFIG_CONTIG) {
        TIFFReadScanline(tiff, tif_buf, row, 0);
      }
      else {
        TIFFReadScanline(tiff, tif_buf, row, band);
      }
      break;
    case STRIP_TIFF:
      ReadScanline_from_TIFF_Strip(tiff, tif_buf, row, band);
      break;
    case TILED_TIFF:
      ReadScanline_from_TIFF_TileRow(tiff, tif_buf, row, band);
      break;
    default:
      // This code should never execute
      return FALSE;
      break;
  }

  return TRUE;
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:27,代码来源:tiff_util.c

示例2: tiff_read

static void
tiff_read(unsigned char *dst, unsigned int line, void *data)
{
    struct tiff_state *h = data;
    int s,on,off;

    if (h->image) {
	/* loaded whole image using TIFFReadRGBAImage() */
	uint32 *row = h->image + h->width * (h->height - line -1);
	load_rgba(dst,(unsigned char*)row,h->width);
	return;
    }
    
    if (h->config == PLANARCONFIG_CONTIG) {
	TIFFReadScanline(h->tif, h->row, line, 0);
    } else if (h->config == PLANARCONFIG_SEPARATE) {
	for (s = 0; s < h->nsamples; s++)
	    TIFFReadScanline(h->tif, h->row, line, s);
    }

    switch (h->nsamples) {
    case 1:
	if (1 == h->depth) {
	    /* black/white */
	    on = 0, off = 0;
	    if (PHOTOMETRIC_MINISWHITE == h->photometric)
		on = 0, off = 255;
	    if (PHOTOMETRIC_MINISBLACK == h->photometric)
		on = 255, off = 0;
#if 0
	    /* Huh?  Does TIFFReadScanline handle this already ??? */
	    if (FILLORDER_MSB2LSB == h->fillorder)
		load_bits_msb(dst,(unsigned char*)(h->row),h->width,on,off);
	    else
		load_bits_lsb(dst,(unsigned char*)(h->row),h->width,on,off);
#else
	    load_bits_msb(dst,(unsigned char*)(h->row),h->width,on,off);
#endif
	} else {
	    /* grayscaled */
	    load_gray(dst,(unsigned char*)(h->row),h->width);
	}
	break;
    case 3:
	/* rgb */
	memcpy(dst,h->row,3*h->width);
	break;
    case 4:
	/* rgb+alpha */
	load_rgba(dst,(unsigned char*)(h->row),h->width);
	break;
    }
}
开发者ID:ghtyrant,项目名称:fbida,代码行数:53,代码来源:read-tiff.c

示例3: read_tiff_rgb_scanline

static int read_tiff_rgb_scanline (TIFF *tiff, tiff_format_t format, tiff_data_config_t *data_config,
                            uint32 row, uint32 scanlineSize, int sample_count,
                            int band_r, int band_g, int band_b,
                            tdata_t *rtif_buf, tdata_t *gtif_buf, tdata_t *btif_buf)
{
  // NOTE: num_bands may not be greater than 1 ...open_tiff_data() decides what to
  // assign into band_r, band_g, and band_b.  They may all be the same, all different,
  // or some combination depending on what the GUI asked for versus what was available
  // in the TIFF file.  All code called after open_tiff_data() should assume that if
  // RGB is desired that the 3 band assignments are taken care of appropriate to the
  // situation.
  int num_bands = data_config->samples_per_pixel;
  if (num_bands < 1 ||
      band_r < 0 || band_r > num_bands - 1 ||
      band_g < 0 || band_g > num_bands - 1 ||
      band_b < 0 || band_b > num_bands - 1)
  {
    return FALSE;
  }
  switch (format) {
    case SCANLINE_TIFF:
      if (data_config->planar_config == PLANARCONFIG_CONTIG) {
        ReadScanline_from_ContiguousRGB_TIFF(tiff, row, sample_count,
                                             band_r, band_g, band_b,
                                             rtif_buf, gtif_buf, btif_buf);
      }
      else {
        TIFFReadScanline(tiff, rtif_buf, row, band_r); // Red band
        TIFFReadScanline(tiff, gtif_buf, row, band_g); // Green band
        TIFFReadScanline(tiff, btif_buf, row, band_b); // Blue band
      }
      break;
    case STRIP_TIFF:
      ReadScanline_from_TIFF_Strip(tiff, rtif_buf, row, band_r); // Red band
      ReadScanline_from_TIFF_Strip(tiff, gtif_buf, row, band_g); // Green band
      ReadScanline_from_TIFF_Strip(tiff, btif_buf, row, band_b); // Blue band
      break;
    case TILED_TIFF:
      ReadScanline_from_TIFF_TileRow(tiff, rtif_buf, row, band_r); // Red band
      ReadScanline_from_TIFF_TileRow(tiff, gtif_buf, row, band_g); // Green band
      ReadScanline_from_TIFF_TileRow(tiff, btif_buf, row, band_b); // Blue band
      break;
    default:
      // This code should never execute
      return FALSE;
      break;
  }

  return TRUE;
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:50,代码来源:tiff_util.c

示例4: tif_load

/* tif load function */
int tif_load(uint16 *image)
{
	int r, c;	// height index, width index
	uint16 s;
	uint16 *scanline;
	long int image_offset;
	
	if((scanline = (uint16 *)_TIFFmalloc(info->line_size)) == NULL){
		fprintf(stderr, "Could not allocate enough memory for the scan buffer!\n");
		exit(42);
	}
	
	image_offset = 0;	
	printf("-- loading tif files ... \n");		

	TIFFSetDirectory(tif, 0);

	do {
		if (info->config == PLANARCONFIG_CONTIG){
			for(r = 0; r < info->length; r++){
				TIFFReadScanline(tif, scanline, r, s);

				for(c = 0; c < info->width; c++)
				{		
					image[image_offset + info->width * r + c] = *(scanline + c);
				}

			}
		} else if (info->config == PLANARCONFIG_SEPARATE){
			for(s = 0; s < info->spp; s++){
				for(r = 0; r < info->length; r++){
					TIFFReadScanline(tif, scanline, r, s);
					for(c = 0; c < info->width; c++)
					{
						image[image_offset + info->width * r + c] = *(scanline + c);
					}

				}
			}
		}
		image_offset += info->image_size/sizeof(uint16);
	} while (TIFFReadDirectory(tif));

	_TIFFfree(scanline);
	
	TIFFClose(tif);

	return 0;
}
开发者ID:sufengniu,项目名称:X_RAY,代码行数:50,代码来源:tif.c

示例5: read_data

static void
read_data (UfoTiffReaderPrivate *priv,
           UfoBuffer *buffer,
           UfoRequisition *requisition,
           guint16 bits,
           guint roi_y,
           guint roi_height,
           guint roi_step)
{
    gchar *dst;
    gsize step;
    gsize offset;

    step = requisition->dims[0] * bits / 8;
    dst = (gchar *) ufo_buffer_get_host_array (buffer, NULL);
    offset = 0;

    if (requisition->n_dims == 3) {
        /* RGB data */
        gchar *src;
        gsize plane_size;

        plane_size = step * roi_height / roi_step;
        src = g_new0 (gchar, step * 3);

        for (guint i = roi_y; i < roi_y + roi_height; i += roi_step) {
            guint xd = 0;
            guint xs = 0;

            TIFFReadScanline (priv->tiff, src, i, 0);

            for (; xd < requisition->dims[0]; xd += 1, xs += 3) {
                dst[offset + xd] = src[xs];
                dst[offset + plane_size + xd] = src[xs + 1];
                dst[offset + 2 * plane_size + xd] = src[xs + 2];
            }

            offset += step;
        }

        g_free (src);
    }
    else {
        for (guint i = roi_y; i < roi_y + roi_height; i += roi_step) {
            TIFFReadScanline (priv->tiff, dst + offset, i, 0);
            offset += step;
        }
    }
}
开发者ID:ufo-kit,项目名称:ufo-filters,代码行数:49,代码来源:ufo-tiff-reader.c

示例6: _read_planar_16

static inline int _read_planar_16(tiff_t *t)
{
  for(uint32_t row = 0; row < t->height; row++)
  {
    uint16_t *in = ((uint16_t *)t->buf);
    float *out = ((float *)t->mipbuf) + (size_t)4 * row * t->width;

    /* read scanline */
    if(TIFFReadScanline(t->tiff, in, row, 0) == -1) return -1;

    for(uint32_t i = 0; i < t->width; i++, in += t->spp, out += 4)
    {
      out[0] = ((float)in[0]) * (1.0f / 65535.0f);

      if(t->spp == 1)
      {
        out[1] = out[2] = out[0];
      }
      else
      {
        out[1] = ((float)in[1]) * (1.0f / 65535.0f);
        out[2] = ((float)in[2]) * (1.0f / 65535.0f);
      }

      out[3] = 0;
    }
  }

  return 1;
}
开发者ID:supertobi,项目名称:darktable,代码行数:30,代码来源:imageio_tiff.c

示例7: read_scanlines

static void read_scanlines(struct tiff_tile *tout, TIFF *tif)
{
	// read all file info
	struct tiff_info tinfo[1];
	get_tiff_info(tinfo, tif);

	// fill-in output information
	tout->w = tinfo->w;
	tout->h = tinfo->h;
	tout->bps = tinfo->bps;
	tout->fmt = tinfo->fmt;
	tout->spp = tinfo->spp;
	tout->broken = false;

	// define useful constants
	int pixel_size = tinfo->spp * tinfo->bps/8;
	int output_size = tout->w * tout->h * pixel_size;

	// allocate space for output data
	tout->data = xmalloc(output_size);

	// copy scanlines
	int scanline_size = TIFFScanlineSize(tif);
	assert(scanline_size == tinfo->w * pixel_size);
	for (int j = 0; j < tinfo->h; j++)
	{
		uint8_t *buf = tout->data + scanline_size*j;
		int r = TIFFReadScanline(tif, buf, j, 0);
		if (r < 0) fail("could not read scanline %d", j);
	}
}
开发者ID:cpalmann,项目名称:s2p,代码行数:31,代码来源:tiff_octaves_rw.c

示例8: read_tiff_image

void read_tiff_image(TIFF* tif, IMAGE* image) {
  tdata_t buf;
  uint32 image_width, image_height;
  uint16 photometric;
  inT16 bpp;
  inT16 samples_per_pixel = 0;
  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &image_width);
  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &image_height);
  TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bpp);
  TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
  TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric);
  if (samples_per_pixel > 1)
    bpp *= samples_per_pixel;
  // Tesseract's internal representation is 0-is-black,
  // so if the photometric is 1 (min is black) then high-valued pixels
  // are 1 (white), otherwise they are 0 (black).
  uinT8 high_value = photometric == 1;
  image->create(image_width, image_height, bpp);
  IMAGELINE line;
  line.init(image_width);

  buf = _TIFFmalloc(TIFFScanlineSize(tif));
  int bytes_per_line = (image_width*bpp + 7)/8;
  uinT8* dest_buf = image->get_buffer();
  // This will go badly wrong with one of the more exotic tiff formats,
  // but the majority will work OK.
  for (int y = 0; y < image_height; ++y) {
    TIFFReadScanline(tif, buf, y);
    memcpy(dest_buf, buf, bytes_per_line);
    dest_buf += bytes_per_line;
  }
  if (high_value == 0)
    invert_image(image);
  _TIFFfree(buf);
}
开发者ID:GaryShearer,项目名称:BasicOCR,代码行数:35,代码来源:tessedit.cpp

示例9: _declspec

_declspec (dllexport) int readGreyImage(TIFF* tif,              // TIFF handle - IN 
  const int directory,   // page ordinal number - IN
  uint8_t* buffer)      // OUT, caller allocates memory
{
  TIFFSetDirectory(tif, directory);
  int err = 0;
  uint32_t w, h, s;
  size_t npixels;

  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
  TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
  s = TIFFScanlineSize(tif);
  //TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, bits);
  npixels = w * h;
  int numToRead = npixels / s;
  for (int r = 0; r < numToRead; r++)
  {
    err = TIFFReadScanline(tif, buffer+r*s, r);
    if (err != 1)
    {
      return -1*r;
    }
  }
  return err;
}
开发者ID:sandlerr,项目名称:imagerecon,代码行数:25,代码来源:labviewdll.cpp

示例10: TIFFSetWarningHandler

void *image_read_tif(const char *name, int *w, int *h, int *c, int *b, int n)
{
    TIFF *T = 0;
    void *p = 0;

    TIFFSetWarningHandler(0);

    if ((T = TIFFOpen(name, "r")))
    {
        if ((n == 0) || TIFFSetDirectory(T, n))
        {
            uint32 i, s = (uint32) TIFFScanlineSize(T);
            uint32 W, H;
            uint16 B, C;

            TIFFGetField(T, TIFFTAG_IMAGEWIDTH,      &W);
            TIFFGetField(T, TIFFTAG_IMAGELENGTH,     &H);
            TIFFGetField(T, TIFFTAG_BITSPERSAMPLE,   &B);
            TIFFGetField(T, TIFFTAG_SAMPLESPERPIXEL, &C);

            if ((p = malloc(H * s)))
            {
                for (i = 0; i < H; ++i)
                    TIFFReadScanline(T, (uint8 *) p + i * s, i, 0);

                *w = (int) W;
                *h = (int) H;
                *b = (int) B / 8;
                *c = (int) C;
            }
        }
        TIFFClose(T);
    }
    return p;
}
开发者ID:treeffle,项目名称:CSC4356,代码行数:35,代码来源:image.c

示例11: tif_read_scanline

/*
	スキャンラインフォーマット画像の、
	1スキャンライン分のみ、読み込む
	なお、
	Compression algorithm does not support random access.
	つまり、圧縮フォーマットの場合は、
	ゼロライン(yy=0)から順にとらないと読み込めない
	vp_scanlineは読み込み始める場所へのポインター
*/
int tif_read_scanline( TIF_IMAGE_RW *tp_read, uint32_t yy, void *vp_scanline )
{
	if (NULL == tp_read ) {
		pri_funct_err_bttvr(
			"Error : bad argument, tp_read is NULL." );
		return NG;
	}
	if (NULL == tp_read->tp_tiff_head ) {
		pri_funct_err_bttvr(
	"Error : bad argument, tp_read->tp_tiff_head is NULL." );
		return NG;
	}
	if (NULL == vp_scanline ) {
		pri_funct_err_bttvr(
			"Error : bad argument, vp_scanline is NULL." );
		return NG;
	}

	if ( -1 == TIFFReadScanline(
		tp_read->tp_tiff_head,
		/*(tdata_t)*/vp_scanline, yy, (tsample_t)0
	) ) {
		pri_funct_err_bttvr(
	  "Error : TIFFReadScanline(%p,%p,%u,0) returns minus.",
			tp_read->tp_tiff_head, vp_scanline, yy );
		return NG;
	}
	return OK;
}
开发者ID:OriginalAdric,项目名称:GTS,代码行数:38,代码来源:tif_read_scanline.c

示例12: TIFFScanlineSize

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int TiffUtilities::read16BitImage(TIFF* in, TiffImage* data)
{
  int err = 0;
  int bytesPerScanLine = TIFFScanlineSize(in);
  // Allocate a buffer to read each scan line into
  tdata_t scanBuffer = (unsigned char*)(malloc(bytesPerScanLine));

  // Allocate the image buffer
  data->imageData = malloc(data->width * data->height * 2);
  unsigned short* dest = static_cast<unsigned short*>(data->imageData);


  //Loop over each row (scanline) and read the data, then copy the data into the
  // image buffer. We do it this way because of alignment issues that crop up in
  // some tiff images. If the scanline size is an odd number tiff will round up
  // to the next multiple of 4 bytes.
  for (int i = 0; i < data->height; ++i)
  {
    err = TIFFReadScanline(in, scanBuffer, i);
    ::memcpy(dest, scanBuffer, bytesPerScanLine);
    dest = dest + data->width;
  }

  // Free the memory that was allocated
  free(scanBuffer);
  return err;

}
开发者ID:chongbingbao,项目名称:DREAM3D,代码行数:31,代码来源:TiffUtilities.cpp

示例13: TIFFGetField

/**
 * Read a TIFF float image.
 */
static float *readTIFF(TIFF * tif, size_t * nx, size_t * ny)
{
    uint32 w = 0, h = 0, i;
    uint16 spp = 0, bps = 0, fmt = 0;
    float *data, *line;

    TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
    TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
    TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &spp);
    TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bps);
    TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &fmt);
    if (spp != 1 || bps != (uint16) sizeof(float) * 8
            || fmt != SAMPLEFORMAT_IEEEFP)
        return NULL;

    assert((size_t) TIFFScanlineSize(tif) == w * sizeof(float));
    data = (float *) malloc(w * h * sizeof(float));
    *nx = (size_t) w;
    *ny = (size_t) h;
    for (i = 0; i < h; i++) {
        line = data + i * w;
        if (TIFFReadScanline(tif, line, i, 0) < 0) {
            fprintf(stderr, "readTIFF: error reading row %u\n", i);
            free(data);
            return NULL;
        }
    }

    return data;
}
开发者ID:Algomorph,项目名称:disparity-with-graph-cuts,代码行数:33,代码来源:io_tiff.c

示例14: cpData

static int cpData(TIFF *in, TIFF *out, const uint32_t nrow) {
	tsize_t scSize = TIFFScanlineSize(in);
	tdata_t buf = _TIFFmalloc(scSize);
	if (!buf)
		return 0;
	_TIFFmemset(buf, 0, scSize);
	for (uint32_t irow = 0; irow < nrow; irow++) {
        try {
    		if (TIFFReadScanline(in, buf, irow, 0) < 0) {
    			throw -1;
    		}
    		if (TIFFWriteScanline(out, buf, irow, 0) < 0) {
    			throw -2;
    		}
        } catch (int err) {
            if (err == -1) {
                std::cerr << "Cannot read scanline " << irow;
                std::cerr << " from " << TIFFFileName(in) << std::endl;
            } else if (err == -2) {
                std::cerr << "Cannot write scanline " << irow;
                std::cerr << " to " << TIFFFileName(out) << std::endl;
            } else {
                std::cerr << "Unknown error during row copy" << std::endl;
            }
            _TIFFfree(buf);
            return 0;
        }
	}
	_TIFFfree(buf);
	return 1;
}
开发者ID:liuyenting,项目名称:python-tiff-transpose,代码行数:31,代码来源:tiff.cpp

示例15: read_64_bit_data

static void
read_64_bit_data (UfoTiffReaderPrivate *priv,
                  UfoBuffer *buffer,
                  UfoRequisition *requisition,
                  guint roi_y,
                  guint roi_height,
                  guint roi_step)
{
    gdouble *src;
    gfloat *dst;

    dst = ufo_buffer_get_host_array (buffer, NULL);
    src = g_new0 (gdouble, requisition->dims[0]);

    for (guint i = roi_y; i < roi_y + roi_height; i += roi_step) {
        TIFFReadScanline (priv->tiff, src, i, 0);

        for (guint j = 0; j < requisition->dims[0]; j++)
            dst[j] = (gfloat) src[j];

        dst += requisition->dims[0];
    }

    g_free (src);
}
开发者ID:ufo-kit,项目名称:ufo-filters,代码行数:25,代码来源:ufo-tiff-reader.c


注:本文中的TIFFReadScanline函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。