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


C++ CImage类代码示例

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


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

示例1: Draw_SeedCandidates

void Draw_SeedCandidates (std::vector<CPoint> & seed_candidates)
{
	string output_path = gConfig.GetOutputPath();
	string image_name = gConfig.GetImageName();
	string file_name;
	CImage* XY = NULL;

	CPoint* pPoint = NULL;
	//int giMARGIN2 = 3;

	XY = new CImage(*CanvasXY);

	XY->RemovePixels(5);

	int min_X, max_X, min_Y, max_Y;

	for (std::vector<CPoint>::iterator i = seed_candidates.begin (); i != seed_candidates.end (); i++)
	{	
		pPoint = &*i;
		if (!The3DImage->WithinImagePadding(*pPoint,0))
			continue;
		XY->MarkCrosshairXY(pPoint,2);
		int radius = Round( static_cast<double>(i->m_fHWidth) / 2.0 );
		if(i->m_iHDir != 0)
		{
			min_X = max(0,i->m_iX - radius);
			max_X = min(i->m_iX + radius, XY->m_iCols);
			pPoint->m_iY = i->m_iY;
			for (int x = min_X; x <= max_X; x++)
			{
				pPoint->m_iX = x;
				XY->MarkPoint(pPoint, 3);
			}
		}
		else
		{
			min_Y = max(0,i->m_iY - radius);
			max_Y = min(i->m_iY + radius, XY->m_iRows);
			pPoint->m_iX = i->m_iX;
			for (int y = min_Y; y <= max_Y; y++)
			{
				pPoint->m_iY = y;
				if(XY->ValidPoint(*pPoint))
					XY->MarkPoint(pPoint, 3);
			}
		}
	}

	file_name = output_path + image_name + "UnverifiedSeeds.tif";
	XY->WriteTIFF(file_name);

	delete XY; XY = NULL;
}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:53,代码来源:draw.cpp

示例2: chc_export_image_collection

void chc_export_image_collection(FILE *fd, CTexture *tex) {
	CHCTexItem cube_item;
	CImage *img;
	memset(&cube_item, 0, sizeof(cube_item));
	if (tex->isCubeMap()) {
		cube_item.type = EColourType_CubeMap;
		cube_item.checksum = tex->getChecksum();
		printf("Item checksum: %08X\n", cube_item.checksum);
		fwrite(&cube_item, sizeof(cube_item), 1, fd);
		for (int i = 0; i < ECUBEMAPTYPE_COUNT; i++) {
			memset(&cube_item, 0, sizeof(cube_item));
			img = tex->getImage(i);
			img->compress();
			img->getDimensions(cube_item.width, cube_item.height);
			cube_item.data_size = img->getDataSize();
			cube_item.type = img->getColourType();
			cube_item.checksum = 0;
			fwrite(&cube_item, sizeof(cube_item), 1, fd);
			fwrite(img->getRawData(), cube_item.data_size, 1, fd);
		}
	}
	else {
		//write the raw img
		img = tex->getImage();
		//img->compress();
		cube_item.type = img->getColourType();
		cube_item.data_size = img->getDataSize();
		cube_item.checksum = tex->getChecksum();
		img->getDimensions(cube_item.width, cube_item.height);
		uint32_t guess_size = CImage::guessDataSize((EColourType)cube_item.type, cube_item.width, cube_item.height);
		if (guess_size > cube_item.data_size) {
			cube_item.data_size = guess_size;
		}
		fwrite(&cube_item, sizeof(cube_item), 1, fd);
		void *addr = img->getRawData();
		fwrite(addr, cube_item.data_size, 1, fd);
	}
}
开发者ID:chc,项目名称:assettool,代码行数:38,代码来源:CHCTexture.cpp

示例3: GetBitmapImage

/*!
 @brief イメージの取得

 @param [in]    pSelectItem     選択データ
 @param [out]   bitmap          イメージ
 */
BOOL CImageFontDlg::GetBitmapImage(LPVOID pSelectItem, CImage &bitmap)
{
	CRect rect;
	GetClientRect(&rect);

	bitmap.Create(rect.Width(), rect.Height(), 32);

	HDC hDC = bitmap.GetDC();
	Gdiplus::Graphics graphics(hDC);
	graphics.Clear((Gdiplus::ARGB)Gdiplus::Color::White);

	CString strMessage;
	strMessage = _T("1234567890\n");
	strMessage += _T("abcdefghijklmnopqrstuvwxyz\n");
	strMessage += _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
	strMessage += _T("あいおえおかきくけこさしすせそたちつてとなにぬねの\n");
	strMessage += _T("はひふへほまみむめもやゆよらりるれろわをん\n");

	LOGFONT *pLogfont = (LOGFONT *) pSelectItem;
	Gdiplus::Font font(hDC, pLogfont);

	Gdiplus::RectF drawLayout(0, 0, (Gdiplus::REAL)rect.Width(), (Gdiplus::REAL)rect.Height());

	Gdiplus::StringFormat stringFormat;
	stringFormat.SetAlignment(Gdiplus::StringAlignmentCenter);
	stringFormat.SetLineAlignment(Gdiplus::StringAlignmentCenter);
	stringFormat.SetTrimming(Gdiplus::StringTrimmingNone);

	Gdiplus::SolidBrush brush((Gdiplus::ARGB)Gdiplus::Color::Black);

	graphics.SetTextRenderingHint((Gdiplus::TextRenderingHint) (GetSpaceKeyDownCount() % (int)Gdiplus::TextRenderingHintClearTypeGridFit));
	graphics.DrawString(strMessage, -1, &font, drawLayout, &stringFormat,&brush);


	bitmap.ReleaseDC();

	return TRUE;
}
开发者ID:todesmarz,项目名称:InspectUsefulTools,代码行数:44,代码来源:ImageFontDlg.cpp

示例4: CopyToImage

//
// Copies the content of a byte buffer to a MFC image with respect to the image's alignment
//
// Parameters:
//  [in]    pInbuffer       The byte buffer as received from the cam
//  [in]    ePixelFormat    The pixel format of the frame
//  [out]   OutImage        The filled MFC image
//
void CAsynchronousGrabDlg::CopyToImage( VmbUchar_t *pInBuffer, VmbPixelFormat_t ePixelFormat, CImage &OutImage )
{
    const int               nHeight         = m_ApiController.GetHeight();
    const int               nWidth          = m_ApiController.GetWidth();
    const int               nStride         = OutImage.GetPitch();
    const int               nBitsPerPixel   = OutImage.GetBPP();
    VmbError_t              Result;
    if( ( nWidth*nBitsPerPixel ) /8 != nStride )
    {
        Log( _TEXT( "Vimba only supports stride that is equal to width." ), VmbErrorWrongType );
        return;
    }
    VmbImage                SourceImage,DestinationImage;
    SourceImage.Size        = sizeof( SourceImage );
    DestinationImage.Size   = sizeof( DestinationImage );

    SourceImage.Data        = pInBuffer;
    DestinationImage.Data   = OutImage.GetBits();

    Result = VmbSetImageInfoFromPixelFormat( ePixelFormat, nWidth, nHeight, &SourceImage );
    if( VmbErrorSuccess != Result )
    {
        Log( _TEXT( "Error setting source image info." ), static_cast<VmbErrorType>( Result ) );
        return;
    }
    static const std::string DisplayFormat( "BGR24" );
    Result = VmbSetImageInfoFromString( DisplayFormat.c_str(),DisplayFormat.size(), nWidth,nHeight, &DestinationImage );
    if( VmbErrorSuccess != Result )
    {
        Log( _TEXT( "Error setting destination image info." ),static_cast<VmbErrorType>( Result ) );
        return;
    }
    Result = VmbImageTransform( &SourceImage, &DestinationImage,NULL,0 );
    if( VmbErrorSuccess != Result )
    {
        Log( _TEXT( "Error transforming image." ), static_cast<VmbErrorType>( Result ) );
    }
}
开发者ID:noeliecherrier,项目名称:Logiciel-mecatro,代码行数:46,代码来源:AsynchronousGrabDlg.cpp

示例5: OnFileOpen

void CChildView::OnFileOpen()
{
	CImage image;
	CString strFilter;
	CString strAllFilePrompt;
	CSimpleArray<GUID> aguidFileTypes;
	HRESULT hResult;
	INT_PTR nResult;

	if (m_pSurface == NULL)
		return;
	VERIFY(strAllFilePrompt.LoadString(IDS_ALL_IMAGES));
	hResult = image.GetImporterFilterString(strFilter, aguidFileTypes, strAllFilePrompt);
	if(FAILED(hResult))	{
		CString fmt;
		fmt.Format(IDS_ERROR_GETEXPORTERFILTER, hResult, _com_error(hResult).ErrorMessage());
		::AfxMessageBox(fmt);
		return;
	}

	CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, strFilter);
	dlg.m_ofn.nFilterIndex = m_nFilterLoad;

	nResult = dlg.DoModal();
	if(nResult != IDOK) {
		return;
	}

	m_nFilterLoad = dlg.m_ofn.nFilterIndex;
	hResult = image.Load(dlg.GetFileName());
	ASSERT(SUCCEEDED(hResult));
	if (SUCCEEDED(hResult)) {
		m_pSurface->Import(image);
		// Stop the weird effects
		m_bPauseBlur = true;
		m_bPauseSwarm = true;
	}
}
开发者ID:jetlive,项目名称:skiaming,代码行数:38,代码来源:ChildView.cpp

示例6: TestImageDividerGenerateFromBorder

void TestImageDividerGenerateFromBorder(void)
{

	CImageDivider	cImageDivider;
	CImage			cImage;
	CImage			cMask;
	CImageCelMask*	pcRectangle;

	ReadImage(&cImage, "Input\\splitter.png");

	cImageDivider.Init(&cImage);
	cImageDivider.GenerateFromBorder(&cMask);
	AssertInt(20, cImageDivider.GetDestImageCels()->NumElements());
	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(0);
	AssertInt(1, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(1, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(1);
	AssertInt(15, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(1, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(13, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	pcRectangle = (CImageCelMask*)cImageDivider.GetDestImageCels()->Get(17);
	AssertInt(21, pcRectangle->GetSubImage()->mcImageRect.miLeft);
	AssertInt(39, pcRectangle->GetSubImage()->mcImageRect.miTop);
	AssertInt(3, pcRectangle->GetSubImage()->mcImageRect.GetWidth());
	AssertInt(3, pcRectangle->GetSubImage()->mcImageRect.GetHeight());

	WriteImage(&cMask, "Output\\splitter.raw");
	AssertFileMemory("input\\splitter.raw", cMask.mcChannels.GetData(), cMask.GetByteSize());

	cImageDivider.Kill();
	cMask.Kill();
	cImage.Kill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:38,代码来源:TestImageDivider.cpp

示例7: Test_FFMPEG_CaptureCamera

// ------------------------------------------------------
//					Test_FFMPEG_CaptureCamera
// ------------------------------------------------------
void Test_FFMPEG_CaptureCamera(const std::string &video_url)
{
	CFFMPEG_InputStream		in_video;

	if (!in_video.openURL(video_url,false /*grayscale*/, true /* verbose */ ))
		return;

	CDisplayWindow   win("Video");

	CTicTac	tictac;
	tictac.Tic();
	unsigned int nFrames = 0;

	CImage img;
	while (win.isOpen() && in_video.retrieveFrame(img))
	{
		double fps = ++nFrames / tictac.Tac();
		img.textOut(5,5,mrpt::format("%.02f fps",fps),TColor(0x80,0x80,0x80) );
		if (nFrames>100)
		{
			tictac.Tic();
			nFrames=0;
		}

		if (nFrames==1)
			cout << "Video FPS: " << in_video.getVideoFPS() << endl;


		win.showImage(img);
		mrpt::system::sleep(10);

		if (win.keyHit() && win.waitForKey()==27) break;
	}


	in_video.close();
	mrpt::system::pause();
}
开发者ID:3660628,项目名称:mrpt,代码行数:41,代码来源:test.cpp

示例8: assignImageAndZ

/*---------------------------------------------------------------
							assign Image and Z
  ---------------------------------------------------------------*/
void  CMeshFast::assignImageAndZ( const CImage& img, const mrpt::math::CMatrixTemplateNumeric<float> &in_Z)
{
	MRPT_START

	ASSERT_((img.getWidth() == static_cast<size_t>(in_Z.cols()))&&(img.getHeight() == static_cast<size_t>(in_Z.rows())))

	Z = in_Z;
		
	// Make a copy:
	m_textureImage = img;

	//Update flags/states
	m_modified_Image = true;
	m_enableTransparency = false;
	m_colorFromZ = false;
	m_isImage = true;
	pointsUpToDate = false;
	

	CRenderizableDisplayList::notifyChange();

	MRPT_END
}
开发者ID:SibghatullahSheikh,项目名称:mrpt,代码行数:26,代码来源:CMeshFast.cpp

示例9: benchmark_detectFeatures_FASTER

double benchmark_detectFeatures_FASTER(int N, int threshold)
{
	CTicTac tictac;

	// Generate a random image
	CImage img;
	getTestImage(0, img);

	CFeatureExtraction fExt;
	CFeatureList feats;

	fExt.options.featsType = TYP;
	fExt.options.FASTOptions.threshold = threshold;
	fExt.options.patchSize = 0;

	img = img.grayscale();

	tictac.Tic();
	for (int i = 0; i < N; i++) fExt.detectFeatures(img, feats, 0, MAX_N_FEATS);

	const double T = tictac.Tac() / N;
	return T;
}
开发者ID:MRPT,项目名称:mrpt,代码行数:23,代码来源:perf-feature_extraction.cpp

示例10: WriteFile

void WriteFile(CImage& img, const char* filename)
{
    // Determine the file extension
    char *dot = strrchr((char *) filename, '.');
    if (strcmp(dot, ".tga") == 0 || strcmp(dot, ".tga") == 0)
    {
        if (img.PixType() == typeid(uchar))
            WriteFileTGA(*(CByteImage *) &img, filename);
        else
           throw CError("ReadFile(%s): haven't implemented conversions yet", filename);
    }
    else
        throw CError("WriteFile(%s): file type not supported", filename);
}
开发者ID:Nikash,项目名称:cs5670proj4,代码行数:14,代码来源:FileIO.cpp

示例11: images

void CImageExplorer::mousePressEvent(QMouseEvent *event)
{
	iActiveImage = NULL;
	QListIterator<CImage*> images(iImages);
	images.toBack ();
	while (images.hasPrevious())
	{
		CImage* obj = images.previous();
		if(obj->IsPointOnObject(event->x(),event->y()))
		{
			//iActiveImage = obj;
			//iImages.move(iImages.indexOf(obj),iImages.count()-1);
			obj->mousePressEvent(event);
			SelectImage(obj);
			CWidget::GetInstance()->paint();
			break;
		}
	}
	if(CInfoPanel::GetInstance())
	{
		CInfoPanel::GetInstance()->SetImageExplorerInfoView();
	}
}
开发者ID:flaska,项目名称:DPEngine,代码行数:23,代码来源:cimageexplorer.cpp

示例12: captureImageAsync

/*-------------------------------------------------
                  CAPTURE PICTURE
  -----------------------------------------------*/
bool CRovio::captureImageAsync( CImage & picture, bool rectified)
{
	try
	{
		vector_byte resp;
		string errormsg;
		string MF=format("http://%s/Jpeg/CamImg[0000].jpg",options.IP.c_str());
		http_get (MF, resp, errormsg, 80, options.user, options.password);

		CMemoryStream stream( &resp[0],  resp.size()  );
		picture.loadFromStreamAsJPEG(stream);
		if( rectified )//Comprobar que las matrices existen y son correctas********************
			picture.rectifyImageInPlace(options.cameraParams);
		//picture.saveToFile("0000.jpg");
		//cout<<"Response:\n"<<response<<endl;
		return true;
	}
	catch(std::exception &e)
	{
		cerr << e.what() << endl;
		return false;
	}
}
开发者ID:9578577,项目名称:mrpt,代码行数:26,代码来源:CRovio.cpp

示例13: WriteFileJPEG

void WriteFileJPEG(CImage& img, const char* filename, unsigned quality) 
{
    JPEGWriter writer;

    CShape shape = img.Shape();

    if(shape.nBands != 1 && shape.nBands != 3) {
        throw CError("Can only write jpeg files with 1 or 3 channels, %d were given", shape.nBands);
    }

    writer.header(shape.width, shape.height, shape.nBands, (shape.nBands == 1)?JPEG::COLOR_GRAYSCALE : JPEG::COLOR_RGB);
    writer.setQuality(quality);

    // Reverse color channel order
    CByteImage imgAux(shape);
    for(int y = 0; y < shape.height; y++) {
        uchar* auxIt = (uchar*)imgAux.PixelAddress(0, y, 0);
        uchar* imgIt = (uchar*)img.PixelAddress(0, y, 0);

        for(int x = 0; x < shape.width; x++, auxIt += shape.nBands, imgIt += shape.nBands) {
            for(int c = 0; c < shape.nBands; c++) {
                auxIt[c] = imgIt[shape.nBands - c - 1];
            }
        }
    }

    // Pack row pointers
    std::vector<uchar*> rowPointers(shape.height);
    for(int y = 0; y < shape.height; y++) {
        rowPointers[shape.height - y - 1] = (uchar*) imgAux.PixelAddress(0,y,0);
    }

    writer.write(filename, rowPointers.begin());

    if (!writer.warnings().empty())
        std::cout << writer.warnings() << std::endl;
}
开发者ID:actionfarsi,项目名称:cv-pj4,代码行数:37,代码来源:FileIO.cpp

示例14: Min

void CTopographyRasterizer::RasterizeImage()
{
	CStopWatch sw;
	sw.Start();

	int LowPixel = 255;
	int HighPixel = 0;

	byte * ImageData = new byte[ImageSize * ImageSize * 3];
	for (int i = 0; i < ImageSize; ++ i)
	{
		for (int j = 0; j < ImageSize; ++ j)
		{
			int const Index = ImageSize * i + j;

			double const Value = Buckets[Index].Value;
			double const Intensity = 1.0f;
			int const Pixel = Clamp<int>((int) (Value * Intensity), 0, 255);

			LowPixel = Min(LowPixel, Pixel);
			HighPixel = Max(HighPixel, Pixel);

			ImageData[Index * 3 + 0] = Pixel;
			ImageData[Index * 3 + 1] = Pixel;
			ImageData[Index * 3 + 2] = Pixel;
			
		}
	}

	Log::Info("Low value: %d High Value: %d", LowPixel, HighPixel);

	CImage * Image = new CImage(ImageData, vec2u(ImageSize), 3);
	Image->FlipY();
	Image->Write(OutputName);

	Log::Info("Rasterize to image took %.3f", sw.Stop());
}
开发者ID:iondune,项目名称:Aqueous-2.0,代码行数:37,代码来源:CBathymetryRasterizer.cpp

示例15: TestImagesFaceDetection

// ------------------------------------------------------
// 				 TestImagesFaceDetection
// ------------------------------------------------------
void TestImagesFaceDetection(int argc, char *argv[])
{
	CImage		img;
	CDisplayWindow  win("Result");
	mrpt::utils::CTicTac	tictac;

	// For each aditional argument, tty to load an image and detect faces
	for ( int i = 1; i < argc; i++ )
	{
		string fileName( argv[i] );
		
		if (!img.loadFromFile(myDataDir+fileName))
		{
			cerr << "Cannot load " << myDataDir+fileName << endl;
			continue;
		}

		vector_detectable_object detected;

		tictac.Tic();

		faceDetector.detectObjects( &img, detected );

		cout << "Detection time: " << tictac.Tac() << " s" << endl;

		for ( unsigned int i = 0; i < detected.size() ; i++ )
		{	
			ASSERT_( IS_CLASS(detected[i],CDetectable2D ) )
			CDetectable2DPtr obj = CDetectable2DPtr( detected[i] );
			img.rectangle( obj->m_x, obj->m_y, obj->m_x+obj->m_width, obj->m_y + obj->m_height, TColor(255,0,0) );
		}

		win.showImage(img);

		mrpt::system::pause();
	}
}
开发者ID:Insomnia-,项目名称:mrpt,代码行数:40,代码来源:test.cpp


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