void CT3000DefaultView::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: Add your message handler code here
	// Do not call CFormView::OnPaint() for painting messages
	CMemDC memDC(dc,this);
	Graphics graphics(memDC.GetDC());

	CRect test_rect;
	HWND temp_hwnd = this->m_hWnd;
	::GetWindowRect(temp_hwnd,&test_rect);	//获取 view的窗体大小;
	Bitmap bitmap(hBitmap_default_bmp,NULL);
	graphics.DrawImage(&bitmap,0 ,0,test_rect.Width(),test_rect.Height());
}
inline void OmniStereoGraphicsRenderer::onDrawOmni(OmniStereo& omni) {
  graphics().error("start onDraw");
  mShader.begin();
  mOmni.uniforms(mShader);
  graphics().pushMatrix(graphics().MODELVIEW);
  onDraw(graphics());
  graphics().popMatrix(graphics().MODELVIEW);
  mShader.end();
}
Beispiel #3
0
void CImageString::DrawControl(CDC &dc, CRect rcUpdate)
{
	int nWidth = m_rc.Width();
	int nHeight = m_rc.Height();

	if(!m_bUpdate)
	{
		int nLen = m_strTitle.GetLength();
		UpdateMemDC(dc, nWidth * nLen, nHeight);

		Graphics graphics(m_memDC);
		
		m_memDC.BitBlt(0, 0, nWidth, nHeight, &dc, m_rc.left ,m_rc.top, SRCCOPY);

		int nXPos = 0;
		int nYPos = 0;
		if(m_uAlignment == Align_Center)
		{
			nXPos = (nWidth - nLen * m_sizeImage.cx) / 2;
		}
		else if(m_uAlignment == Align_Right)
		{
			nXPos = nWidth - nLen * m_sizeImage.cx;
		}

		if(m_uVAlignment == VAlign_Middle)
		{
			nYPos = (nHeight - m_sizeImage.cy) / 2;
		}
		else if(m_uVAlignment == VAlign_Bottom)
		{
			nYPos = nHeight - m_sizeImage.cy;
		}

		for(int i = 0; i < nLen; i++)
		{
			int nImageIndex = GetImageIndex(i);
			if(nImageIndex != -1)
			{
				graphics.DrawImage(m_pImage, Rect(nXPos , nYPos,  m_sizeImage.cx, m_sizeImage.cy),
					nImageIndex * m_sizeImage.cx, 0, m_sizeImage.cx, m_sizeImage.cy, UnitPixel);
			}

			nXPos += m_sizeImage.cx;
		}
	}

	dc.BitBlt(m_rc.left,m_rc.top, m_rc.Width(), m_rc.Height(), &m_memDC, 0, 0, SRCCOPY);
}
Beispiel #4
0
void CVideoStatic::SetBackGroudImage(const CPaintDC& dc)
{
	// ¼ÓÔر³¾°logoͼƬ
	if (NULL == m_pImage)
	{
		m_pImage = Gdiplus::Image::FromFile(m_strLogoPath);
		if (NULL == m_pImage)
		{
			LOG_RUN_ERROR("m_pImage is null.");
			return;
		}
		else
		{
			if (Gdiplus::Ok != m_pImage->GetLastStatus())
			{
				std::string strPath = eLTE_Tool::UnicodeToANSI(m_strLogoPath.GetString()).c_str();
				LOG_RUN_ERROR("Gdiplus::Image::FromFile failed. (%s)", strPath.c_str());
				m_pImage = NULL;
				return;
			}
		}
	}

	// ¾ÓÖÐλÖüÆËã
	CRect rect;
	GetClientRect(&rect);
	int iWidth = (int)m_pImage->GetWidth();
	int iHeight = (int)m_pImage->GetHeight();
	if ((double)rect.right/rect.bottom > (double)iWidth/iHeight)
	{
		iHeight = rect.bottom / 3;
		iWidth = iHeight * (int)m_pImage->GetWidth() / (int)m_pImage->GetHeight();
	}
	else
	{
		iWidth = rect.right / 3;
		iHeight = iWidth * (int)m_pImage->GetHeight() / (int)m_pImage->GetWidth();
	}

	int iLeft = (rect.right - iWidth) / 2;
	int iTop = (rect.bottom - iHeight) / 2;

	// »æÖÆͼƬ
	Gdiplus::Graphics graphics(dc);
	Gdiplus::Rect gRect(iLeft, iTop, iWidth, iHeight);
	Gdiplus::ImageAttributes ImgAtt;
	ImgAtt.SetWrapMode(Gdiplus::WrapModeTileFlipXY);
	graphics.DrawImage(m_pImage, gRect, 0, 0, (INT)m_pImage->GetWidth(), (INT)m_pImage->GetHeight(), Gdiplus::UnitPixel, &ImgAtt);
}
Beispiel #5
0
//************************************
// Method:    DrawFrame
// FullName:  CGifAnimUI::DrawFrame
// Access:    private 
// Returns:   void
// Qualifier:
// Parameter: HDC hDC
// Note:	  
//************************************
void CGifAnimUI::DrawFrame( HDC hDC )
{
	try
	{
		if ( NULL == hDC || NULL == m_pGifImage ) return;
		GUID pageGuid = Gdiplus::FrameDimensionTime;
		Graphics graphics( hDC );
		graphics.DrawImage( m_pGifImage, m_rcItem.left, m_rcItem.top );
		m_pGifImage->SelectActiveFrame( &pageGuid, m_nFramePosition );
	}
	catch (...)
	{
		throw "CGifAnimUI::DrawFrame";
	}
}
Beispiel #6
0
void CScrollV::DrawRange(CDC &dc, CRect rc, int nXPos)
{
	Graphics graphics(dc);

	CRect rcTemp;
	rcTemp.SetRect(rc.left, rc.top, rc.left + rc.Width(), rc.top + m_sizeImage.cy);
	DrawImageFrame(graphics, m_pImage, rcTemp, nXPos, 0, m_sizeImage.cx, m_sizeImage.cy, 2);

	rcTemp.SetRect(rc.left, rc.top + m_sizeImage.cy, rc.left + rc.Width(), rc.bottom - m_sizeImage.cy);
	graphics.DrawImage(m_pImage, Rect(rcTemp.left, rcTemp.top, rcTemp.Width(), rcTemp.Height()), 
		nXPos, m_sizeImage.cy, m_sizeImage.cx,m_sizeImage.cy , UnitPixel);

	rcTemp.SetRect(rc.left, rc.bottom - m_sizeImage.cy, rc.left + rc.Width(), rc.bottom);
	DrawImageFrame(graphics, m_pImage, rcTemp, nXPos, m_sizeImage.cy * 2, m_sizeImage.cx, m_sizeImage.cy, 2);
}
Beispiel #7
0
void bbGraphics3D( int w,int h,int d,int mode ){
	int flags=gxGraphics::GRAPHICS_3D;
	switch( mode ){
	case 0:flags|=(debug && bbWindowed3D()) ? gxGraphics::GRAPHICS_WINDOWED : 0 ;break;
	case 1:break;
	case 2:flags|=gxGraphics::GRAPHICS_WINDOWED;break;
	case 3:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED;break;
	case 6:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_AUTOSUSPEND;break;
	case 7:flags|=gxGraphics::GRAPHICS_WINDOWED|gxGraphics::GRAPHICS_SCALED|gxGraphics::GRAPHICS_AUTOSUSPEND;break;
	default:RTEX( "Illegal Graphics3D mode" );
	}
	graphics( w,h,d,flags );
	extern void blitz3d_open();
	blitz3d_open();
}
Beispiel #8
0
void  CStartupView::DrawStartupPage()
{
   Gdiplus::Graphics graphics(GetDC()->m_hDC);
   graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighSpeed);

   // Different regions within the tab   
   DrawBackground(graphics);
   DrawTitleText(graphics);
   //DrawSeparator(graphics);
   //Draw

   DrawLecturnityLogo(graphics);
   //DrawImcLogo(graphics);
   //InvalidateAllButtons(TRUE);
}
Beispiel #9
0
// 绘制羽化文字
void DrawEclosionText(HDC hDC, LPCTSTR lpszText, LPCTSTR lpszFontName, int nFontSize)
{
	int nWidth = 56, nHeight = 16;

	Gdiplus::Bitmap bmp(nWidth, nHeight, 0, PixelFormat32bppARGB, NULL);
	Gdiplus::Graphics graphics(&bmp);
	Gdiplus::GraphicsPath path(Gdiplus::FillModeAlternate);
	Gdiplus::FontFamily fontFamily(lpszFontName, NULL);
	Gdiplus::StringFormat strFmt(0, 0);

	Gdiplus::RectF rc(0.0f, 0.0f, nWidth, nHeight);
	path.AddString(lpszText, -1, &fontFamily, Gdiplus::FontStyleBold, nFontSize, rc, &strFmt);

	Gdiplus::Matrix matrix(1.0f/* / 5.0f*/, 0.0f, 0.0f, 1.0f/* / 5.0f*/, -1.0f/* / 5.0f*/, -1.0f/* / 5.0f*/);
	
	graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
	graphics.SetTransform(&matrix);

	Gdiplus::Color color((Gdiplus::ARGB)0x55CCE0EE);
	Gdiplus::Pen pen(color, 3);

	graphics.DrawPath(&pen, &path);

	Gdiplus::Color color2((Gdiplus::ARGB)0x55CCE0EE);
	Gdiplus::SolidBrush brush(color2);

	graphics.FillPath(&brush, &path);

 	Gdiplus::Bitmap bmp2(300, 40, 0, PixelFormat32bppARGB, NULL);
 	Gdiplus::Graphics graphics2(&bmp2);
 
 	graphics2.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
 	graphics2.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
 	graphics2.DrawImage(&bmp, 0, 0, nWidth, nHeight);
 
 	Gdiplus::Color color3((Gdiplus::ARGB)0xFF000000);
 	Gdiplus::SolidBrush brush2(color3);
 
 	graphics2.FillPath(&brush2, &path);

	CLSID clsid;
	::CLSIDFromString(_T("{557CF406-1A04-11D3-9A73-0000F81EF32E}"), &clsid);
	bmp2.Save(_T("c:\\CoolText.png"), &clsid, NULL);

	Gdiplus::Graphics graphics3(hDC);

	graphics3.DrawImage(&bmp2, 8, 4);
}
Beispiel #10
0
void CBoardDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
//AfxMessageBox(m_strImagePath);
	if (m_pBGBitmap)
	{
		CRect rc;
		GetClientRect(&rc);

		Graphics graphics(dc.m_hDC);	
		graphics.DrawImage(m_pBGBitmap, 0, 0, rc.Width(), rc.Height());
	}

}
Beispiel #11
0
int main(int argc, char **argv)
{
    if(argc < 3)
    {
	printf("missing obstacle file argument\n");		
	printf("  RunBug <obstacle_file.txt> <bugSelection>\n");
	return 0;		
    }

    Graphics graphics(argv[1], atoi(argv[2]));
    
    graphics.HandleEventOnHelp();
    graphics.MainLoop();
    
    return 0;    
}
Beispiel #12
0
int main(int argc, char *argv[])
{
    std::srand(std::time(0));
    Graphics graphics(&argc, argv, "Casino game");

    ResourceManager::getInstance().loadTexture("background.tga");
    ResourceManager::getInstance().loadTexture("stripe.tga");
    ResourceManager::getInstance().loadTexture("start.tga");
    ResourceManager::getInstance().loadTexture("stop.tga");
    ResourceManager::getInstance().loadTexture("debian.tga");
    ResourceManager::getInstance().loadTexture("vim.tga");
    ResourceManager::getInstance().loadTexture("gentoo.tga");

    Game::getInstance().run();
    return 0;
}
Beispiel #13
0
void CEnteringRoomDlg::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CDialog::OnPaint()
	
	//中间
	CRect rcClient ;
	GetClientRect( &rcClient ) ;
	Graphics    graphics(dc);

	ImageAttributes imgAtt;
	imgAtt.SetWrapMode(WrapModeTileFlipXY);//GDI+在位伸图片时会自动加上渐变效果。但此处不需要,所以得加上此属性

	//去掉边框
	//左上、上中、右上
	graphics.DrawImage(m_imgTopLeft,Rect(0, 0, m_imgTopLeft->GetWidth(), m_imgTopLeft->GetHeight()), 
		                            0, 0, m_imgTopLeft->GetWidth(),  m_imgTopLeft->GetHeight(),UnitPixel,&imgAtt);//没拉抻

	graphics.DrawImage(m_imgTopMid, Rect(m_imgTopLeft->GetWidth(), 0, rcClient.Width() - m_imgTopLeft->GetWidth() * 2, m_imgTopMid->GetHeight()), 
		                            0, 0, rcClient.Width() - m_imgTopLeft->GetWidth() * 2, m_imgTopMid->GetHeight(), UnitPixel,&imgAtt);

	graphics.DrawImage(m_imgTopRight, Rect(rcClient.right - m_imgTopRight->GetWidth() - 1, 0, m_imgTopRight->GetWidth(), m_imgTopRight->GetHeight()), 
		                             0, 0, m_imgTopRight->GetWidth(), m_imgTopRight->GetHeight(), UnitPixel,&imgAtt);

	//左中、右中
	graphics.DrawImage(m_imgMidLeft, Rect(0, m_imgTopMid->GetHeight(), m_imgMidLeft->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2), 
		                             0, 0, m_imgMidLeft->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2, UnitPixel,&imgAtt);

	graphics.DrawImage(m_imgMidRight, Rect(rcClient.right - m_imgMidRight->GetWidth() - 1, m_imgTopMid->GetHeight(), m_imgMidRight->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2), 
		                              0, 0,  m_imgMidRight->GetWidth(), rcClient.Height() - m_imgTopMid->GetHeight() * 2,UnitPixel,&imgAtt);

	//左下、下中、右下
	graphics.DrawImage(m_imgBottomLeft,Rect(0, rcClient.bottom - m_imgBottomLeft->GetHeight() - 1, m_imgBottomLeft->GetWidth(), m_imgBottomLeft->GetHeight()), 
		                               0, 0, m_imgBottomLeft->GetWidth(), m_imgBottomLeft->GetHeight(), UnitPixel,&imgAtt);

	graphics.DrawImage(m_imgBottomMid, Rect(m_imgMidLeft->GetWidth(), rcClient.bottom - m_imgBottomMid->GetHeight() - 1, rcClient.Width() - m_imgMidLeft->GetWidth() * 2, m_imgBottomMid->GetHeight()), 
		                               0, 0,rcClient.Width() - m_imgMidLeft->GetWidth() * 2, m_imgBottomMid->GetHeight(), UnitPixel,&imgAtt);

	graphics.DrawImage(m_imgBottomRight,Rect(rcClient.right - m_imgBottomRight->GetWidth() - 1, rcClient.bottom - m_imgBottomRight->GetHeight() - 1, m_imgBottomRight->GetWidth(), m_imgBottomRight->GetHeight()),
		                                0, 0, m_imgBottomRight->GetWidth(), m_imgBottomRight->GetHeight(), UnitPixel,&imgAtt);
	//中间
	graphics.DrawImage( m_pPic->GetCurImage() ,Rect(m_imgMidLeft->GetWidth(), m_imgTopMid->GetHeight(), rcClient.Width() - m_imgMidLeft->GetWidth() * 2 - 1 , rcClient.Height() - m_imgTopMid->GetHeight() * 2 - 1),
		                        0, 0,  rcClient.Width() - m_imgMidLeft->GetWidth() * 2 - 1 , rcClient.Height() - m_imgTopMid->GetHeight() * 2 - 1,UnitPixel,&imgAtt) ;
	/*graphics.DrawImage( m_pPic->GetCurImage() ,Rect(0, 0, rcClient.Width(), rcClient.Height()),
		0, 0,  rcClient.Width(), rcClient.Height(),UnitPixel,&imgAtt) ;*/
}
Beispiel #14
0
void CALLBACK CPlayer::OnDrawFun(long nPort, HDC hDc, LONG nUser)
{
	if (!CDVRSettings::GetInstance()->m_bDrawMetaData) // show/hide metadata
	{
		return;
	}

	CPlayer* pPlayer = (CPlayer*)nUser;
	if( pPlayer != NULL )
	{
		int renderWndWidth =  pPlayer->m_rcRenderRect.right-pPlayer->m_rcRenderRect.left;
		int renderWndHeight =  pPlayer->m_rcRenderRect.bottom-pPlayer->m_rcRenderRect.top;
		if (renderWndWidth <= 0 && renderWndHeight <= 0)
		{
			return;
		}

		BYTE byMetaData[sizeof(pPlayer->m_meta)];
		U32 metaLen = 0;
		pPlayer->m_MetaDataLock.Lock();
		memcpy(&metaLen, pPlayer->m_meta, sizeof(U32));
		memcpy(byMetaData, pPlayer->m_meta+sizeof(U32), metaLen);
		pPlayer->m_MetaDataLock.Unlock();

		HHV::FrameMetaDataList metaList;
		U32 readSize = 0;
		BYTE* pFMDStartPos = byMetaData;
		while(readSize < metaLen)
		{
			HHV::FrameMetaData fmd;
			pFMDStartPos = fmd.FromMemory(pFMDStartPos);
			metaList.push_back(fmd);
			readSize += fmd.memsize();
		}
		
		HHV::FrameMetaDataList scaledMetaData;

		pPlayer->m_spScaleMetaData->GetScaledFrameMetaDataList(scaledMetaData, metaList, renderWndWidth, renderWndHeight);
		Gdiplus::Graphics graphics(hDc);

		for (HHV::FrameMetaDataList::const_iterator it = scaledMetaData.begin(); it != scaledMetaData.end(); ++it)
		{
			HHFrameMetadataHelper().DrawFrameMetaData(graphics, *it, renderWndWidth, renderWndHeight);
		}
	}

}
Beispiel #15
0
BOOL CDL便签Dlg::OnEraseBkgnd(CDC* pDC)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	//CRect rect;
	//GetWindowRect(&rect);
	//Graphics graphics(pDC->m_hDC);
	//CDC MemDC;
	//CBitmap bitmap;
	//MemDC.CreateCompatibleDC(pDC);
	//bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
	//MemDC.SelectObject(&bitmap);

	//Graphics MemGraphics(MemDC.GetSafeHdc());

	//if(!m_image)
	//	m_image = Image::FromFile(L"res\\NCPAINT.bmp");
	//MemGraphics.DrawImage(m_image,0,0,rect.Width(),rect.Height());

	//CDialog::OnEraseBkgnd(pDC);
	CRect rect;
	GetClientRect(&rect);

	CDC MemDC;
	MemDC.CreateCompatibleDC(pDC);
	CBitmap bitmap;
	bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
	MemDC.SelectObject(bitmap);

	Graphics graphics(MemDC.m_hDC);
	m_image = Image::FromFile(L"res\\NCPAINT.png");
	graphics.DrawImage(m_image,10,10,rect.Width(),rect.Height());

	/*pDC->StretchBlt(//客户区和标题栏有点绘图错误,问题在这里
	0,-10,rect.Width(),rect.Height()+10,
	&MemDC,10,10+GetSystemMetrics(SM_CYCAPTION)+ GetSystemMetrics(SM_CYFRAME),
	rect.Width()-10,rect.Height()-10,SRCCOPY);*/

	pDC->StretchBlt(//客户区和标题栏有点绘图错误,问题在这里
		0,0,rect.Width(),rect.Height()+10,
		&MemDC,
		10+GetSystemMetrics(SM_CYFRAME),
		10+GetSystemMetrics(SM_CYCAPTION)+ GetSystemMetrics(SM_CYFRAME),
		200-GetSystemMetrics(SM_CYFRAME)*2,
		rect.Height()-10-GetSystemMetrics(SM_CYCAPTION)+ GetSystemMetrics(SM_CYFRAME),
		SRCCOPY);
	return 1;
}
	void RenderContext::CalcStringRectWithFlags(const std::wstring& text, const Font& font, const Rect& rect, int flags, Rect& out, size_t* len, int* lines)
	{
		HDC hdc = GetDC(NULL);
		Gdiplus::Graphics graphics(hdc);
		Gdiplus::Font        gdi_font(hdc, font.ToHFONT());
		Gdiplus::StringFormat format;
		Gdiplus::RectF       rectF(rect.x(), rect.y(), rect.width(), rect.height());

		Gdiplus::RectF outF;

		GetStringFormat(format, flags);
		graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
		graphics.MeasureString(text.c_str(), text.size(), &gdi_font, rectF, &format, &outF, (int*)len, lines);

		out.SetRect(outF.X, outF.Y, outF.Width, outF.Height);
		::ReleaseDC(NULL, hdc);
	}
Beispiel #17
0
	void Figura::draw(HDC hdc)
	{
		srand(time(NULL));
		int t = rand() % 2;
		Graphics graphics(hdc);
		if (t == 0)
		{
			SolidBrush      solidbrush(Color(255, 0, 0, 255));
			graphics.FillEllipse(&solidbrush, 0, 0, 30, 30);
		}
		else
		{
			SolidBrush      solidbrush(Color(155,155,155, 155));
			graphics.FillEllipse(&solidbrush, 0, 0, 60, 60);
		}
		
	}
Beispiel #18
0
    // Invalidates the tab's region in the client area.
    void Invalidate(int index) {
        if (index < 0) return;

        Graphics graphics(hwnd);
        GraphicsPath shapes(data->Points, data->Types, data->Count);
        GraphicsPath shape;
        GraphicsPathIterator iterator(&shapes);
        iterator.NextMarker(&shape);
        Region region(&shape);

        ClientRect rClient(hwnd);
        REAL yPosTab = inTitlebar ? 0.0f : REAL(rClient.dy - height - 1);
        graphics.TranslateTransform(REAL((width + 1) * index) + 1.0f, yPosTab);
        HRGN hRgn = region.GetHRGN(&graphics);
        InvalidateRgn(hwnd, hRgn, FALSE);
        DeleteObject(hRgn);
    }
Beispiel #19
0
int main(int argc, char **argv)
{
    PseudoRandomSeed();
    
    if(argc < 2)
    {
	printf("missing arguments\n");		
	printf("  Planner <file>\n");
	return 0;		
    }

    Graphics graphics(argv[1]);
    
    graphics.MainLoop();
    
    return 0;    
}
    Bitmap::Bitmap(Image* original, int width, int height, Imaging::PixelFormat format)
      {
      if(width == 0)
        width = original->Width();

      if(height == 0)
        height = original->Height();

      void* bmp;
      /*int status = */GDIPlus::GdipCreateBitmapFromScan0(width, height, 0, (INT)format, nullptr, &bmp);
      //GDIPlus.CheckStatus(s);
      _nativeObject = bmp;

      GCGraphics graphics(Graphics::FromImage(this));

      graphics->DrawImage(original, 0, 0, width, height);
      }
Beispiel #21
0
BOOL CBSObject::DrawPNG(HDC hDC, const RECT &rectDst, Gdiplus::Image* pImage, const RECT* prectImagePortion /*= NULL*/)
{
	BOOL bRet = FALSE;

    if (pImage > 0)
    {
        Gdiplus::Graphics graphics(hDC);

        Gdiplus::RectF cRectF(static_cast<Gdiplus::REAL>(rectDst.left), 
            static_cast<Gdiplus::REAL>(rectDst.top), 
            static_cast<Gdiplus::REAL>(rectDst.right - rectDst.left), 
            static_cast<Gdiplus::REAL>(rectDst.bottom - rectDst.top));
								
	    Gdiplus::ImageAttributes clImgAtt;
	    clImgAtt.SetWrapMode(Gdiplus::WrapModeTileFlipXY);

        if (NULL == prectImagePortion)
		{
			graphics.DrawImage(pImage, 
                cRectF, 
                static_cast<Gdiplus::REAL>(0), 
                static_cast<Gdiplus::REAL>(0),
                static_cast<Gdiplus::REAL>(pImage->GetWidth()), 
                static_cast<Gdiplus::REAL>(pImage->GetHeight()),
				Gdiplus::UnitPixel, 
                &clImgAtt); //
		}
		else
        {
			graphics.DrawImage(pImage, 
                cRectF, 
                static_cast<Gdiplus::REAL>(prectImagePortion->left), 
				static_cast<Gdiplus::REAL>(prectImagePortion->top), 
				static_cast<Gdiplus::REAL>(prectImagePortion->right - prectImagePortion->left), 
				static_cast<Gdiplus::REAL>(prectImagePortion->bottom - prectImagePortion->top), 
				Gdiplus::Unit::UnitPixel, 
				NULL, //&clImgAtt
				NULL, 
				NULL);
		}

        bRet = TRUE;
    }

	return bRet;
}
void CGdiPlusBitmapHelper::DrawPngImage(HDC &dc, HINSTANCE hInst, UINT uiImageID, int xStart, int yStart)
{
	if (!m_pBitmap)
	{
		LPCTSTR lpszResource = MAKEINTRESOURCE(uiImageID);
		LPCTSTR lpszType = L"PNG";

		m_pBitmap = new CGdiPlusBitmapResource;
		m_bBitmapLoaded = m_pBitmap->Load(lpszResource, lpszType, hInst);
	}

	if(m_bBitmapLoaded)
	{
		Gdiplus::Graphics graphics(dc);
		graphics.DrawImage(*m_pBitmap, xStart, yStart);
	}
}
Beispiel #23
0
//main program loop
int main(int argc, char** argv)
{
	std::setlocale(LC_CTYPE, "en_US.utf8");
    lua_State *L = 0;
    
    bool keepRunning = true;
    Lazy::EventDistributor distro;
    //Lazy::Window window(640,480);
    Lazy::GraphicsDevice graphics(window);
    Lazy::Lua::Machine vm;
	Lazy::ResourceHandle font = graphics.loadFontFromFile("Arial Unicode.ttf");
    L = vm.FiberNew();
    vm.LoadProgram(L, program);

    /*distro.subscribe(Crystal::GetTypeId<A>(),
                     [=](const Lazy::Event&)
                     {
                         std::cout << "Received event A" << std::endl;
                     });
    
    distro.input(Crystal::NewObject<A>());
    distro.input(Crystal::NewObject<B>());
    distro.input(Crystal::NewObject<A>());*/
    
    /*if(window == NULL)
    {
        printf("Could not start LazyGame Engine.");
        delete window;
        return 1;
    }*/


    while(keepRunning)
    {
        //vm.Run();
        keepRunning = window.HandleEvents();

		graphics.drawString(font, L"レナート Hello World ﻟﻴﻨﺎﺭﺕ", 32, 64);
        
        
        window.FlipBuffer();
        graphics.Clear();
    }
    lua_close(L);
    return 0;
}
	void RenderContext::CalcStringSizeWithFlags(const wchar_t* text, size_t text_len, const Font& font, const Size& sz, int flags, Size& out, size_t* len /*= NULL*/, int* lines /*= NULL*/)
	{
		HDC hdc = GetDC(NULL);
		Gdiplus::Graphics graphics(hdc);
		Gdiplus::Font        gdi_font(hdc, font.ToHFONT());
		Gdiplus::StringFormat format;
		Gdiplus::RectF       rectF(0, 0, sz.width(), sz.height());

		Gdiplus::RectF outF;

		GetStringFormat(format, flags);
		graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
		graphics.MeasureString(text, text_len, &gdi_font, rectF, &format, &outF, (int*)len, lines);

		out.SetSize(outF.Width, outF.Height);
		::ReleaseDC(NULL, hdc);
	}
Beispiel #25
0
void write_packing() {
    FILE *packing_fptr;
    packing_fptr = fopen("input_phase_space.out", "w");
    fprintf(packing_fptr, "%ld %ld %e %e\n", nDisks, 4L, box_w, box_h);
    for (long i = 0; i < 4; i++) {
        fprintf(packing_fptr, "%e %e %e %e\n",
                wall[i].x, wall[i].y, wall[i].nx, wall[i].ny);
    }
    for (long i = 0; i < nDisks; i++) {
        fprintf(packing_fptr, "%16.12e %16.12e %16.12e %16.12e %16.12e\n",
                disk[i].x, disk[i].y, disk[i].R, disk[i].mass, disk[i].iMoment);
    }
    fclose(packing_fptr);
#ifdef GRAPHICS
    graphics(-1, -1, 0);
#endif
}
Beispiel #26
0
LRESULT CToolBarLogo::OnPaint(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
	CPaintDC dc(m_hWnd);
	#ifdef _VISUALSTYLE_XP_H_
	if (g_xpStyle.IsAppThemed())
	{
		RECT rc = {};
		::GetClientRect(m_hWnd,&rc);
		HTHEME hTheme = g_xpStyle.OpenThemeData(m_hWnd, L"TAB");
		g_xpStyle.DrawThemeBackground(hTheme, dc.m_hDC, TABP_BODY, TIS_NORMAL, &rc, 0);
		g_xpStyle.CloseThemeData(hTheme);
	}
	#endif
	//方法二: 直接读取png文件并显示!
	Gdiplus::Graphics graphics(dc.m_hDC);
	graphics.DrawImage(m_pngLogo,Gdiplus::Point(0,0));
	return 0;
}
Beispiel #27
0
double ASSISTANT::Text::GetTextWidth(const _TCHAR *textString, int textLength, LOGFONT *logFont)
{
   if (textLength == 0)
      return 0;

   HDC hdc = ::CreateCompatibleDC(NULL);

   //Gdiplus::Graphics graphics(hdc);

   WCHAR *wcString = (WCHAR *)malloc((textLength+1)*sizeof(WCHAR));

#ifdef _UNICODE
   wcscpy(wcString, textString);
#else
   MultiByteToWideChar(CP_ACP, 0, textString, textLength+1, 
                                  wcString, textLength+1);
#endif

   
   Gdiplus::RectF bbox;
   Gdiplus::Font font(hdc, logFont);
   
   Gdiplus::Graphics graphics(hdc);
   graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAliasGridFit);
   Gdiplus::StringFormat strFormat(Gdiplus::StringFormatFlagsMeasureTrailingSpaces);

   graphics.MeasureString(wcString, textLength, &font, Gdiplus::PointF(0.0, 0.0), &strFormat, &bbox);

   Gdiplus::CharacterRange charRange(0, textLength);
   strFormat.SetMeasurableCharacterRanges(1, &charRange);
   Gdiplus::Region pRangeRegion[1];
   graphics.MeasureCharacterRanges(wcString, textLength,
                                   &font, bbox, &strFormat, 1, pRangeRegion);
   // get bounding rectangle
   Gdiplus::RectF rect;
   pRangeRegion[0].GetBounds(&rect, &graphics);

   if (wcString)
      delete wcString;

   ::DeleteObject(hdc);
   ::DeleteDC(hdc);

   return rect.Width;
}
Beispiel #28
0
STDMETHODIMP CGaugeOverlay::Render(LONG hdc)
{
	long val = 0;

	IMeter *iMeter;
	get_meter(&iMeter);
	if (iMeter && SUCCEEDED(iMeter->GetAsLong(selector, &val)))
	{
		GraphicsPath path(FillModeAlternate);

		long max, min, length, thickness;
		get_Max(&max);
		get_Min(&min);
		get_Length(&length);
		get_Thickness(&thickness);
		long size = max - min;
		long offset = val - min;

		path.AddRectangle(RectF(0.0, 0.0, (float)length, (float)thickness));

		REAL el[6];
		CumulativeTransform(size, offset, el);
		Matrix matrix(el[0], el[1], el[2], el[3], el[4], el[5]);

		path.Transform(&matrix);
   
		Graphics graphics((HDC)hdc);
		graphics.SetInterpolationMode(InterpolationModeHighQuality);
		graphics.SetSmoothingMode(SmoothingModeAntiAlias);
		graphics.SetPixelOffsetMode(PixelOffsetModeHalf);

		long rgb;
		BYTE alpha;
		get_Color(&rgb);
		get_Alpha(&alpha);
		Color color;
		color.SetFromCOLORREF(rgb);
		rgb = color.GetValue() & 0x00FFFFFF;
		color.SetValue(rgb | ((long)alpha << 24));
		SolidBrush  fg(color);
 		graphics.FillPath(&fg, &path);
	}

	return S_OK;
}
void ImageWindow::OnPaint(HDC hdc, ImageWindow* wnd)
{
	if(wnd->_backgroundImage)
	{
		Gdiplus::Graphics graphics(hdc);
		CHECK_GDIPLUS_STATUS(graphics.GetLastStatus());
		
		CachedBitmapDrawer::CheckedDrawCachedBitmap(wnd->_backgroundImage_cached, wnd->_backgroundImage.get(), &graphics);
		
		// working version
		/*if(!_backgroundImage_cached || !CHECK_GDIPLUS_STATUS_TO_BOOL(graphics.DrawCachedBitmap(wnd->_backgroundImage_cached.get(), 0, 0)))
		{
			_backgroundImage_cached.reset(new Gdiplus::CachedBitmap(wnd->_backgroundImage.get(), &graphics));
			CHECK_GDIPLUS_STATUS(_backgroundImage_cached->GetLastStatus());
			CHECK_GDIPLUS_STATUS(graphics.DrawCachedBitmap(wnd->_backgroundImage_cached.get(), 0, 0));
		}*/
	}
}
Beispiel #30
0
void CCherryStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CRect clientRect;
	GetClientRect(&clientRect);

	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CCherryMemDC memDC(pDC, clientRect);
	Graphics graphics(memDC.GetSafeHdc());

	if (m_pBackMemDC)
		m_pBackMemDC->Draw(&memDC);

	CString strText;
	GetWindowText(strText);

	if (!strText.IsEmpty())
		DrawText(&graphics, strText, clientRect);
}