void FormEditorWin::Redraw(SynthWidget *wdg) { if (wdg) { Graphics *gr = new Graphics(m_hWnd); Graphics *gr2 = 0; if (offscrn) gr2 = Graphics::FromImage(offscrn); else gr2 = gr; wdg->Paint((DrawContext)gr2); SynthWidget *bud = wdg->GetBuddy2(); if (bud) bud->Paint((DrawContext)gr2); if (offscrn) { delete gr2; wdgRect a = wdg->GetArea(); gr->DrawImage(offscrn, a.x, a.y, a.x, a.y, a.w, a.h, UnitPixel); if (bud) { a = bud->GetArea(); gr->DrawImage(offscrn, a.x, a.y, a.x, a.y, a.w, a.h, UnitPixel); } } delete gr; } else InvalidateRect(NULL, 0); }
void CHeightMapPanel::OnPaint() { CPaintDC dc(this); // device context for painting Graphics *graph = Graphics::FromHDC(dc.GetSafeHdc()); if (m_heightMap) { // 텍스쳐 출력. if (CWnd *pictureCtlr = GetDlgItem(IDC_STATIC_TEXTURE)) { CRect cr; pictureCtlr->GetWindowRect(cr); ScreenToClient(cr); const Rect dest(cr.left, cr.top, cr.Width(), cr.Height()); graph->DrawImage(m_heightMap, dest ); } } if (m_texture) { // 텍스쳐 출력. if (CWnd *pictureCtlr = GetDlgItem(IDC_STATIC_TEXTURE2)) { CRect cr; pictureCtlr->GetWindowRect(cr); ScreenToClient(cr); const Rect dest(cr.left, cr.top, cr.Width(), cr.Height()); graph->DrawImage(m_texture, dest ); } } }
wxBitmap* gdiplusResize(wxBitmap* bitmap, const FloatSize& size) { IntSize intSize = IntSize(ceilf(size.width()), ceilf(size.height())); if (intSize.width() == bitmap->GetWidth() && intSize.height() == bitmap->GetHeight()) return new wxBitmap(*bitmap); // just return a copy if the asked for the same size wxBitmap* newBitmap = new wxBitmap(intSize.width(), intSize.height(), 32); newBitmap->UseAlpha(); wxMemoryDC memdc(*newBitmap); wxGraphicsContext* gc = wxGraphicsContext::Create(memdc); wxGraphicsBitmap gcbitmap(gc->CreateBitmap(*bitmap)); Graphics* graphics = (Graphics*)gc->GetNativeContext(); graphics->Clear(Gdiplus::Color(0, 0, 0, 0)); // Only use HighQualityBicubic when downsampling. InterpolationMode mode; if (size.width() < (int)bitmap->GetWidth() && size.height() < (int)bitmap->GetHeight()) mode = InterpolationModeHighQualityBicubic; else mode = InterpolationModeBicubic; graphics->SetInterpolationMode(mode); graphics->DrawImage((Bitmap*)gcbitmap.GetNativeBitmap(), 0.0, 0.0, size.width(), size.height()); premultiplyAlpha(*newBitmap); delete gc; return newBitmap; }
void CSplashWnd::OnPaint() { CPaintDC dc (this); Graphics g (dc.GetSafeHdc ()); g.DrawImage ((Bitmap*) *m_pBitmap, 0, 0, m_nWidth, m_nHeight); }
void Widget::WriteNumberFromStrip(Graphics* g, int theNumber, int theX, int theY, Image* theNumberStrip, int aSpacing) { int aDivisor = 10; int aNumDigits = 1; while (theNumber >= aDivisor) { aNumDigits++; aDivisor *= 10; } if (theNumber == 0) aDivisor = 10; int aDigitLen = theNumberStrip->GetWidth() / 10; for (int aDigitIdx = 0; aDigitIdx < aNumDigits; aDigitIdx++) { aDivisor /= 10; int aDigit = (theNumber / aDivisor) % 10; Graphics* aClipG = g->Create(); aClipG->ClipRect(theX + aDigitIdx*(aDigitLen + aSpacing), theY, aDigitLen, theNumberStrip->GetHeight()); aClipG->DrawImage(theNumberStrip, theX + aDigitIdx*(aDigitLen + aSpacing) - aDigit*aDigitLen, theY); delete aClipG; } }
/* ** Draws the meter on the double buffer ** */ bool CMeterRotator::Draw(Graphics& graphics) { if (!CMeter::Draw(graphics)) return false; if (m_Image.IsLoaded()) { // Calculate the center for rotation int x = GetX(); int y = GetY(); REAL cx = (REAL)(x + m_W / 2.0); REAL cy = (REAL)(y + m_H / 2.0); // Calculate the rotation REAL angle = (REAL)(CONVERT_TO_DEGREES(m_RotationAngle * m_Value + m_StartAngle)); graphics.TranslateTransform(cx, cy); graphics.RotateTransform(angle); graphics.TranslateTransform((REAL)-m_OffsetX, (REAL)-m_OffsetY); Bitmap* drawBitmap = m_Image.GetImage(); UINT width = drawBitmap->GetWidth(); UINT height = drawBitmap->GetHeight(); // Blit the image graphics.DrawImage(drawBitmap, 0, 0, width, height); graphics.ResetTransform(); } return true; }
void ImageButton::Paint(Graphics &g) { Component::Paint(g); Image *anImage = NULL; if(Disabled()) anImage = mImages[ImageButtonType_Disabled]; else if(IsChecked() && mImages[ImageButtonType_Checked].get()!=NULL) anImage = mImages[4]; else if(IsButtonDown()) anImage = mImages[ImageButtonType_Down]; else if(IsMouseOver())// || HasFocus()) anImage = mImages[ImageButtonType_Over]; if(anImage==NULL) anImage = mImages[ImageButtonType_Normal]; if(anImage!=NULL) { if(mStretch && (anImage->GetWidth()!=Width() || anImage->GetHeight()!=Height())) anImage->SetSize(Width(),Height()); g.DrawImage(anImage,0,0); } }
Bitmap* ResizeBitmap(Bitmap* source, int percentage) { int w = source->GetWidth()*percentage/100; if(w < 1) w = 1; int h = source->GetHeight()*percentage/100; if(h < 1) h = 1; Bitmap* b = new Bitmap(w, h, source->GetPixelFormat()); if(b) { Graphics* g = Graphics::FromImage(b); if(g) { g->DrawImage(source, 0, 0, w, h); delete g; } else { delete b; b = NULL; } } return b; }
Bitmap *Cell::getImageThumb() { if( this->thumb == NULL ) { Image *img = this->getImage(); if( img != NULL ) { this->thumb = new Bitmap(THB_SIZE,THB_SIZE,Core::getPixelFormat()); int frame = 1; Graphics *gfx = Graphics::FromImage(this->thumb); int iwidth = img->GetWidth(); int iheight = img->GetHeight(); int thbSize = THB_SIZE - 4*frame; if( iwidth > thbSize || iheight > thbSize ) { double dx = (double)thbSize / (double)iwidth; double dy = (double)thbSize / (double)iheight; iwidth = (int)(min(dx,dy) * iwidth); iheight = (int)(min(dx,dy) * iheight); } int x = max( (int)((thbSize - iwidth) / 2), 2*frame ); int y = max( (int)((thbSize - iheight) / 2), 2*frame ); gfx->DrawImage(img,x,y,iwidth,iheight); delete gfx; delete img; } } return this->thumb; }
//[-------------------------------------------------------] //[ Protected virtual PLGui::Widget functions ] //[-------------------------------------------------------] void GuiButton::OnDraw(Graphics &cGraphics) { // Call base implementation Widget::OnDraw(cGraphics); // Draw background if (m_cBackground.GetPointer()) cGraphics.DrawImage(*m_cBackground.GetPointer(), Vector2i::Zero, GetSize()); // Is the font valid? if (m_pFont) { // Get the text color to use const Color4 &cColor = m_bMouseOver ? m_cMouseOverColor : m_cColor; // Get text alignment if (m_nAlign == AlignLeft) { // Left aligned uint32 nHeight = cGraphics.GetTextHeight(*m_pFont, m_sText); cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, Vector2i(0, GetSize().y/2 - nHeight/2), m_sText); } else if (m_nAlign == AlignRight) { // Right aligned uint32 nWidth = cGraphics.GetTextWidth(*m_pFont, m_sText); uint32 nHeight = cGraphics.GetTextHeight(*m_pFont, m_sText); cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, Vector2i(GetSize().x - nWidth, GetSize().y/2 - nHeight/2), m_sText); } else if (m_nAlign == AlignCenter) { // Centered uint32 nWidth = cGraphics.GetTextWidth(*m_pFont, m_sText); uint32 nHeight = cGraphics.GetTextHeight(*m_pFont, m_sText); cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, Vector2i((GetSize().x - nWidth)/2, GetSize().y/2 - nHeight/2), m_sText); } else if (m_nAlign == AlignBlock) { // Draw block text Vector2i vPos (0, 0); Vector2i vSize(GetSize()); // Draw text word for word RegEx cRegEx("\\s*([^\\s]+)"); uint32 nParsePos = 0; while (cRegEx.Match(m_sText, nParsePos)) { // Get word nParsePos = cRegEx.GetPosition(); String sWord = cRegEx.GetResult(0); // Get text width int nWidth = cGraphics.GetTextWidth(*m_pFont, sWord); if (vPos.x + nWidth >= vSize.x) { // Line break vPos.x = 0; vPos.y = vPos.y + cGraphics.GetTextHeight(*m_pFont, sWord); } // Draw word cGraphics.DrawText(*m_pFont, cColor, Color4::Transparent, vPos, sWord); // Next word vPos.x += nWidth + 8; } } } }
DWORD WINAPI Layer::anim(LPVOID param) { Layer *that = (Layer *)param; WaitForSingleObject(that->mut_animloop,INFINITE); WaitForSingleObject(that->mut_image,INFINITE); if( that->image == NULL ){ ReleaseMutex(that->mut_image); return 0; } int propertySize = that->image->GetPropertyItemSize(PropertyTagFrameDelay); PropertyItem *frameDelay = (PropertyItem*) malloc(propertySize); that->image->GetPropertyItem(PropertyTagFrameDelay,propertySize,frameDelay); ReleaseMutex(that->mut_image); long *delays = (long *)frameDelay->value; bool mode = false; while( true ){ if( that->isTopmost() == false ) break; if( WaitForSingleObject(that->mut_terminator,0) != WAIT_TIMEOUT ){ ReleaseMutex(that->mut_terminator); ReleaseMutex(that->mut_animloop); return 0; } Sleep( max((delays[that->frameThat] * 100),MINDELAY) ); WaitForSingleObject(that->mut_image,INFINITE); if( that->gifdir == RIGHT ) mode = that->nextFrame(); else if( that->gifdir == LEFT ) mode = that->prevFrame(); if( that->scali != NULL ) delete that->scali; that->scali = NULL; if( that->rot != ROT_0 ){ that->scali = new Bitmap(that->image->GetWidth(),that->image->GetHeight()); Graphics *gfx = Graphics::FromImage(that->scali); gfx->DrawImage(that->image,0,0,that->scali->GetWidth(),that->scali->GetHeight()); delete gfx; } ReleaseMutex(that->mut_image); if( that->rot != ROT_0 ) that->rotate(that->scali); that->invalidate(mode); } if( frameDelay != NULL ) delete frameDelay; ReleaseMutex(that->mut_animloop); return 0; }
void Bitmap::OnDraw(Graphics &cGraphics) { // Call base implementation Widget::OnDraw(cGraphics); // Draw image // [TODO] PLGui: Was m_cImage.GetSize() ?! cGraphics.DrawImage(m_cImage, Vector2i::Zero, GetSize()); }
void CBacnetAlarmWindow::OnPaint() { CPaintDC dc(this); // device context for painting // Do not call CDialogEx::OnPaint() for painting messages CMemDC memDC(dc,this); CRect rcClient; GetClientRect(&rcClient); memDC.GetDC().FillSolidRect(&rcClient,RGB(230,230,230)); Graphics *mygraphics; mygraphics = new Graphics(memDC.GetDC()); mygraphics->SetSmoothingMode(SmoothingModeAntiAlias); CRect test_rect; HWND temp_hwnd = this->m_hWnd; ::GetWindowRect(temp_hwnd,&test_rect); //获取 view的窗体大小; Bitmap bitmap(show_bitmap,NULL); mygraphics->DrawImage(&bitmap,0 ,0,test_rect.Width(),test_rect.Height()); delete mygraphics; //Graphics graphics(memDC.GetDC()); //SolidBrush *BlackBrush; //SolidBrush *CharacterBlackBrush; //Graphics *mygraphics; //mygraphics = new Graphics(memDC.GetDC()); //mygraphics->SetSmoothingMode(SmoothingModeAntiAlias); //BlackBrush =new SolidBrush(MY_COLOR_RED) ; //CharacterBlackBrush = new SolidBrush(MY_COLOR_BLACK_CHARACTER); //mygraphics->FillRectangle(BlackBrush,0,0,rcClient.Width(),40); //FontFamily CharacterfontFamily(_T("Arial")); //PointF TitlepointF(0, 0); //SolidBrush TitleCharacterColor(Color(255,255,255,255)); //Gdiplus::Font Scroll_font(&CharacterfontFamily, 28, FontStyleBold, UnitPixel); //TitlepointF.X = 250; //TitlepointF.Y = 5; //mygraphics->DrawString(_T("Remote Connect procedure"), -1, &Scroll_font, TitlepointF,&TitleCharacterColor); //PointF WarningMessagePoint(0, 0); //SolidBrush WarningMessageColor(Color(255,0,0,0)); //Gdiplus::Font WarningMessageFont(&CharacterfontFamily, 21, FontStyleRegular, UnitPixel); //SolidBrush MessageRetColor(Color(255,0,255,255)); //CString step1_message; end_connect_paint: return; }
void TextImage::Paint(Graphics &g, TextArea *theTextArea) { if(theTextArea->mSelStartChar<=mAbsStartChar && theTextArea->mSelEndChar>=mAbsEndChar) { g.SetColor(theTextArea->mSelColor.GetBackgroundColor(g)); g.FillRect(mx,0,mWidth,mLine->mHeight); } g.DrawImage(mImage,mx,my); }
/****************************************************************************** * 作用: 在内存中预先绘制图像 ******************************************************************************/ void CGraphShowerView::PreDrawImage(void) { Image image(GetFilePath(m_nPos)); ::delete m_pBitmap; m_pBitmap = ::new Bitmap(image.GetWidth(), image.GetHeight(), PixelFormat32bppARGB); Graphics* graph = Graphics::FromImage(m_pBitmap); graph->DrawImage(&image, 0, 0, image.GetWidth(), image.GetHeight()); SAFE_DELETE (graph); }
void Character::Draw() { const s_Polygon& ImgPos = GetPolygon(); Sprite.Pos->X = (int)ImgPos.MinX; Sprite.Pos->Y = (int)ImgPos.MinY; Screen->DrawImage(Sprite); //imgpos << "X: " << Sprite.Pos->X << " " << "Y: " << Sprite.Pos->Y << std::endl; //boxpos << "MinX: " << ImgPos.MinX << " " << "MinY: " << ImgPos.MinY << std::endl; }
Bitmap* IrisBitmap::ScaleBitmap(Bitmap* srcBitmap, int width, int height){ Bitmap* tpBitmap = new Bitmap(width, height, srcBitmap->GetPixelFormat()); if(tpBitmap){ Graphics* g = new Graphics(tpBitmap); if(g){ // use the best interpolation mode g->SetInterpolationMode(InterpolationModeHighQualityBicubic); g->DrawImage(srcBitmap, 0, 0, width, height); delete g; } } return tpBitmap; }
Bitmap * ScaleBitmap( Bitmap *& pSrc, UINT nCx, UINT nCy, BOOL bCreate ) { if (pSrc == NULL) return NULL; if (nCx < 1 || nCy < 1) return NULL; Bitmap * pResult = NULL; if (pSrc->GetWidth() == nCx && pSrc->GetHeight() == nCy) { if (bCreate) { return pSrc->Clone( 0, 0, nCx, nCy, pSrc->GetPixelFormat() ); } else { return pSrc; } } pResult = new Bitmap( nCx, nCy, pSrc->GetPixelFormat() ); if( pResult == NULL ) return NULL; Graphics * g = Graphics::FromImage(pResult); if ( g == NULL) { delete pResult; pResult = NULL; return NULL; } // use the best interpolation mode g->SetInterpolationMode(InterpolationModeHighQualityBicubic); Status status = g->DrawImage(pSrc, 0, 0, nCx, nCy); delete g; g= NULL; if ( Ok != status ) { delete pResult; pResult = NULL; return NULL; } if (!bCreate) { delete pSrc; pSrc = pResult; } return pResult; }
/* gamma 参数的典型值在 1.0 到 2.2 之间;但在某些情况下,0.1 到 5.0 范围内的值也很有用。 imageAttr.SetGamma 参数值越大,图像越暗,反之则越亮 */ Bitmap * HighlightBitmap(Bitmap * pSrc, float fGamma, BOOL bCreate ) { if (pSrc == NULL) return NULL; if (fGamma <= 0.0f) return NULL; RectF rc(0.0f, 0.0f, (float)pSrc->GetWidth(), (float)pSrc->GetHeight()); if ( rc.IsEmptyArea()) return NULL; Bitmap * pResult = !bCreate ? pSrc : new Bitmap( (int)rc.Width, (int)rc.Height, pSrc->GetPixelFormat() ); if( pResult == NULL ) return NULL; Graphics * g = Graphics::FromImage(pResult); if ( g == NULL) { if (bCreate) { delete pResult; pResult = NULL; } return NULL; } ImageAttributes imageAttr; ////////////////////////////////////////////////////////////////////////// #if TRUE imageAttr.SetGamma( 1/fGamma ); #else Gdiplus:: ColorMatrix HotMat = {1.05f, 0.00f, 0.00f, 0.00f,0.00f, 0.00f, 1.05f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 1.05f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 1.00f, 0.00f, 0.05f, 0.05f, 0.05f, 0.00f, 1.00f}; imageAttr.SetColorMatrix(&HotMat); #endif ////////////////////////////////////////////////////////////////////////// Status status = g->DrawImage(pSrc, rc, 0, 0, (float)pSrc->GetWidth(), (float)pSrc->GetHeight() ,Gdiplus:: UnitPixel, &imageAttr); delete g; g = NULL; if ( Ok != status ) { if (bCreate) { delete pResult; pResult = NULL; } return NULL; } return pResult; }
Bitmap *Cell::getImageThumb(int width, int height) { Image *img = this->getImage(); if( img != NULL ) { Bitmap *thumb = new Bitmap(width,height,Core::getPixelFormat()); Graphics *gfx = Graphics::FromImage(thumb); gfx->DrawImage(img,0,0,width,height); delete gfx; delete img; return thumb; } return NULL; }
// 画图片边框(可指定九宫格的位置,nX/nY是原图的左上角,nWH/nHL是左上角点坐标,nWR/nHR是右下角点坐标) void DrawImageFrameMID(Graphics &graphics, Image *pImage, const CRect &rcControl, int nX, int nY, int nW, int nH, int nWL, int nHL, int nWR, int nHR) { // 左上角 graphics.DrawImage(pImage, Rect(rcControl.left ,rcControl.top, nWL, nHL), nX, nY, nWL, nHL, UnitPixel); // 左中边框 graphics.DrawImage(pImage, Rect(rcControl.left ,rcControl.top + nHL, nWL, rcControl.Height() - nHL - nHR), nX, nY + nHL, nWL, nH - nHL - nHR, UnitPixel); // 左下角 graphics.DrawImage(pImage, Rect(rcControl.left ,rcControl.bottom - nHR, nWL, nHR), nX, nY + nH - nHR, nWL, nHR, UnitPixel); // 上中边框 graphics.DrawImage(pImage, Rect(rcControl.left + nWL ,rcControl.top, rcControl.Width() - nWL - nWR, nHL), nX + nWL, nY, nW - nWL - nWR, nHL, UnitPixel); // 右上角 graphics.DrawImage(pImage, Rect(rcControl.right - nWR ,rcControl.top, nWR, nHL), nX + nW - nWR, nY, nWR, nHL, UnitPixel); // 右中边框 graphics.DrawImage(pImage, Rect(rcControl.right - nWR ,rcControl.top + nHL, nWR, rcControl.Height() - nHL - nHR), nX + nW - nWR, nY + nHL, nWR, nH - nHL - nHR, UnitPixel); // 右下角 graphics.DrawImage(pImage, Rect(rcControl.right - nWR ,rcControl.bottom - nHR, nWR, nHR), nX + nW - nWR, nY + nH - nHR, nWR, nHR, UnitPixel); // 下中边框 graphics.DrawImage(pImage, Rect(rcControl.left + nWL ,rcControl.bottom - nHR, rcControl.Width() - nWL - nWR, nHR), nX + nWL, nY + nH - nHR, nW - nWL - nWR, nHR, UnitPixel); // 中间 graphics.DrawImage(pImage, Rect(rcControl.left + nWL ,rcControl.top + nHL, rcControl.Width() - nWL - nWR, rcControl.Height() - nHL - nHR), nX + nWL, nY + nHL, nW - nWL - nWR, nH - nHL - nHR, UnitPixel); }
// 画图片边框 void DrawImageFrame(Graphics &graphics, Image *pImage, const CRect &rcControl, int nX, int nY, int nW, int nH, int nFrameSide/* = 4*/) { // 左上角 graphics.DrawImage(pImage, Rect(rcControl.left ,rcControl.top, nFrameSide, nFrameSide), nX, nY, nFrameSide, nFrameSide, UnitPixel); // 左中边框 graphics.DrawImage(pImage, Rect(rcControl.left ,rcControl.top + nFrameSide, nFrameSide, rcControl.Height() - 2 * nFrameSide), nX, nY + nFrameSide, nFrameSide, nH - 2 * nFrameSide, UnitPixel); // 左下角 graphics.DrawImage(pImage, Rect(rcControl.left ,rcControl.bottom - nFrameSide, nFrameSide, nFrameSide), nX, nY + nH - nFrameSide, nFrameSide, nFrameSide, UnitPixel); // 上中边框 graphics.DrawImage(pImage, Rect(rcControl.left + nFrameSide ,rcControl.top, rcControl.Width() - 2 * nFrameSide, nFrameSide), nX + nFrameSide, nY, nW - 2 * nFrameSide, nFrameSide, UnitPixel); // 右上角 graphics.DrawImage(pImage, Rect(rcControl.right - nFrameSide ,rcControl.top, nFrameSide, nFrameSide), nX + nW - nFrameSide, nY, nFrameSide, nFrameSide, UnitPixel); // 右中边框 graphics.DrawImage(pImage, Rect(rcControl.right - nFrameSide ,rcControl.top + nFrameSide, nFrameSide, rcControl.Height() - 2 * nFrameSide), nX + nW - nFrameSide, nY + nFrameSide, nFrameSide, nH - 2 * nFrameSide, UnitPixel); // 右下角 graphics.DrawImage(pImage, Rect(rcControl.right - nFrameSide ,rcControl.bottom - nFrameSide, nFrameSide, nFrameSide), nX + nW - nFrameSide, nY + nH - nFrameSide, nFrameSide, nFrameSide, UnitPixel); // 下中边框 graphics.DrawImage(pImage, Rect(rcControl.left + nFrameSide ,rcControl.bottom - nFrameSide, rcControl.Width() - 2 * nFrameSide, nFrameSide), nX + nFrameSide, nY + nH - nFrameSide, nW - 2 * nFrameSide, nFrameSide, UnitPixel); // 中间 graphics.DrawImage(pImage, Rect(rcControl.left + nFrameSide ,rcControl.top + nFrameSide, rcControl.Width() - 2 * nFrameSide, rcControl.Height() - 2 * nFrameSide), nX + nFrameSide, nY + nFrameSide, nW - 2 * nFrameSide, nH - 2 * nFrameSide, UnitPixel); }
Image *Layer::scale(Image *source) { if( source == NULL ) return NULL; double zoom = this->zoom; if( source != this->image ) zoom = this->getZoom(source->GetWidth(),source->GetHeight()); int width = (int)(zoom * source->GetWidth()); int height = (int)(zoom * source->GetHeight()); Bitmap *bmp = new Bitmap(width,height); Graphics *gfx = Graphics::FromImage(bmp); gfx->DrawImage(source,0,0,width,height); delete gfx; return bmp; }
void View::Redraw(ControlPtr c) { if (_hWnd == NULL) return; HDC hdc = GetDC(_hWnd); Graphics g(hdc); Graphics *gg = Graphics::FromImage(_gbuf); SolidBrush b(_backcolor); gg->FillRectangle(&b, c->_dirty_rect); if (_bmp) { gg->DrawImage(_bmp, c->_dirty_rect.X, c->_dirty_rect.Y, c->_dirty_rect.X, c->_dirty_rect.Y, c->_dirty_rect.Width, c->_dirty_rect.Height, UnitPixel); } for (ClstPtr cc = _cl.begin(); cc != _cl.end(); cc++) if ((*cc)->_dirty_rect.IntersectsWith(c->_dirty_rect)) { if (*cc != c) (*cc)->OnDraw(gg); } c->OnDraw(gg); delete gg; g.DrawImage(_gbuf, c->_dirty_rect.X, c->_dirty_rect.Y, c->_dirty_rect.X, c->_dirty_rect.Y, c->_dirty_rect.Width, c->_dirty_rect.Height, UnitPixel ); ReleaseDC(_hWnd, hdc); c->_repaint = false; }
void CGraphDlg::OnPaint() { CPaintDC pDC(this); // device context for painting GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Graphics* pGraphics; Image *pImage = NULL; pGraphics = new Graphics(pDC); pImage = new Image(m_fPath); pGraphics->DrawImage(pImage, 0, 50); delete pImage; delete pGraphics; GdiplusShutdown(gdiplusToken); }
HRESULT CMediaController::DrawKeyFrame(HWND hWnd) { if (!m_pBitmap) { return E_FAIL; } Graphics* grph = new Graphics(hWnd); if (!grph) { return E_FAIL; } Status st = grph->DrawImage( m_pBitmap, 0, 0); delete grph; return S_OK; }
void ImageDelegate::Draw(Graphics & gph, RECT const &update_bound) { gph.DrawImage( &m_image, Rect(m_bound.left, m_bound.top, m_bound.right - m_bound.left, m_bound.bottom - m_bound.top), 0, 0, m_image.GetWidth(), m_image.GetHeight(), UnitPixel, NULL ) ; /* RECT temp_bound ; std::vector<RECT>::iterator iter ; for (iter = m_bound_group.begin() ; iter != m_bound_group.end() ; ++ iter) { if (::IntersectRect(&temp_bound, &update_bound, &(*iter))) { gph.DrawImage( &m_image, Rect(iter->left, iter->top, iter->right - iter->left, iter->bottom - iter->top), 0, 0, m_image.GetWidth(), m_image.GetHeight(), UnitPixel, NULL ) ; } }*/ }
void FontSheet::BuildFontSheetBitmap(Font& font, Graphics& charGraphics, Bitmap& charBitmap, Graphics& fontSheetGraphics) { WCHAR charString[2] = {' ', 0}; SolidBrush whiteBrush(Color(255, 255, 255, 255)); UINT fontSheetX = 0; UINT fontSheetY = 0; for(UINT i = 0; i < NumChars; ++i) { charString[0] = static_cast<WCHAR>(StartChar + i); charGraphics.Clear(Color(0, 0, 0, 0)); charGraphics.DrawString(charString, 1, &font, PointF(0.0f, 0.0f), &whiteBrush); // Compute tight char horizontal bounds (ignoring empty space). int minX = GetCharMinX(charBitmap); int maxX = GetCharMaxX(charBitmap); int charWidth = maxX - minX + 1; // Move to next row of the font sheet? if(fontSheetX + charWidth >= mTexWidth) { fontSheetX = 0; fontSheetY += static_cast<int>(mCharHeight) + 1; } // Save the rectangle of this character on the texture atlas. mCharRects[i] = CD3D11_RECT(fontSheetX, fontSheetY, fontSheetX + charWidth, fontSheetY + mCharHeight); // The rectangle subset of the source image to copy. fontSheetGraphics.DrawImage(&charBitmap, fontSheetX, fontSheetY, minX, 0, charWidth, mCharHeight, UnitPixel); // next char fontSheetX += charWidth + 1; } }
void View::Paint(Graphics *g) { if (_gbuf == NULL) return; Graphics *gg = Graphics::FromImage(_gbuf); gg->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); gg->Clear(_backcolor); if (_bmp) { gg->DrawImage(_bmp, 0, 0, _bmp->GetWidth(), _bmp->GetHeight()); } for (ClstPtr c = _cl.begin(); c != _cl.end(); c++) (*c)->OnDraw(gg); delete gg; g->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality); g->DrawImage(_gbuf, 0, 0); }
Bitmap * StretchBitmap(Bitmap * pSrcBmp, int nWidth,int nHeight) { if (nWidth<=0 || nHeight <=0) return NULL; Bitmap *bmpStretched = new Bitmap(nWidth,nHeight); if (NULL == bmpStretched) return NULL; Graphics * pGraphics = NULL; pGraphics = Graphics::FromImage(bmpStretched); if (pGraphics!=NULL) { //将pSrcBmp画到画布pGraphics上 pGraphics->DrawImage(pSrcBmp,Rect(0,0,nWidth,nHeight)); return bmpStretched; } else { delete bmpStretched; return NULL; } }