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


C++ Bitmap::Clone方法代码示例

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


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

示例1: Capture

bool ScreenCapture::Capture(HWND hWnd, Bitmap** bitmapRet)
{
    HDC desktop_dc = GetDC(nullptr);
    RECT rc = {0};
    GetWindowRect(hWnd, &rc);
    Bitmap* bitmap = new Bitmap(rc.right -rc.left, rc.bottom - rc.top);
    RECT window_rect = { };
    GetWindowRect(hWnd, &window_rect);
    bool success = false;
    do
    {
        Graphics graphic(bitmap); 
        HDC graphic_hdc = graphic.GetHDC();
        success = !!BitBlt(
            graphic_hdc, 0, 0, 
            rc.right -rc.left, rc.bottom - rc.top, 
            desktop_dc, 0, 0, SRCCOPY);
        graphic.ReleaseHDC(graphic_hdc);
    } while (false);
    ReleaseDC(nullptr, desktop_dc);
    *bitmapRet = bitmap->Clone(window_rect.left, window_rect.top, 
        window_rect.right - window_rect.left, 
        window_rect.bottom - window_rect.top, PixelFormat32bppARGB);
    delete bitmap;
    return success;
}
开发者ID:winwingy,项目名称:Study,代码行数:26,代码来源:screen_capture.cpp

示例2: copyFrom

void CBMPDoc::copyFrom(const CBMPDoc* bmpDoc)
{
	Bitmap *src = bmpDoc->m_bitmap;
	this->m_bitmap = src->Clone(0, 0, src->GetWidth(), src->GetHeight(), PixelFormat8bppIndexed);

	CString newTitle("copied_");
	newTitle.Append(bmpDoc->GetTitle());
	this->SetTitle(newTitle);
}
开发者ID:Leehwajung,项目名称:ImagePointProcessor,代码行数:9,代码来源:BMPDoc.cpp

示例3: FillRect

void IrisBitmap::FillRect(int x, int y, int width, int height, const IrisColor *color){
	this->needRefreshTexture = true;
	Bitmap* tbitmap = this->bitmap->Clone(0, 0, this->width, this->height, PixelFormat32bppARGB);
	SolidBrush *tpBrush = new SolidBrush(Color(color->alpha, color->red, color->green, color->blue));
	
	delete this->bitmap;
	Graphics g(tbitmap);
	g.FillRectangle(tpBrush, x, y, width, height);

	this->bitmap = tbitmap->Clone(0, 0, tbitmap->GetWidth(), tbitmap->GetHeight(), PixelFormat32bppARGB);

	delete tbitmap;
	delete tpBrush;
}
开发者ID:big-moon,项目名称:Iris-2D-Project,代码行数:14,代码来源:IrisBitmap.cpp

示例4: ImageEngineImpl

ImageEngine *ImageEngineImpl::Clone()
{
    Bitmap *bmp = pages.At(0);
    bmp = bmp->Clone(0, 0, bmp->GetWidth(), bmp->GetHeight(), PixelFormat32bppARGB);
    if (!bmp)
        return NULL;

    ImageEngineImpl *clone = new ImageEngineImpl();
    clone->fileName = str::Dup(fileName);
    clone->fileExt = fileExt;
    if (fileStream)
        fileStream->Clone(&clone->fileStream);
    clone->FinishLoading(bmp);

    return clone;
}
开发者ID:Livit,项目名称:moonpdf,代码行数:16,代码来源:ImagesEngine.cpp

示例5: Clear

void IrisBitmap::Clear(){
	this->needRefreshTexture = true;
	//graphics->Clear(Color(100, 100, 100));

	Bitmap* tp = this->bitmap->Clone(0, 0, this->width, this->height, PixelFormat32bppARGB);
	Graphics* tg = new Graphics(tp);

	delete this->bitmap;

	tg->Clear(Color(0, 0, 0, 0));
	
	this->bitmap = tp->Clone(0, 0, tp->GetWidth(), tp->GetHeight(), PixelFormat32bppARGB);

	delete tp;
	delete tg;

}
开发者ID:big-moon,项目名称:Iris-2D-Project,代码行数:17,代码来源:IrisBitmap.cpp

示例6:

vector<Bitmap*> CExampleDemoDlg::LoadTemplateImg(string filesrc)
{
	vector<Bitmap*> tempplate;
	vector<string>filepathname;
	ScanDirectory(filesrc, ".jpg", filepathname);//filesrc是文件夹名字
	//std::sort(filepathname.begin(),filepathname.end());
	for (int i = 0; i < filepathname.size(); i++)
	{
		string image = filesrc+"\\"+ filepathname[i];
		std::wstring widestr = std::wstring(image.begin(), image.end());
		Bitmap* pInImage = Bitmap::FromFile(widestr.c_str());
		if (pInImage->GetLastStatus() == -1)
		{
			SAFE_DELETE(pInImage);
			continue;
		}

		Bitmap*  img = pInImage->Clone(0, 0, pInImage->GetWidth(), pInImage->GetHeight(), PixelFormat32bppARGB);
		tempplate.push_back(img);
	}
	return tempplate;
}
开发者ID:hjimce,项目名称:EyeLabelDemo,代码行数:22,代码来源:ExampleDemoDlg.cpp

示例7: OnDraw

void CQTTDemoView::OnDraw(CDC* pDC)
{
	{
		/*
		CDC *mdc = new CDC;
		//De lam cai gi vay troi?
		mdc->CreateCompatibleDC(pDC);
		CBitmap* m_bitmap = new CBitmap();
		//Ham de load cai file den cai bitmap // Win32 API
		m_bitmap->m_hObject=(HBITMAP)::LoadImage(
			NULL,
			"tamtit.bmp",
			IMAGE_BITMAP,
			520,
			758,
			LR_LOADFROMFILE);
		//Phai select object thi no moi ve dc.
		mdc->SelectObject(m_bitmap);
		CRect rect;
		//Lay client Rect
		GetClientRect(&rect);
		//BitBlt() // Khong hieu
		//pDC->BitBlt(100,100,400,500,mdc,0,0,SRCCOPY);
		float radians = 3.1416f*0/180;
		float minx = 0;
		float miny = 0;
		float cosine = (float)cos(radians);
		float sine = (float)sin(radians);
		XFORM xform;
		xform.eM11 = cosine;
		xform.eM12 = -sine;
		xform.eM21 = sine;
		xform.eM22 = cosine;
		xform.eDx = (float)-minx;
		xform.eDy = (float)-miny;
		pDC->BitBlt(0,0,400,500,mdc,100,100,SRCCOPY);		
		SetGraphicsMode(pDC->m_hDC, GM_ADVANCED);
		SetWorldTransform(pDC->GetSafeHdc(),&xform);
		pDC->TransparentBlt(100,100,400,500,mdc,0,0,400,500,RGB(144,3,225));
		mdc->DeleteDC();		
		CBrush brush;
		brush.CreatePatternBrush(m_bitmap);
		*/
		// Block for Graphics
		Bitmap* originalBitmap = new Bitmap(L"gameloft_logo.png");
		Graphics g(pDC->GetSafeHdc());
		g.SetSmoothingMode(SmoothingModeHighQuality);
		g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
		g.SetPixelOffsetMode(PixelOffsetModeHighQuality);
		
		for (int i = 0; i < PATH_COUNT; i++)
		{
			//g.RotateTransform(45);
			
			if( i == PATH_IMAGE)
			{
				REAL left		= 34;
				REAL top		= 59;
				REAL width		= 106;
				REAL height		= 76;
				RectF sourceRect(
					left,
					top, 
					width, 
					height
				);
				RectF sourceBound;
				m_Paths[i].GetBounds(&sourceBound);				
				Bitmap* secondBitmap = originalBitmap->Clone(sourceRect, PixelFormatDontCare);
				m_Matrixs[i];
				g.SetTransform(m_Matrixs[i]);
				g.DrawImage(secondBitmap,0,0);
				Matrix* m = m_Matrixs[i]->Clone();
				m->Reset();
				g.SetTransform(m);
				g.DrawPath(m_pPens[i], & m_Paths[i]);
				delete m;				
			}
			else{
				g.FillPath(m_pBrushes[i], & m_Paths[i]);
				g.DrawPath(m_pPens[i], & m_Paths[i]);
			}
			
			//g.GetTransform()
		}
	}
	//Dung de paint may cai nut de co the xoay, resize v.v...
	m_Tracker.Draw(pDC);
}
开发者ID:seancyw,项目名称:dev-center,代码行数:89,代码来源:QTTDemoView.cpp

示例8: GetThumbnail


//.........这里部分代码省略.........
                                }
                            }

                            gfx.SetSmoothingMode(SmoothingModeNone);

                            if (m_Settings.BG_Transparency == 0)
                            {
                                gfx.DrawImage(&img, RectF((width / 2) - (new_width/2), 0, 
                                    static_cast<REAL>(new_width), static_cast<REAL>(new_height)));
                            }
                            else
                            {
                                ImageAttributes ImgAttr;
                                ImgAttr.SetColorMatrix(&BitmapMatrix, 
                                    ColorMatrixFlagsDefault, 
                                    ColorAdjustTypeBitmap);

                                gfx.SetSmoothingMode(SmoothingModeNone);
                                gfx.DrawImage(&img, RectF((width / 2) - (new_width/2), 0, static_cast<REAL>(new_width), static_cast<REAL>(new_height)),
                                    0, 0, img_width, img_height,
                                    UnitPixel, &ImgAttr);
                            }
                        }
                    }
                    else if (m_Settings.Revertto != BG_CUSTOM)
                    {
                        fail = true;
                        ClearBackground();
                        GetThumbnail();
                    }	                   
                }       

                delete background;
                background = (Bitmap*)custom_img->Clone();                
            }
            else if (m_Settings.Revertto != BG_CUSTOM)
            {		
                fail = true;
                ClearBackground();
                GetThumbnail();
            }
            break;	

        default:
            {
                fail = true;
                ClearBackground();
                GetThumbnail();                
            }
            break;
        }
    }

    if (tempfail)
    {
        return NULL;
    }

    REAL textheight = 0;
    Bitmap *canvas = background->Clone(0, 0, background->GetWidth(), background->GetHeight(), PixelFormat32bppPARGB);
    Graphics gfx(canvas);

    if (m_Settings.Text.empty())
    {
        Pen p(Color::MakeARGB(1, 255, 255, 255), 0.1);
        gfx.DrawLine(&p, 0, 0, 1, 1);
开发者ID:JsonHaLong,项目名称:win7shell,代码行数:67,代码来源:renderer.cpp

示例9: activate

void ToolFilter::activate()
{
	ChildCore *child = this->core->getActiveChild();
	if( child != NULL ){
		if( this->lastActivate == true && this->isLastActivate == false ){
			this->lastActivate = false;
			return;
		}

		ToolFilter::Info fi;
		Bitmap *source = NULL;
		if( child->getWorkspace()->getSelection() != NULL ){
			source = child->getWorkspace()->getSelectedProjection(NULL,COPCOP);
		}
		else {
			source = child->getWorkspace()->getSelectedLayer()->getRender();
			source = source->Clone(Rect(0,0,source->GetWidth(),source->GetHeight()),source->GetPixelFormat());
		}				

		fi.bmpSource = source;
		fi.bmpEffect = NULL;
		fi.bw = this->lastBw;
		fi.bwalpha = (this->lastAlpha &&
					  this->lastFilterId != ID_FILTER_OLDSTONE &&
					  this->lastFilterId != ID_FILTER_EDGETRACE );
		fi.smooth = true;
		fi.edgeTrace = (this->lastFilterId == ID_FILTER_EDGETRACE);

		fi.filterId = this->lastFilterId;
		fi.filterValue = this->lastFilterValue;
		fi.filterByValue = (this->lastFilterId != ID_FILTER_CUSTOM);

		fi.minVal = 0;
		switch(fi.filterId){
			case ID_FILTER_SHARPEN:
				fi.maxVal = SHARPENMAX;
				break;
			default:
				fi.maxVal = FILTERMAX;
				break;
		}

		if( fi.filterByValue == true )
			fi.matrix = ToolFilter::allocateMatrix(fi.filterId,fi.filterValue);
		else
			fi.matrix = this->lastCustomMatrix;

		int result = NO;
		if( this->lastActivate == false ){
			result = this->core->getDialogs()->showDialog(
														(LPCTSTR)IDD_FIL,
														(DLGPROC)Dialogs::processDlg_Fil,
														(LPARAM)&fi
														);
		}
		else {
			this->lastActivate = false;
			result = YES;
		}
		if( result == YES ){

			Point shift(0,0);
			Rect *bounds = NULL;

			if( child->getWorkspace()->getSelection() != NULL ){
				bounds = new Rect(0,0,0,0);
				child->getWorkspace()->getSelection()->GetBounds(bounds);

				fi.bmpSource = child->getWorkspace()->getSelectedLayer()->getRender();
			}
			else {
				int exw = (int)( floor(fi.matrix.mxw / 2.0) + 1 );
				int exh = (int)( floor(fi.matrix.mxh / 2.0) + 1 );

				shift.X = -exw;
				shift.Y = -exh;

				Bitmap *newsource = new Bitmap(
					source->GetWidth() + 2 * exw,
					source->GetHeight() + 2 * exh,
					source->GetPixelFormat());
				Graphics *g = Graphics::FromImage(newsource);
				g->DrawImage(source,exw,exh,source->GetWidth(),source->GetHeight());

				delete g;
				delete source;

				source = newsource;
				fi.bmpSource = newsource;
			}
			if( fi.filterByValue == true )
				this->lastFilterValue = fi.filterValue;
			else
				this->lastCustomMatrix = fi.matrix;
			this->lastBw = fi.bw;
			this->lastAlpha = fi.bwalpha;

			Rect newbounds = ToolFilter::applyFilter(&fi,bounds);

			if( child->getWorkspace()->getSelection() == NULL ){
//.........这里部分代码省略.........
开发者ID:f055,项目名称:fedit-image-editor,代码行数:101,代码来源:ToolFilter.cpp


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