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


C++ ossimRefPtr::initialize方法代码示例

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


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

示例1: decodeJpeg

bool ossimCodecFactory::decodeJpeg( const std::vector<ossim_uint8>& in,
                                    ossimRefPtr<ossimImageData>& out ) const
{
   bool result = false;

   // Note: This is public and can be called directly; hence, the signature check
   // Check for jpeg signature:
   if ( in.size() > 3 )
   {
      if ( (in[0] == 0xff) &&
           (in[1] == 0xd8) &&
           (in[2] == 0xff) &&
           (in[3] == 0xe0) )
      {
         /* This struct contains the JPEG decompression parameters and pointers
          * to working space (which is allocated as needed by the JPEG library).
          */
         jpeg_decompress_struct cinfo;
         
         /* We use our private extension JPEG error handler.
          * Note that this struct must live as long as the main JPEG parameter
          * struct, to avoid dangling-pointer problems.
          */
         ossimJpegErrorMgr jerr;
         
         /* Step 1: allocate and initialize JPEG decompression object */
         
         /* We set up the normal JPEG error routines, then override error_exit. */
         cinfo.err = jpeg_std_error(&jerr.pub);
         
         jerr.pub.error_exit = ossimJpegErrorExit;
         
         /* Establish the setjmp return context for my_error_exit to use. */
         if (setjmp(jerr.setjmp_buffer) == 0)
         {
            result = true;
            
            /* Now we can initialize the JPEG decompression object. */
            jpeg_CreateDecompress(&cinfo, JPEG_LIB_VERSION, sizeof(cinfo));
            
            //---
            // Step 2: specify data source.  In this case we will uncompress from
            // memory so we will use "ossimJpegMemorySrc" in place of " jpeg_stdio_src".
            //---
            ossimJpegMemorySrc ( &cinfo,
                                 &(in.front()),
                                 (size_t)(in.size()) );
            
            /* Step 3: read file parameters with jpeg_read_header() */
            jpeg_read_header(&cinfo, TRUE);
            
            /* Step 4: set parameters for decompression */
            
            /* In this example, we don't need to change any of the defaults set by
             * jpeg_read_header(), so we do nothing here.
             */
            
            /* Step 5: Start decompressor */
            jpeg_start_decompress(&cinfo);
            
#if 0       /* Please leave for debug. (drb) */
            if ( traceDebug() )
            {
               ossimNotify(ossimNotifyLevel_DEBUG)
                  << "jpeg cinfo.output_width:  " << cinfo.output_width
                  << "\njpeg cinfo.output_height: " << cinfo.output_height
                  << "\n";
            }
#endif
            
            const ossim_uint32 SAMPLES    = cinfo.output_width;
            const ossim_uint32 LINES      = cinfo.output_height;
            const ossim_uint32 BANDS      = cinfo.output_components;

            if ( out.valid() )
            {
               // This will resize tile if not correct.
               out->setImageRectangleAndBands(
                  ossimIrect(0,0,(ossim_int32)SAMPLES-1,(ossim_int32)LINES-1), BANDS );
            }
            else
            {
               out = new ossimU8ImageData( 0, BANDS, SAMPLES, LINES );
               out->initialize();
            }
            
            // Get pointers to the cache tile buffers.
            std::vector<ossim_uint8*> destinationBuffer(BANDS);
            for (ossim_uint32 band = 0; band < BANDS; ++band)
            {
               destinationBuffer[band] = out->getUcharBuf(band);
            }
            
            std::vector<ossim_uint8> lineBuffer(SAMPLES * cinfo.output_components);
            JSAMPROW jbuf[1];
            jbuf[0] = (JSAMPROW) &(lineBuffer.front());
            
            while (cinfo.output_scanline < LINES)
            {
               // Read a line from the jpeg file.
//.........这里部分代码省略.........
开发者ID:Dukeke,项目名称:ossim,代码行数:101,代码来源:ossimCodecFactory.cpp


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