Exemplo n.º 1
0
void
FreeImageStack::loadImage(unsigned int iSlice, npp::ImageNPP_8u_C1 & rImage)
const
{
    NPP_ASSERT_MSG(iSlice < slices(), "Slice index exceeded number of slices in stack.");
    FIBITMAP * pBitmap = FreeImage_LockPage(pImageStack_, iSlice);
    NPP_ASSERT_NOT_NULL(pBitmap);
            // make sure this is an 8-bit single channel image
    NPP_DEBUG_ASSERT(FreeImage_GetColorType(pBitmap) == FIC_MINISBLACK);
    NPP_DEBUG_ASSERT(FreeImage_GetBPP(pBitmap) == 8);
    
    NPP_DEBUG_ASSERT(FreeImage_GetWidth(pBitmap) == nWidth_);
    NPP_DEBUG_ASSERT(FreeImage_GetHeight(pBitmap) == nHeight_);
    unsigned int    nSrcPitch = FreeImage_GetPitch(pBitmap);
    unsigned char * pSrcData  = FreeImage_GetBits(pBitmap);
    
    if (rImage.width() == nWidth_ && rImage.height() == nHeight_)
    {
        NPP_CHECK_CUDA(cudaMemcpy2D(rImage.data(), rImage.pitch(), pSrcData, nSrcPitch, 
                                    nWidth_, nHeight_, cudaMemcpyHostToDevice));
    }
    else
    {
                // create new NPP image
        npp::ImageNPP_8u_C1 oImage(nWidth_, nHeight_);
                // transfer slice data into new device image
        NPP_CHECK_CUDA(cudaMemcpy2D(oImage.data(), oImage.pitch(), pSrcData, nSrcPitch, 
                                    nWidth_, nHeight_, cudaMemcpyHostToDevice));
                // swap the result image with the reference passed into this method
        rImage.swap(oImage);
    }
                // release locked slice
    FreeImage_UnlockPage(pImageStack_, pBitmap, FALSE);
}
Exemplo n.º 2
0
int main(int   argc,     // Command line argument count
         char *argv[])   // Pointers to command line args
{
    
    DirectBeamInfo      oBeamInfo;

    Cimage      oImage(argv[1]);
    oBeamInfo.Evaluate(&oImage,
                       -1,
                       -1);

    
    
    return  0;
}
Exemplo n.º 3
0
    /// Load a gray-scale image from disk.
    void 
    loadImage(const std::string & rFileName, ImageCPU_8u_C1 & rImage)
    {
	            // set your own FreeImage error handler
	    FreeImage_SetOutputMessage(FreeImageErrorHandler);

        FREE_IMAGE_FORMAT eFormat = FreeImage_GetFileType(rFileName.c_str());
                // no signature? try to guess the file format from the file extension
        if (eFormat == FIF_UNKNOWN)
            eFormat = FreeImage_GetFIFFromFilename(rFileName.c_str());
        NPP_ASSERT(eFormat != FIF_UNKNOWN);
                // check that the plugin has reading capabilities ...
        FIBITMAP * pBitmap;
        if (FreeImage_FIFSupportsReading(eFormat)) 
            pBitmap = FreeImage_Load(eFormat, rFileName.c_str());
        NPP_ASSERT(pBitmap != 0);
                // make sure this is an 8-bit single channel image
        NPP_ASSERT(FreeImage_GetColorType(pBitmap) == FIC_MINISBLACK);
        NPP_ASSERT(FreeImage_GetBPP(pBitmap) == 8);
        
                // create an ImageCPU to receive the loaded image data
        ImageCPU_8u_C1 oImage(FreeImage_GetWidth(pBitmap), FreeImage_GetHeight(pBitmap));
        
                // Copy the FreeImage data into the new ImageCPU
        unsigned int nSrcPitch = FreeImage_GetPitch(pBitmap);
        const Npp8u * pSrcLine = FreeImage_GetBits(pBitmap) + nSrcPitch * (FreeImage_GetHeight(pBitmap) -1);
        Npp8u * pDstLine = oImage.data();
        unsigned int nDstPitch = oImage.pitch();
        for (size_t iLine = 0; iLine < oImage.height(); ++iLine)
        {
            memcpy(pDstLine, pSrcLine, oImage.width() * sizeof(Npp8u));
            pSrcLine -= nSrcPitch;
            pDstLine += nDstPitch;
        }
        
                // swap the user given image with our result image, effecively
                // moving our newly loaded image data into the user provided shell
        oImage.swap(rImage);
    }
Exemplo n.º 4
0
GraphiItemCtrl::GraphiItemCtrl(QWidget *parent)
	:QWidget(parent)
{
	setupUi(this);
	d_Scale = 1;
	i_LastItemKey = -1;
	i_ActivityMode = ACTIVTITY_MODE_SELECT;
	
	QPixmap oImage(":/ImageTool/Resources/Penguins.jpg");
	o_OrigianlRect = oImage.rect();
	p_GraphicView->setSceneRect(oImage.rect());
	p_GraphicView->setMaximumHeight(oImage.height());
	p_GraphicView->setMaximumWidth(oImage.width());
	
	p_Image = new GraphicImage(oImage,this);
	p_GraphicView->setScene(&o_ItemScene);
	
	o_ItemScene.addItem(p_Image);

	o_MainActivity.addButton(rdo_Draw);
	o_MainActivity.addButton(rdo_Erase);
	o_MainActivity.addButton(rdo_Select);
	o_MainActivity.addButton(rdo_Point);

	o_DrawType.addButton(btn_Line);
	o_DrawType.addButton(btn_Rectangle);
	o_DrawType.addButton(btn_Elipse);

	o_Zooming.addButton(btn_ZoomIn);
	o_Zooming.addButton(btn_ZoomOut);

	b_InitDraw = false;
	i_CurrentType = 6;

	lbl_SelColor->setBackgroundRole(QPalette::Background);
	lbl_SelColor->setAutoFillBackground(true);

	QPalette oPlaet;
	oPlaet.setColor(QPalette::Background, Qt::black);
	lbl_SelColor->setPalette(oPlaet);
	i_CurrentWidth = 3;
	e_CurrentColor = Qt::black;
	o_CurrentPen.setColor(e_CurrentColor);
	o_CurrentPen.setWidth(i_CurrentWidth);
	p_ColorDialog = new QColorDialog(this);
	
	p_GraphicView->setInteractive(false);
	p_GraphicView->setDragMode(QGraphicsView::ScrollHandDrag);

	frm_ClrSelection->setEnabled(false);
	frm_ItemSelection->setEnabled(false);
	frm_SizeSelection->setEnabled(false);

	connect(&o_MainActivity, SIGNAL(buttonClicked ( QAbstractButton *  )),
		this, SLOT(OnButtonSelected( QAbstractButton *  )));
	connect(&o_DrawType, SIGNAL(buttonClicked(QAbstractButton*)), 
		this, SLOT(OnDrawTypeChanged(QAbstractButton *)));
	connect(p_ColorDialog, SIGNAL(colorSelected ( const QColor   )),
		this, SLOT(ColorSelected( QColor  )));
	connect(&o_Zooming, SIGNAL(buttonClicked ( QAbstractButton *  )), 
		this, SLOT(OnZoomChanged(QAbstractButton * )));

	
	
}