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


C++ ImageBuf::specmod方法代码示例

本文整理汇总了C++中ImageBuf::specmod方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageBuf::specmod方法的具体用法?C++ ImageBuf::specmod怎么用?C++ ImageBuf::specmod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageBuf的用法示例。


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

示例1: crop

bool 
ImageBufAlgo::cut (ImageBuf &dst, const ImageBuf &src,
                   ROI roi, int nthreads)
{
    bool ok = crop (dst, src, roi, nthreads);
    ASSERT(ok);
    if (! ok)
        return false;
    // Crop did the heavy lifting of copying the roi of pixels from src to
    // dst, but now we need to make it look like we cut that rectangle out
    // and repositioned it at the origin.
    dst.specmod().x = 0;
    dst.specmod().y = 0;
    dst.specmod().z = 0;
    dst.set_roi_full (dst.roi());
    return true;
}
开发者ID:brianhall77,项目名称:oiio,代码行数:17,代码来源:imagebufalgo_copy.cpp

示例2: lock

bool
ImageBufAlgo::capture_image (ImageBuf &dst, int cameranum, TypeDesc convert)
{
#ifdef USE_OPENCV
    IplImage *frame = NULL;
    {
        // This block is mutex-protected
        lock_guard lock (opencv_mutex);
        CvCapture *cvcam = cameras[cameranum];
        if (! cvcam) {
            dst.error ("Could not create a capture camera (OpenCV error)");
            return false;  // failed somehow
        }
        frame = cvQueryFrame (cvcam);
        if (! frame) {
            dst.error ("Could not cvQueryFrame (OpenCV error)");
            return false;  // failed somehow
        }
    }

    time_t now;
    time (&now);
    struct tm tmtime;
    Sysutil::get_local_time (&now, &tmtime);
    std::string datetime = Strutil::format ("%4d:%02d:%02d %02d:%02d:%02d",
                                   tmtime.tm_year+1900, tmtime.tm_mon+1,
                                   tmtime.tm_mday, tmtime.tm_hour,
                                   tmtime.tm_min, tmtime.tm_sec);

    bool ok = ImageBufAlgo::from_IplImage (dst, frame, convert);
    // cvReleaseImage (&frame);   // unnecessary?
    if (ok)
        dst.specmod().attribute ("DateTime", datetime);

    return ok;
#else
    dst.error ("capture_image not supported -- no OpenCV support at compile time");
    return false;
#endif
}
开发者ID:AheadIO,项目名称:oiio,代码行数:40,代码来源:imagebufalgo_opencv.cpp

示例3: u_subimages

bool
ImageRec::read (ReadPolicy readpolicy)
{
    if (elaborated())
        return true;
    static ustring u_subimages("subimages"), u_miplevels("miplevels");
    static boost::regex regex_sha ("SHA-1=[[:xdigit:]]*[ ]*");
    int subimages = 0;
    ustring uname (name());
    if (! m_imagecache->get_image_info (uname, 0, 0, u_subimages,
                                        TypeDesc::TypeInt, &subimages)) {
        error ("file not found: \"%s\"", name());
        return false;  // Image not found
    }
    m_subimages.resize (subimages);
    bool allok = true;
    for (int s = 0;  s < subimages;  ++s) {
        int miplevels = 0;
        m_imagecache->get_image_info (uname, s, 0, u_miplevels,
                                      TypeDesc::TypeInt, &miplevels);
        m_subimages[s].m_miplevels.resize (miplevels);
        m_subimages[s].m_specs.resize (miplevels);
        for (int m = 0;  m < miplevels;  ++m) {
            // Force a read now for reasonable-sized first images in the
            // file. This can greatly speed up the multithread case for
            // tiled images by not having multiple threads working on the
            // same image lock against each other on the file handle.
            // We guess that "reasonable size" is 50 MB, that's enough to
            // hold a 2048x1536 RGBA float image.  Larger things will 
            // simply fall back on ImageCache.
            bool forceread = (s == 0 && m == 0 &&
                              m_imagecache->imagespec(uname,s,m)->image_bytes() < 50*1024*1024);
            ImageBuf *ib = new ImageBuf (name(), m_imagecache);

            // If we were requested to bypass the cache, force a full read.
            if (readpolicy & ReadNoCache)
                forceread = true;

            // Convert to float unless asked to keep native.
            TypeDesc convert = (readpolicy & ReadNative)
                             ? ib->nativespec().format : TypeDesc::FLOAT;
            if (! forceread &&
                convert != TypeDesc::UINT8 && convert != TypeDesc::UINT16 &&
                convert != TypeDesc::HALF &&  convert != TypeDesc::FLOAT) {
                // If we're still trying to use the cache but it doesn't
                // support the native type, force a full read.
                forceread = true;
            }

            bool ok = ib->read (s, m, forceread, convert);
            if (!ok)
                error ("%s", ib->geterror());
            allok &= ok;
            // Remove any existing SHA-1 hash from the spec.
            ib->specmod().erase_attribute ("oiio:SHA-1");
            std::string desc = ib->spec().get_string_attribute ("ImageDescription");
            if (desc.size())
                ib->specmod().attribute ("ImageDescription",
                                         boost::regex_replace (desc, regex_sha, ""));

            m_subimages[s].m_miplevels[m].reset (ib);
            m_subimages[s].m_specs[m] = ib->spec();
            // For ImageRec purposes, we need to restore a few of the
            // native settings.
            const ImageSpec &nativespec (ib->nativespec());
            // m_subimages[s].m_specs[m].format = nativespec.format;
            m_subimages[s].m_specs[m].tile_width  = nativespec.tile_width;
            m_subimages[s].m_specs[m].tile_height = nativespec.tile_height;
            m_subimages[s].m_specs[m].tile_depth  = nativespec.tile_depth;
        }
    }

    m_time = Filesystem::last_write_time (name());
    m_elaborated = true;
    return allok;
}
开发者ID:LumaPictures,项目名称:oiio,代码行数:76,代码来源:imagerec.cpp

示例4: src


//.........这里部分代码省略.........
            outstream << "  Monochrome image detected. Converting to single channel texture.\n";
        }
    }

    // If we've otherwise explicitly requested to write out a
    // specific number of channels, do it.
    if ((nchannels > 0) && (nchannels != src.nchannels())) {
        ImageBuf newsrc(src.name() + ".channels", src.spec());
        ImageBufAlgo::setNumChannels (newsrc, src, nchannels);
        src.copy (newsrc);
        if (verbose) {
            outstream << "  Overriding number of channels to " << nchannels << "\n";
        }
    }
    
    if (shadowmode) {
        // Some special checks for shadow maps
        if (src.spec().nchannels != 1) {
            outstream << "maketx ERROR: shadow maps require 1-channel images,\n"
                      << "\t\"" << filename << "\" is " 
                      << src.spec().nchannels << " channels\n";
            return false;
        }
        // Shadow maps only make sense for floating-point data.
        if (out_dataformat != TypeDesc::FLOAT &&
              out_dataformat != TypeDesc::HALF &&
              out_dataformat != TypeDesc::DOUBLE)
            out_dataformat = TypeDesc::FLOAT;
    }

    if (configspec.get_int_attribute("maketx:set_full_to_pixels")) {
        // User requested that we treat the image as uncropped or not
        // overscan
        ImageSpec &spec (src.specmod());
        spec.full_x = spec.x = 0;
        spec.full_y = spec.y = 0;
        spec.full_z = spec.z = 0;
        spec.full_width = spec.width;
        spec.full_height = spec.height;
        spec.full_depth = spec.depth;
    }

    // Copy the input spec
    const ImageSpec &srcspec = src.spec();
    ImageSpec dstspec = srcspec;
    bool orig_was_volume = srcspec.depth > 1 || srcspec.full_depth > 1;
    bool orig_was_crop = (srcspec.x > srcspec.full_x ||
                          srcspec.y > srcspec.full_y ||
                          srcspec.z > srcspec.full_z ||
                          srcspec.x+srcspec.width < srcspec.full_x+srcspec.full_width ||
                          srcspec.y+srcspec.height < srcspec.full_y+srcspec.full_height ||
                          srcspec.z+srcspec.depth < srcspec.full_z+srcspec.full_depth);
    bool orig_was_overscan = (srcspec.x < srcspec.full_x &&
                              srcspec.y < srcspec.full_y &&
                              srcspec.x+srcspec.width > srcspec.full_x+srcspec.full_width &&
                              srcspec.y+srcspec.height > srcspec.full_y+srcspec.full_height &&
                              (!orig_was_volume || (srcspec.z < srcspec.full_z &&
                                                    srcspec.z+srcspec.depth > srcspec.full_z+srcspec.full_depth)));
    // Make the output not a crop window
    if (orig_was_crop) {
        dstspec.x = 0;
        dstspec.y = 0;
        dstspec.z = 0;
        dstspec.width = srcspec.full_width;
        dstspec.height = srcspec.full_height;
        dstspec.depth = srcspec.full_depth;
开发者ID:mmmovania,项目名称:PVR_Windows,代码行数:67,代码来源:maketexture.cpp

示例5: roi

bool
SMF::saveGrass()
{
	if( verbose )cout << "INFO: saveGrass\n";

	SMFEHGrass *grassHeader = NULL;
	for( unsigned int i = 0; i < extraHeaders.size(); ++i ) {
		if( extraHeaders[ i ]->type == 1 )
			grassHeader = reinterpret_cast<SMFEHGrass *>( extraHeaders[ i ] );
	}
	if( !grassHeader )return true;

	ImageBuf *imageBuf = NULL;
	ROI roi(	0, width * 16,
				0, length * 16,
				0, 1,
				0, 1);
	ImageSpec imageSpec(roi.xend, roi.yend, roi.chend, TypeDesc::UINT8 );

	if( is_smf(grassFile) ) {
		// Load from SMF
		SMF sourcesmf(grassFile);
		imageBuf = sourcesmf.getGrass();
	}
	if( !imageBuf ) {
		// Load image file
		imageBuf = new ImageBuf( grassFile );
		imageBuf->read( 0, 0, false, TypeDesc::UINT8 );
		if( imageBuf->initialized() ) {
			delete imageBuf;
			imageBuf = NULL;
		}
	}
	if( !imageBuf ) {
		// Generate blank
		imageBuf = new ImageBuf( "grass", imageSpec );
	}

	imageSpec = imageBuf->specmod();
	ImageBuf fixBuf;

	// Fix the number of channels
	if( imageSpec.nchannels != roi.chend ) {
		int map[] = {0};
		ImageBufAlgo::channels(fixBuf, *imageBuf, roi.chend, map );
		imageBuf->copy( fixBuf );
		fixBuf.clear();
	}

	// Fix the Dimensions
	if ( imageSpec.width != roi.xend || imageSpec.height != roi.yend ) {
		if( verbose )
			printf( "\tWARNING: %s is (%i,%i), wanted (%i, %i) Resampling.\n",
			typeFile.c_str(), imageSpec.width, imageSpec.height, roi.xend, roi.yend);
		ImageBufAlgo::resample(fixBuf, *imageBuf, false, roi);
		imageBuf->copy( fixBuf );
		fixBuf.clear();		
	}

	unsigned char *pixels = (unsigned char *)imageBuf->localpixels();

	char filename[256];
	sprintf( filename, "%s.smf", outPrefix.c_str() );

	if( verbose )printf( "    Source: %s.\n", grassFile.c_str() );

	fstream smf(filename, ios::binary | ios::in | ios::out);
	smf.seekp(grassHeader->grassPtr);

	smf.write( (char *)pixels, imageBuf->spec().image_bytes() );
	smf.close();
	
	delete imageBuf;
	if( is_smf( grassFile ) ) delete [] pixels;

	return false;
}
开发者ID:pajohns,项目名称:MapConv,代码行数:77,代码来源:smf.cpp

示例6: smf

bool
SMF::saveTilemap()
{
	if( verbose )cout << "INFO: saveTilemap\n";

	char filename[256];
	sprintf( filename, "%s.smf", outPrefix.c_str() );

	fstream smf(filename, ios::binary | ios::in | ios::out);
	smf.seekp(tilesPtr);

	// Tiles Header
	int nTileFiles = smtList.size();
	smf.write( (char *)&nTileFiles, 4);
	smf.write( (char *)&nTiles, 4);
	if(verbose)printf( "    %i tiles referenced in %i files\n", nTiles, nTileFiles );

	// SMT Names
	for(unsigned int i = 0; i < smtList.size(); ++i) {
		if( verbose )printf( "\t%i %s\n", smtTiles[i], smtList[i].c_str() );
		smf.write( (char *)&smtTiles[i], 4);
		smf.write( smtList[i].c_str(), smtList[i].size() +1 );
	}

	// Dimensions of displacement map.
	ImageBuf *imageBuf = NULL;
	ROI roi(	0, width * 16,  // xbegin, xend
				0, length * 16, // ybegin, yend
				0, 1,               // zbegin, zend
				0, 1);              // chbegin, chend
	ImageSpec imageSpec( roi.xend, roi.yend, roi.chend, TypeDesc::UINT );

	if( is_smf(tilemapFile) ) {
		// Load from SMF
		SMF sourcesmf(tilemapFile);
		imageBuf = sourcesmf.getTilemap();
	}
   	if( !imageBuf ) {
		// load image file
		imageBuf = new ImageBuf( tilemapFile );
		imageBuf->read( 0, 0, false, TypeDesc::UINT );
		if( !imageBuf->initialized() ) {
			delete imageBuf;
			imageBuf = NULL;
		}
	}
	if( !imageBuf ) {
		// Generate blank
		imageBuf = new ImageBuf( "tilemap", imageSpec );
		for ( unsigned int i = 0; i < imageSpec.image_pixels(); ++i )
			((unsigned int *)imageBuf->localpixels())[ i ] = i;
	}

	imageSpec = imageBuf->specmod();
	ImageBuf fixBuf;
	// Fix the number of channels
	if( imageSpec.nchannels != roi.chend ) {
		int map[] = {0};
		ImageBufAlgo::channels(fixBuf, *imageBuf, roi.chend, map);
		imageBuf->copy(fixBuf);
		fixBuf.clear();
	}

	// Fix the size
	// FIXME image should never be resized, instead tiling either from an edge or centred.
	if ( imageSpec.width != roi.xend || imageSpec.height != roi.yend ) {
		if( verbose )
			printf( "\tWARNING: %s is (%i,%i), wanted (%i, %i), Resampling.\n",
			tilemapFile.c_str(), imageSpec.width, imageSpec.height, roi.xend, roi.yend );
		ImageBufAlgo::resample(fixBuf, *imageBuf, false, roi);
		imageBuf->copy(fixBuf);
		fixBuf.clear();
	}

	unsigned int *pixels = (unsigned int *)imageBuf->localpixels();

	// write the data to the smf
	smf.write( (char *)pixels, imageBuf->spec().image_bytes() );
	smf.close();

	delete imageBuf;
	if( is_smf( tilemapFile ) ) delete [] pixels;

	return false;
}
开发者ID:pajohns,项目名称:MapConv,代码行数:85,代码来源:smf.cpp


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