size_t wxBitmapDataObject::GetDataSize() const { #if wxUSE_WXDIB return wxDIB::ConvertFromBitmap(NULL, GetHbitmapOf(GetBitmap())); #else return 0; #endif }
wxObject * MaxBitmapComboBoxXmlHandler::DoCreateResource() { if (m_class == wxT("ownerdrawnitem")) { wxCHECK_MSG(m_combobox, NULL, wxT("Incorrect syntax of XRC resource: ownerdrawnitem not within a bitmapcombobox!")); m_combobox->Append(GetText(wxT("text")), GetBitmap(wxT("bitmap"), wxART_MISSING_IMAGE)); return m_combobox; } else /*if( m_class == wxT("wxBitmapComboBox"))*/ { // find the selection long selection = GetLong( wxT("selection"), -1 ); XRC_MAKE_INSTANCE(control, MaxBitmapComboBox) control->Create(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), 0, NULL, GetStyle(), wxDefaultValidator, GetName()); control->MaxBind(_wx_wxbitmapcombobox_wxBitmapComboBox__xrcNew(control)); m_isInside = true; m_combobox = control; wxXmlNode *children_node = GetParamNode(wxT("object")); wxXmlNode *n = children_node; while (n) { if ((n->GetType() == wxXML_ELEMENT_NODE) && (n->GetName() == wxT("object"))) { CreateResFromNode(n, control, NULL); } n = n->GetNext(); } m_isInside = false; m_combobox = NULL; if (selection != -1) control->SetSelection(selection); SetupWindow(control); return control; } }
wxObject* wxRibbonXmlHandler::Handle_galleryitem() { wxRibbonGallery *gallery = wxStaticCast(m_parent, wxRibbonGallery); wxCHECK (gallery, NULL); gallery->Append (GetBitmap(), GetID()); return NULL; // nothing to return }
void Sprite::Render(Bitmap& bitmap) { if (!visible_) { return; } GetBitmap().Blit((int)GetCel(),bitmap,Round(GetX()-GetOriginX()),Round(GetY()-GetOriginY()),GetColor(),GetAlpha()); }
void CBitmapEx::SethBitmap(int iWidth, int iHeight, HDC hdc) { _hBitmap = CreateCompatibleBitmap( hdc, iWidth, iHeight); GetObject(hGethBitmap(), sizeof(BITMAP), &GetBitmap()); }
// Obtain a mask bitmap. A mask bitmap is a bitmap which has // all pixels with the color "crColor" set to white and all // other pixels set to black. HBITMAP ClsBitmap::GetMaskBitmap( COLORREF crColor, int nXPos /* = 0 */, int nYPos /* = 0 */ ) const { _ASSERT_VALID( m_hGdiObject ); // Must be valid. // Preset result. BOOL bResult = FALSE; HBITMAP hMaskBM = NULL; // Create the necessary device contexts. ClsDC dcSrc, dcDst; if ( dcSrc.CreateCompatibleDC( NULL ) && dcDst.CreateCompatibleDC( NULL )) { // Get source bitmap information. BITMAP bm; if ( GetBitmap( &bm )) { // Create a monochrome bitmap of the same size. hMaskBM = ::CreateBitmap( bm.bmWidth, bm.bmHeight, 1, 1, NULL ); if ( hMaskBM ) { // Select both the source and destination bitmaps. HGDIOBJ hOldSrc = dcSrc.SelectObject( m_hGdiObject ); HGDIOBJ hOldDst = dcDst.SelectObject( hMaskBM ); _ASSERT( hOldSrc && hOldDst ); // Obtain the color used to create the mask bitmap. if ( crColor == CLR_DEFAULT ) crColor = dcSrc.GetPixel( nXPos, nYPos ); // Change the background color to the masked color. COLORREF crOldBkCol = dcSrc.SetBkColor( crColor ); // Copy the source into the destination which creates // the mask. if ( dcDst.BitBlt( 0, 0, bm.bmWidth, bm.bmHeight, &dcSrc, 0, 0, SRCCOPY )) // Success... bResult = TRUE; // Restore background color. dcSrc.SetBkColor( crOldBkCol ); // Restore old bitmaps. dcSrc.SelectObject( hOldSrc ); dcDst.SelectObject( hOldDst ); // Destroy it if no successful. if ( bResult == FALSE ) ::DeleteObject( hMaskBM ); } } } // Destroy DCs if ( dcSrc.IsValid()) dcSrc.DeleteDC(); if ( dcDst.IsValid()) dcDst.DeleteDC(); return bResult == TRUE ? hMaskBM : NULL; }
void C4DefGraphics::Draw(C4Facet &cgo, DWORD iColor, C4Object *pObj, int32_t iPhaseX, int32_t iPhaseY, C4DrawTransform* trans) { // default: def picture rect C4Rect fctPicRect = pDef->PictureRect; C4Facet fctPicture; // if assigned: use object specific rect and graphics if (pObj) if (pObj->PictureRect.Wdt) fctPicRect = pObj->PictureRect; // specific object color? if (pObj) pObj->PrepareDrawing(); switch(Type) { case C4DefGraphics::TYPE_Bitmap: fctPicture.Set(GetBitmap(iColor),fctPicRect.x,fctPicRect.y,fctPicRect.Wdt,fctPicRect.Hgt); fctPicture.DrawTUnscaled(cgo,true,iPhaseX,iPhaseY,trans); break; case C4DefGraphics::TYPE_Mesh: // TODO: Allow rendering of a mesh directly, without instance (to render pose; no animation) std::unique_ptr<StdMeshInstance> dummy; StdMeshInstance* instance; C4Value value; if (pObj) { instance = pObj->pMeshInstance; pObj->GetProperty(P_PictureTransformation, &value); } else { dummy.reset(new StdMeshInstance(*Mesh, 1.0f)); instance = dummy.get(); pDef->GetProperty(P_PictureTransformation, &value); } StdMeshMatrix matrix; if (C4ValueToMatrix(value, &matrix)) pDraw->SetMeshTransform(&matrix); pDraw->SetPerspective(true); pDraw->RenderMesh(*instance, cgo.Surface, cgo.X,cgo.Y, cgo.Wdt, cgo.Hgt, pObj ? pObj->Color : iColor, trans); pDraw->SetPerspective(false); pDraw->SetMeshTransform(NULL); break; } if (pObj) pObj->FinishedDrawing(); // draw overlays if (pObj && pObj->pGfxOverlay) for (C4GraphicsOverlay *pGfxOvrl = pObj->pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext()) if (pGfxOvrl->IsPicture()) pGfxOvrl->DrawPicture(cgo, pObj, trans); }
////////////////// // Attach is just like the CGdiObject version, // except it also creates the palette // BOOL CDib::Attach(HGDIOBJ hbm) { if (CBitmap::Attach(hbm)) { if (!GetBitmap(&m_bm)) // load BITMAP for speed return FALSE; m_pal.DeleteObject(); // in case one is already there return CreatePalette(m_pal); // create palette } return FALSE; }
void ReconcileProjectDlg::OnUndoSelectedFiles(wxCommandEvent& event) { wxDataViewItemArray items; m_dataviewAssigned->GetSelections(items); for(size_t i=0; i<items.GetCount(); ++i) { wxVariant v; ReconcileFileItemData* data = dynamic_cast<ReconcileFileItemData*>(m_dataviewAssignedModel->GetClientObject( items.Item(i) )); if ( data ) { wxFileName fn(data->GetFilename()); fn.MakeRelativeTo(m_toplevelDir); wxVector<wxVariant> cols; cols.push_back(::MakeIconText(fn.GetFullPath(), GetBitmap(fn.GetFullName()))); m_dvListCtrl1Unassigned->AppendItem( cols, (wxUIntPtr)NULL ); } } // get the list of items wxArrayString allfiles; for(int i=0 ; i<m_dvListCtrl1Unassigned->GetItemCount(); ++i) { wxVariant v; m_dvListCtrl1Unassigned->GetValue(v, i, 0); wxDataViewIconText it; it << v; allfiles.Add(it.GetText()); } m_dataviewAssignedModel->DeleteItems(wxDataViewItem(0), items); // Could not find a nicer way of doing this, but // we want the files to be sorted again m_dvListCtrl1Unassigned->DeleteAllItems(); std::sort(allfiles.begin(), allfiles.end()); for(size_t i=0; i<allfiles.GetCount(); ++i) { wxVector<wxVariant> cols; cols.push_back( ::MakeIconText(allfiles.Item(i), GetBitmap(allfiles.Item(i)) ) ); m_dvListCtrl1Unassigned->AppendItem( cols, (wxUIntPtr)NULL); } }
void cVnsiOsd::Flush(void) { if (!Active()) return; cBitmap *Bitmap; bool full = cVnsiOsdProvider::IsRequestFull(); for (int i = 0; (Bitmap = GetBitmap(i)) != NULL; i++) { uint8_t reset = !shown || full; Cmd(VNSI_OSD_OPEN, i, Bitmap->Bpp(), Left() + Bitmap->X0(), Top() + Bitmap->Y0(), Left() + Bitmap->X0() + Bitmap->Width() - 1, Top() + Bitmap->Y0() + Bitmap->Height() - 1, (void *)&reset, 1); int x1 = 0, y1 = 0, x2 = 0, y2 = 0; if (!shown || Bitmap->Dirty(x1, y1, x2, y2) || full) { if (!shown || full) { x1 = y1 = 0; x2 = Bitmap->Width() - 1; y2 = Bitmap->Height() - 1; } // commit colors: int NumColors; const tColor *Colors = Bitmap->Colors(NumColors); if (Colors) { Cmd(VNSI_OSD_SETPALETTE, i, 0, NumColors, 0, 0, 0, Colors, NumColors*sizeof(tColor)); } // commit modified data: int size = (y2-y1) * Bitmap->Width() + (x2-x1+1); Cmd(VNSI_OSD_SETBLOCK, i, Bitmap->Width(), x1, y1, x2, y2, Bitmap->Data(x1, y1), size); } Bitmap->Clean(); } if (!shown) { // Showing the windows in a separate loop to avoid seeing them come up one after another for (int i = 0; (Bitmap = GetBitmap(i)) != NULL; i++) { Cmd(VNSI_OSD_MOVEWINDOW, i, 0, Left() + Bitmap->X0(), Top() + Bitmap->Y0()); } shown = true; } }
int NewBitmapCursor(Cursor *cp, char *source, char *mask) { XColor fore, back; int hotx, hoty; int sx, sy, mx, my; unsigned int sw, sh, mw, mh; Pixmap spm, mpm; Colormap cmap = Scr->RootColormaps.cwins[0]->colormap->c; if(dpy == NULL) { // Handle special cases like --cfgchk *cp = None; return 0; } fore.pixel = Scr->Black; XQueryColor(dpy, cmap, &fore); back.pixel = Scr->White; XQueryColor(dpy, cmap, &back); spm = GetBitmap(source); if((hotx = HotX) < 0) { hotx = 0; } if((hoty = HotY) < 0) { hoty = 0; } mpm = GetBitmap(mask); /* make sure they are the same size */ XGetGeometry(dpy, spm, &JunkRoot, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth); XGetGeometry(dpy, mpm, &JunkRoot, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth); if(sw != mw || sh != mh) { fprintf(stderr, "%s: cursor bitmaps \"%s\" and \"%s\" not the same size\n", ProgramName, source, mask); return (1); } *cp = XCreatePixmapCursor(dpy, spm, mpm, &fore, &back, hotx, hoty); return (0); }
void MAS::Progress::UpdateSize() { Bitmap bmp = GetBitmap(); if (!bmp) return; if (orientation == 1) { h(bmp.h()); } else { w(bmp.w()); } }
bool wxBitmapDataObject::GetDataHere(void *buf) const { #if wxUSE_WXDIB && !defined(__WXWINCE__) BITMAPINFO * const pbi = (BITMAPINFO *)buf; return wxDIB::ConvertFromBitmap(pbi, GetHbitmapOf(GetBitmap())) != 0; #else wxUnusedVar(buf); return false; #endif }
void CMyStatic::OnLButtonDown(UINT nFlags, CPoint point) { bool bHandled = false; HBITMAP hBitmap = GetBitmap(); COleDataSourceEx *pDataSrc = NULL; if (m_bDelayRendering) pDataSrc = DelayRenderOleData(hBitmap); else pDataSrc = CacheOleData(hBitmap, false); if (pDataSrc) { if (m_bAllowDropDesc) // Allow targets to show user defined text. pDataSrc->AllowDropDescriptionText(); // Must be called before setting the drag image. CPoint pt(-1, 30000); // Cursor is centered below the image switch (m_nDragImageType & DRAG_IMAGE_FROM_MASK) { case DRAG_IMAGE_FROM_CAPT : // Get drag image from content with optional scaling pDataSrc->InitDragImage(hBitmap, m_nDragImageScale, &pt); break; case DRAG_IMAGE_FROM_RES : // Use bitmap from resources as drag image pDataSrc->InitDragImage(IDB_BITMAP_DRAGME, &pt, CLR_INVALID); break; case DRAG_IMAGE_FROM_HWND : // This window handles DI_GETDRAGIMAGE messages. // pDataSrc->SetDragImageWindow(m_hWnd, &point); // break; case DRAG_IMAGE_FROM_SYSTEM : // Let Windows create the drag image. // With file lists and provided "Shell IDList Array" data, file type images are shown. // Otherwise, a generic image is used. pDataSrc->SetDragImageWindow(NULL, &point); break; case DRAG_IMAGE_FROM_EXT : // Get drag image from file extension using the file type icon pDataSrc->InitDragImage(_T(".bmp"), m_nDragImageScale, &pt); break; // case DRAG_IMAGE_FROM_TEXT : // case DRAG_IMAGE_FROM_BITMAP : default : // Get drag image from content without scaling pDataSrc->InitDragImage(hBitmap, 100, &pt); } m_bDragging = true; // to know when dragging over our own window pDataSrc->DoDragDropEx(DROPEFFECT_COPY); pDataSrc->InternalRelease(); m_bDragging = false; bHandled = true; } if (!bHandled) CStatic::OnLButtonDown(nFlags, point); }
void CBitmapEx::SethBitmap(const TCHAR* szFileName) { _hBitmap = (HBITMAP)LoadImage( NULL, //hInstance=NULL lay cua so hien tai szFileName, //File can lay hinh IMAGE_BITMAP, //loai la bitmap 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE ); GetObject(hGethBitmap(), sizeof(BITMAP), &GetBitmap()); }
wxObject * MaxBannerWindowXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(banner, MaxBannerWindow) banner->Create(m_parentAsWindow, GetID(), GetDirection(wxS("direction")), GetPosition(), GetSize(), GetStyle(wxS("style")), GetName()); banner->MaxBind(CB_PREF(wx_wxbannerwindow_wxBannerWindow__xrcNew)(banner)); SetupWindow(banner); const wxColour colStart = GetColour(wxS("gradient-start")); const wxColour colEnd = GetColour(wxS("gradient-end")); if ( colStart.IsOk() || colEnd.IsOk() ) { if ( !colStart.IsOk() || !colEnd.IsOk() ) { ReportError ( "Both start and end gradient colours must be " "specified if either one is." ); } else { banner->SetGradient(colStart, colEnd); } } wxBitmap bitmap = GetBitmap(); if ( bitmap.IsOk() ) { if ( colStart.IsOk() || colEnd.IsOk() ) { ReportError ( "Gradient colours are ignored by wxBannerWindow " "if the background bitmap is specified." ); } banner->SetBitmap(bitmap); } banner->SetText(GetText(wxS("title")), GetText(wxS("message"))); return banner; }
// Creates the control and returns a pointer to it. wxObject *wxStaticPictureXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(control, wxStaticPicture) control->Create(m_parentAsWindow, GetID(), GetBitmap(wxT("bitmap"), wxART_OTHER, GetSize()), GetPosition(), GetSize(), GetStyle(), GetName()); SetupWindow(control); return control; }
virtual void SetActive(bool On) { if (On != Active()) { cOsd::SetActive(On); if (!On) Clear(); else if (GetBitmap(0)) Flush(); } }
wxSize wxStaticBitmapBase::DoGetBestSize() const { wxSize best; wxBitmap bmp = GetBitmap(); if ( bmp.IsOk() ) best = bmp.GetScaledSize(); else // this is completely arbitrary best = wxSize(16, 16); CacheBestSize(best); return best; }
virtual void Flush(void) { if (!Active() || !m_fb) return; if (IsTrueColor()) { LOCK_PIXMAPS; while (cPixmapMemory *pm = dynamic_cast<cPixmapMemory *>(RenderPixmaps())) { const uint8_t *src = pm->Data(); char *dst = m_fb + (Left() + pm->ViewPort().Left()) * (m_vinfo.bits_per_pixel / 8 ) + (Top() + pm->ViewPort().Top()) * m_finfo.line_length; for (int y = 0; y < pm->DrawPort().Height(); y++) { memcpy(dst, src, pm->DrawPort().Width() * sizeof(tColor)); src += pm->DrawPort().Width() * sizeof(tColor); dst += m_finfo.line_length; } #if APIVERSNUM >= 20110 DestroyPixmap(pm); #else delete pm; #endif } } else { for (int i = 0; cBitmap *bitmap = GetBitmap(i); ++i) { int x1, y1, x2, y2; if (bitmap->Dirty(x1, y1, x2, y2)) { char *dst = m_fb + (Left() + bitmap->X0() + x1) * (m_vinfo.bits_per_pixel / 8 ) + (Top() + bitmap->Y0() + y1) * m_finfo.line_length; for (int y = y1; y <= y2; ++y) { tColor *p = (tColor *)dst; for (int x = x1; x <= x2; ++x) *p++ = bitmap->GetColor(x, y); dst += m_finfo.line_length; } bitmap->Clean(); } } } }
eOsdError cDvbSdFfOsd::SetAreas(const tArea *Areas, int NumAreas) { if (shown) { cBitmap *Bitmap; for (int i = 0; (Bitmap = GetBitmap(i)) != NULL; i++) { Cmd(OSD_SetWindow, 0, i + 1); Cmd(OSD_Close); } shown = false; } return cOsd::SetAreas(Areas, NumAreas); }
unsigned int BitmapImage::GetBufferSize() const { unsigned int bufferSize = 0; Integration::Bitmap* const bitmap = GetBitmap(); if(bitmap) { bufferSize = bitmap->GetBufferSize(); } return bufferSize; }
PixelBuffer* BitmapImage::GetBuffer() { PixelBuffer* buffer = NULL; Integration::Bitmap* const bitmap = GetBitmap(); if(bitmap) { buffer = bitmap->GetBuffer(); } return buffer; }
wxSize wxStaticBitmapBase::DoGetBestSize() const { wxSize best; wxBitmap bmp = GetBitmap(); if ( bmp.Ok() ) best = wxSize(bmp.GetWidth(), bmp.GetHeight()); else // this is completely arbitrary best = wxSize(16, 16); CacheBestSize(best); return best; }
eOsdError cVnsiOsd::SetAreas(const tArea *Areas, int NumAreas) { if (shown) { for (int i = 0; GetBitmap(i); i++) { Cmd(VNSI_OSD_CLOSE, i); } shown = false; } return cOsd::SetAreas(Areas, NumAreas); }
LRESULT CMediaClipView::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CPaintDC dc(m_hWnd); { Gdiplus::Graphics graphics(dc.m_hDC); Gdiplus::Bitmap* pBitmap; GetBitmap(&pBitmap); if (pBitmap) { CRect client; GetClientRect(&client); graphics.DrawImage(pBitmap, m_videoRect, 0, 0, pBitmap->GetWidth(), pBitmap->GetHeight(), Gdiplus::UnitPixel); } } dc.FillSolidRect(&m_bottomRect, GetSysColor(COLOR_BTNFACE)); dc.FillSolidRect(&m_sliderRect, RGB(220, 220, 220)); { /* CComQIPtr<IMediaSeeking> mediaSeeking = m_dsGraph; LONGLONG llpos; mediaSeeking->GetCurrentPosition(&llpos); double seconds = (double)llpos / 10000000; //seconds; */ double secondWidth = m_sliderRect.Width() / m_pStream->m_pDocument->m_duration; int x = m_sliderRect.left + (m_pStream->m_pDocument->m_currentTime * secondWidth); dc.MoveTo(x, m_sliderRect.top); dc.LineTo(x, m_sliderRect.bottom); double clipBegin = m_pStream->m_pDocument->GetClipBegin(); double clipEnd = m_pStream->m_pDocument->GetClipEnd(); x = m_sliderRect.left + (clipBegin * secondWidth); dc.DrawText("{", 1, CRect(x-5, m_sliderRect.top, x+5, m_sliderRect.bottom), DT_CENTER | DT_SINGLELINE); x = m_sliderRect.left + (clipEnd * secondWidth); dc.DrawText("}", 1, CRect(x-5, m_sliderRect.top, x+5, m_sliderRect.bottom), DT_CENTER | DT_SINGLELINE); } return 0; }
void KDIBSection::DecodeDIBSectionFormat(TCHAR desp[]) { DIBSECTION dibsec; if ( GetObject(m_hBitmap, sizeof(DIBSECTION), & dibsec) ) { KDIB::DecodeDIBFormat(desp); _tcscat(desp, _T(" ")); DecodeDDB(GetBitmap(), desp + _tcslen(desp)); } else _tcscpy(desp, _T("Invalid DIB Section")); }
void MAS::Progress::Draw(Bitmap &canvas) { Bitmap bmp = GetBitmap(); if (orientation == 1) { bmp.HorizontalTile(canvas, 0, 0, 0, w(), 2); int ww = (int)(w()*GetPosition()/(GetMax() - GetMin())); bmp.HorizontalTile(canvas, 1, 0, 0, ww, 2); } else { bmp.VerticalTile(canvas, 0, 0, 0, h(), 2); int hh = (int)(h()*GetPosition()/(GetMax() - GetMin())); bmp.VerticalTile(canvas, 1, 0, 0, hh, 2); } }
int BMPanvas::Create(HDC src, BMPINFO* info) { Destroy(); if((hdc=CreateCompatibleDC(src))!=NULL) { hbmp=CreateDIBSection(hdc,(LPBITMAPINFO)(info),DIB_RGB_COLORS,0,0,0); last_hbmp=(HBITMAP)SelectObject(hbmp); GetBitmap(); Rgn=CRect(0,0,w,h); } else ASSERT(0); return (int)hbmp; }
// Draw void VideoView::Draw(BRect updateRect) { if (LockBitmap()) { BRect r(Bounds()); if (const BBitmap* bitmap = GetBitmap()) { if (!fOverlayMode) { DrawBitmap(bitmap, bitmap->Bounds(), r); } } UnlockBitmap(); } }