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


C++ BitmapPtr类代码示例

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


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

示例1: applyInPlace

void FilterWipeBorder::applyInPlace(BitmapPtr pBmp)
{
    AVG_ASSERT(pBmp->getPixelFormat() == I8);
    if (m_NumPixels != 0) {
        int stride = pBmp->getStride();
        unsigned char * pPixels = pBmp->getPixels();
        IntPoint size = pBmp->getSize();
        IntPoint activeSize = pBmp->getSize()-IntPoint(2*m_NumPixels, 2*m_NumPixels);

        unsigned char * pSrcLine = pPixels+stride*m_NumPixels+m_NumPixels;
        for (int y = m_NumPixels-1; y >= 0; --y) {
            memcpy(pPixels+stride*y+m_NumPixels, pSrcLine, activeSize.x);
        }
        pSrcLine = pPixels+stride*(size.y-m_NumPixels-1)+m_NumPixels;
        for (int y = size.y-m_NumPixels; y < size.y; ++y) {
            memcpy(pPixels+stride*y+m_NumPixels, pSrcLine, activeSize.x);
        }

        for (int y = 0; y < size.y; ++y) {
            unsigned char src = *(pPixels+stride*y+m_NumPixels);
            memset(pPixels+stride*y, src, m_NumPixels);
            src = *(pPixels+stride*y+size.x-m_NumPixels-1);
            memset(pPixels+stride*y+size.x-m_NumPixels, src, m_NumPixels);
        }
    }
}
开发者ID:JohnChu,项目名称:libavg,代码行数:26,代码来源:FilterWipeBorder.cpp

示例2: runFilterTests

    void runFilterTests(bool bUseFloat)
    {
        BitmapPtr pBmp;
        GPUBlurFilterPtr pFilter;
        pBmp = loadTestBmp("spike");
        PixelFormat destPF;
        if (bUseFloat) {
            destPF = R32G32B32A32F;
        } else {
            destPF = B8G8R8A8;
        }
        pFilter = GPUBlurFilterPtr(new GPUBlurFilter(pBmp->getSize(), 
                pBmp->getPixelFormat(), destPF, 0.5f, false));
        runImageTest(pBmp, pFilter, 0.5f, "blur05_spike");
        runImageTest(pBmp, pFilter, 1, "blur1_spike");
        runImageTest(pBmp, pFilter, 3, "blur3_spike");

        pBmp = loadTestBmp("flat");
        pFilter = GPUBlurFilterPtr(new GPUBlurFilter(pBmp->getSize(), 
                pBmp->getPixelFormat(), destPF, 5, false));
        runImageTest(pBmp, pFilter, 5, "blur05_flat", true);

        runImageTest("rgb24-64x64", destPF);
        runImageTest("rgb24alpha-64x64", destPF);

    }
开发者ID:derric,项目名称:libavg,代码行数:26,代码来源:testgpu.cpp

示例3: runTestWithBitmap

 void runTestWithBitmap(BitmapPtr pBmp)
 {
     BitmapPtr pDestBmp = FilterResizeBilinear(IntPoint(32,32)).apply(pBmp);
     string sName = string("ResizeBilinearResult")
             +getPixelFormatString(pBmp->getPixelFormat());
     testEqual(*pDestBmp, sName, pBmp->getPixelFormat());
 }
开发者ID:lynxis,项目名称:libavg,代码行数:7,代码来源:testgraphics.cpp

示例4: assertValid

void Image::setFilename(const std::string& sFilename, TextureCompression comp)
{
    assertValid();
    AVG_TRACE(Logger::category::MEMORY, Logger::severity::INFO, "Loading " << sFilename);
    BitmapPtr pBmp = loadBitmap(sFilename);
    if (comp == TEXTURECOMPRESSION_B5G6R5 && pBmp->hasAlpha()) {
        throw Exception(AVG_ERR_UNSUPPORTED, 
                "B5G6R5-compressed textures with an alpha channel are not supported.");
    }
    changeSource(FILE);
    m_pBmp = pBmp;

    m_sFilename = sFilename;

    switch (comp) {
        case TEXTURECOMPRESSION_B5G6R5:
            m_pBmp = BitmapPtr(new Bitmap(pBmp->getSize(), B5G6R5, sFilename));
            if (!BitmapLoader::get()->isBlueFirst()) {
                FilterFlipRGB().applyInPlace(pBmp);
            }
            m_pBmp->copyPixels(*pBmp);
            break;
        case TEXTURECOMPRESSION_NONE:
            break;
        default:
            assert(false);
    }

    if (m_State == GPU) {
        m_pSurface->destroy();
        setupSurface();
    }
    assertValid();
}
开发者ID:dboesel,项目名称:libavg,代码行数:34,代码来源:Image.cpp

示例5: runImageTest

 void runImageTest(const string& sFName, PixelFormat destPF)
 {
     BitmapPtr pBmp = loadTestBmp(sFName);
     GPUBlurFilterPtr pFilter(new GPUBlurFilter(pBmp->getSize(), 
             pBmp->getPixelFormat(), destPF, 2, false));
     runImageTest(pBmp, pFilter, 2, string("blur_")+sFName, true);
 }
开发者ID:derric,项目名称:libavg,代码行数:7,代码来源:testgpu.cpp

示例6: runTests

    void runTests()
    {
        BitmapPtr pBmp = loadTestBmp("chromakey");
        BitmapPtr pDestBmp;
        GPUChromaKeyFilter filter(pBmp->getSize());
        for (int erosion = 0; erosion < 3; ++erosion) {
            filter.setParams(Pixel32(0,255,0), 0.1, 0.2, 0.1, 0.1, erosion, 0);
            pDestBmp = filter.apply(pBmp);
            testEqual(*pDestBmp, "ChromaKeyResult"+toString(erosion), B8G8R8A8, 0.3, 
                    0.7);
        }
        filter.setParams(Pixel32(0,255,0), 0.0, 0.0, 0.0, 0.0, 0, 0.1);
        pDestBmp = filter.apply(pBmp);
        testEqual(*pDestBmp, "ChromaKeySpillResult1", B8G8R8A8, 0.3, 0.7);
        filter.setParams(Pixel32(0,255,0), 0.1, 0.1, 0.1, 0.0, 0, 0.1);
        pDestBmp = filter.apply(pBmp);
        testEqual(*pDestBmp, "ChromaKeySpillResult2", B8G8R8A8, 0.3, 0.7);
        filter.setParams(Pixel32(0,255,0), 0.1, 0.1, 0.1, 0.0, 0, 0.2);
        pDestBmp = filter.apply(pBmp);
        testEqual(*pDestBmp, "ChromaKeySpillResult3", B8G8R8A8, 0.3, 0.7);

        pBmp = loadTestBmp("chromakey-median");
        filter.setParams(Pixel32(0,255,0), 0.1, 0.1, 0.1, 0.0, 0, 0.0);
        pDestBmp = filter.apply(pBmp);
        testEqual(*pDestBmp, "ChromaKeyMedianResult", B8G8R8A8, 1, 6);
    }
开发者ID:derric,项目名称:libavg,代码行数:26,代码来源:testgpu.cpp

示例7: catch

void GraphicsTest::testEqual(Bitmap& resultBmp, Bitmap& baselineBmp, 
        const string& sFName, float maxAverage, float maxStdDev)
{
    BitmapPtr pDiffBmp;
    try {
        pDiffBmp = resultBmp.subtract(baselineBmp);
    } catch (Exception& e) {
        TEST_FAILED("Error: " << e.getStr() << ". File: '" << sFName << "'.");
        string sResultName = "resultimages/"+sFName;
        resultBmp.save(sResultName+".png");
        baselineBmp.save(sResultName+"_baseline.png");
    }
    if (pDiffBmp) {
        float average = pDiffBmp->getAvg();
        float stdDev = pDiffBmp->getStdDev();
        if (average > maxAverage || stdDev > maxStdDev) {
            TEST_FAILED("Error: Decoded image differs from baseline '" << 
                    sFName << "'. average=" << average << ", stdDev=" << stdDev);
    //        resultBmp.dump();
    //        baselineBmp.dump();
            string sResultName = "resultimages/"+sFName;
            resultBmp.save(sResultName+".png");
            baselineBmp.save(sResultName+"_baseline.png");
            BitmapPtr pDiffBmp = resultBmp.subtract(baselineBmp);
            pDiffBmp->save(sResultName+"_diff.png");
        }
    }
}
开发者ID:JohnChu,项目名称:libavg,代码行数:28,代码来源:GraphicsTest.cpp

示例8: runMipmapTest

    void runMipmapTest(OGLMemoryMode memoryMode, const string& sFName)
    {
        cerr << "    Testing mipmap support, " << sFName << ", " << 
                oglMemoryMode2String(memoryMode) << endl;
        BitmapPtr pOrigBmp = loadTestBmp(sFName);
        GLContextManager* pCM = GLContextManager::get();
        MCTexturePtr pTex = pCM->createTextureFromBmp(pOrigBmp, true);
        pCM->uploadData();
        pTex->generateMipmaps();

        if (GLContext::getCurrent()->isGLES()) {
            // GLES doesn't support attaching texture mipmap levels other than 0 to
            // FBOs, so moveTextureToBmp() will fail. Skip result image comparison.
            return;
        }
        BitmapPtr pResultBmp = pTex->moveTextureToBmp(1);
        IntPoint newSize(pOrigBmp->getSize()/2);
        TEST(pResultBmp->getSize() == newSize);
        FilterResizeBilinear resizer(newSize);
        BitmapPtr pBaselineBmp = resizer.apply(pOrigBmp);
        string sName;
        if (memoryMode == MM_PBO) {
            sName = "pbo-mipmap";
        } else {
            sName = "ogl-mipmap";
        }
        testEqual(*pResultBmp, *pBaselineBmp, sName, 7, 15);
    }
开发者ID:derric,项目名称:libavg,代码行数:28,代码来源:testgpu.cpp

示例9: dc

void CChildView::OnPaint() 
{
   CPaintDC dc(this); // device context for painting

   // If the unbounded_buffer object contains a Bitmap object, 
   // draw the image to the client area.
   BitmapPtr pBitmap;
   if (try_receive(m_MandelbrotImages, pBitmap))
   {
      if (pBitmap != NULL)
      {
         // Draw the bitmap to the client area.
         Graphics g(dc);
         g.DrawImage(pBitmap.get(), 0, 0);
      }
   }
   // Draw the image on a worker thread if the image is not available.
   else
   {
      RECT rc;
      GetClientRect(&rc);
      m_DrawingTasks.run([rc,this]() {
         DrawMandelbrot(BitmapPtr(new Bitmap(rc.right, rc.bottom)));
      });
   }
}
开发者ID:terryjintry,项目名称:OLSource1,代码行数:26,代码来源:walkthrough--removing-work-from-a-user-interface-thread_13.cpp

示例10: runTests

 void runTests()
 {
     BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(16,16), I8));
     FilterFill<Pixel8>(0).applyInPlace(pBmp);
     *(pBmp->getPixels()+pBmp->getStride()*7+7) = 255;
     BitmapPtr pDestBmp = FilterBlur().apply(pBmp);
     testEqual(*pDestBmp, "BlurResult", I8);
 }
开发者ID:lynxis,项目名称:libavg,代码行数:8,代码来源:testgraphics.cpp

示例11: runSaveTest

 void runSaveTest(PixelFormat pf)
 {
     cerr << "    Testing save for " << pf << endl;
     BitmapPtr pBmp = initBmp(pf);
     pBmp->save("test.png");
     BitmapPtr pLoadedBmp = loadBitmap("test.png");
     ::remove("test.png");
     testEqual(*pLoadedBmp, *pBmp, "BmpSave");
 }
开发者ID:lynxis,项目名称:libavg,代码行数:9,代码来源:testgraphics.cpp

示例12: convertRGBImage

void VideoWriterThread::convertRGBImage(BitmapPtr pSrcBmp)
{
    ScopeTimer timer(ProfilingZoneConvertImage);
    unsigned char* rgbData[3] = {pSrcBmp->getPixels(), NULL, NULL};
    int rgbStride[3] = {pSrcBmp->getLineLen(), 0, 0};

    sws_scale(m_pFrameConversionContext, rgbData, rgbStride,
              0, m_Size.y, m_pConvertedFrame->data, m_pConvertedFrame->linesize);
}
开发者ID:pararthshah,项目名称:libavg-vaapi,代码行数:9,代码来源:VideoWriterThread.cpp

示例13: runImageTests

 void runImageTests(const string& sFName, PixelFormat pf)
 {
     cerr << "    Testing " << sFName << endl;
     BitmapPtr pBmp = loadTestBmp(sFName, pf);
     GPUBandpassFilter f(pBmp->getSize(), pf, 0.5, 1.5, 1, false);
     BitmapPtr pDestBmp = f.apply(pBmp);
     TEST(fabs(pDestBmp->getAvg() -128) < 0.06);
     testEqual(*pDestBmp, "bandpass_"+sFName, pf, 0.2, 0.5);
     TEST(pDestBmp->getPixelFormat() == pf);
 }
开发者ID:derric,项目名称:libavg,代码行数:10,代码来源:testgpu.cpp

示例14: initBmp

 void initBmp(BitmapPtr pBmp) 
 {
     PIXEL * pPixels = (PIXEL *)(pBmp->getPixels());
     PIXEL color = PIXEL(0,0,0);
     FilterFill<PIXEL>(color).applyInPlace(pBmp);
     pPixels[0] = PIXEL(1,0,0);
     pPixels[3] = PIXEL(2,0,0);
     pPixels = (PIXEL*)((char *)pPixels+3*pBmp->getStride());
     pPixels[0] = PIXEL(0,0,3);
     pPixels[3] = PIXEL(0,0,4);
 }
开发者ID:lynxis,项目名称:libavg,代码行数:11,代码来源:testgraphics.cpp

示例15:

Sprite::Sprite(BitmapPtr pBitmap)
{
	m_pBitmap = pBitmap;
	SetRect(&m_rcPosition, 0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
	m_ptVelocity.x = m_ptVelocity.y = 0;
	m_iZOrder = 0;
	SetRect(&m_rcBounds, 0, 0, 640, 480);
	m_baBoundsAction = BA_STOP;
	m_bHidden = FALSE;
	CalcCollisionRec();
}
开发者ID:warrior2005,项目名称:WowLink,代码行数:11,代码来源:Sprite.cpp


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