Ejemplo n.º 1
0
      void write( string const& fn, tImgViewLinear const& img )  {
         try {
            vector<uint8_t> buf;

            if( img.is_mono8() ) {
               buf.resize( offsetpixeldata8 + img.bytes() );
               write_mono8( buf, img.size(), img.rows() );
            }

            if( img.is_rgb() ) {
               uint32_t aligned_line_size = bmp_intern::align32( img.size().x()  * sizeof( tBGR ) );
               uint32_t filesize = header_size +  aligned_line_size  * img.size().y();
               buf.resize( filesize );
               write_rgb( buf, img.size(), img.rows() );
            }

            if( img.is_rgba() ) {
               uint32_t aligned_line_size = bmp_intern::align32( img.size().x()  * sizeof( tBGRA ) );
               uint32_t filesize = header_size +  aligned_line_size  * img.size().y();
               buf.resize( filesize );
               write_rgba( buf, img.size(), img.rows() );
            }

            bin_data::tWriteBin()( fn, buf );
         } catch( bin_data::tBinWriteEx& ) {
            throw  tImgWriteEx( bin_data::msg::write_file( fn ) );
         }
      }
Ejemplo n.º 2
0
      void RGB_LineTo_BGR( tImgViewLinear const& img, size_t y, vector<uint8_t>& v ) {
         tRGB const* source = ( tRGB const* )( img.row_ptr( y ) );
         v.resize( img.pitch() );
         tBGR* target = ( tBGR* )&v[0];
         size_t count = img.size().x();

         while( count-- ) {
            *target++ = *source++;
         }
      }