Search Results

Search found 9 results on 1 pages for 'cbitmap'.

Page 1/1 | 1 

  • Create a CBitmap from Resources ID

    - by Smashery
    I need to fill a CImageList with a number of bitmaps which are stored in separate bmp files (rather than as a single bmp with numerous parts). I assume I need to create a CBitmap so I can call the Add method of CImageList. So how might one create a CBitmap object using only MFC Resource IDs?

    Read the article

  • Scaling a CBitmap - what am I doing wrong?

    - by Smashery
    I've written the following code, which attempts to take a 32x32 bitmap (loaded through MFC's Resource system) and turn it into a 16x16 bitmap, so they can be used as the big and small CImageLists for a CListCtrl. However, when I open the CListCtrl, all the icons are black (in both small and large view). Before I started playing with resizing, everything worked perfectly in Large View. What am I doing wrong? // Create the CImageLists if (!m_imageListL.Create(32,32,ILC_COLOR24, 1, 1)) { throw std::exception("Failed to create CImageList"); } if (!m_imageListS.Create(16,16,ILC_COLOR24, 1, 1)) { throw std::exception("Failed to create CImageList"); } // Fill the CImageLists with items loaded from ResourceIDs int i = 0; for (std::vector<UINT>::iterator it = vec.begin(); it != vec.end(); it++, i++) { CBitmap* bmpBig = new CBitmap(); bmpBig->LoadBitmap(*it); CDC bigDC; bigDC.CreateCompatibleDC(m_itemList.GetDC()); bigDC.SelectObject(bmpBig); CBitmap* bmpSmall = new CBitmap(); bmpSmall->CreateBitmap(16, 16, 1, 24, 0); CDC smallDC; smallDC.CreateCompatibleDC(&bigDC); smallDC.SelectObject(bmpSmall); smallDC.StretchBlt(0, 0, 32, 32, &bigDC, 0, 0, 16, 16, SRCCOPY); m_imageListL.Add(bmpBig, RGB(0,0,0)); m_imageListS.Add(bmpSmall, RGB(0,0,0)); } m_itemList.SetImageList(&m_imageListS, LVSIL_SMALL); m_itemList.SetImageList(&m_imageListL, LVSIL_NORMAL);

    Read the article

  • Load a png resource into a CBitMap

    - by Rohit Sasikumar
    How do i load a png resource into a CBitMap? When i try this it doesnt work. CImage image; image.LoadFromResource(AfxGetInstanceHandle(), IDB_PNG1); bitmap.Attach(image.Detach()); It gives me an error resource type not found. Is there any other way to load a PNG resource?

    Read the article

  • Can't Display Bitmap of Higher Resolution than CDC area

    - by T. Jones
    Hi there dear gurus and expert coders. i am not gonna start with im a newbie and don't know much about image programming but unfortunately those are the facts :( I am trying to display an image from a bitmap pointer *ImageData which is of resolution 1392x1032. I am trying to draw that at an area of resolution or size 627x474. However, repeated trying doesnt seem to work. It works when I change the bitmap image I created from *ImageData width and height to resolution or size of around 627x474 I really do not know how to solve this after trying all possible solutions from various forums and google. pDC is a CDC* and memDC is a CDC initialized in an earlier method Anything uninitialized here was initialized in other methods. Here is my code dear humble gurus. Do provide me with guidance Yoda and Obi-Wan provided to Luke Skywalker. void DemoControl::ShowImage( void *ImageData ) { int Width; //Width of Image From Camera int Height; //Height of Image From Camera int m_DisplayWidth = 627 ;//width of rectangle area to display int m_DisplayHeight = 474;//height of rectangle area to display GetImageSize( &Width, &Height ) ; //this will return Width = 1392, Height 1032 CBitmap bitmap; bitmap.CreateBitmap(Width,Height,32,1,ImageData); CBitmap* pOldBitmap = memDC.SelectObject((CBitmap*)&bitmap); pDC->BitBlt(22, 24, 627, 474, &memDC, 0, 0, SRCCOPY); memDC.SelectObject((CBitmap*)pOldBitmap); ReleaseDC(pDC); }

    Read the article

  • How do I repass a function pointer in C++

    - by fneep
    Firstly, I am very new to function pointers and their horrible syntax so play nice. I am writing a method to filter all pixels in my bitmap based on a function that I pass in. I have written the method to dereference it and call it in the pixel buffer but I also need a wrapper method in my bitmap class that takes the function pointer and passes it on. How do I do it? What is the syntax? I'm a little stumped. Here is my code with all the irrelevant bits stripped out and files combined (read all variables initialized filled etc.). struct sColour { unsigned char r, g, b, a; }; class cPixelBuffer { private: sColour* _pixels; int _width; int _height; int _buffersize; public: void FilterAll(sColour (*FilterFunc)(sColour)); }; void cPixelBuffer::FilterAll(sColour (*FilterFunc)(sColour)) { // fast fast fast hacky FAST for (int i = 0; i < _buffersize; i++) { _pixels[i] = (*FilterFunc)(_pixels[i]); } } class cBitmap { private: cPixelBuffer* _pixels; public: inline void cBitmap::Filter(sColour (*FilterFunc)(sColour)) { //HERE!! } };

    Read the article

  • how to load image from file using MFC

    - by Sweety Khan
    **my browse button code is void CFileOpenDlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here CFileDialog dlg(TRUE); int result=dlg.DoModal(); if(result==IDOK) { path=dlg.GetPathName(); UpdateData(FALSE); } } and this is the code for loading an image from resource but tht does not work for loading an image from file. i know LoadImage(); is used for this but how? how can i edit this code to load image from file. Plzz help..... void CFileOpenDlg::OnBnClickedButton2() { // TODO: Add your control notification handler code here CRect r; CBitmap* m_bitmap; CDC dc, *pDC; BITMAP bmp; m_bitmap = new CBitmap(); m_bitmap-LoadBitmapW(IDB_BITMAP1); m_bitmap-GetBitmap(&bmp); pDC = this-GetDC(); dc.CreateCompatibleDC(pDC); dc.SelectObject(m_bitmap); pDC-BitBlt(200, 200, bmp.bmWidth, bmp.bmHeight, &dc,0 , 0, SRCCOPY); m_bitmap-DeleteObject(); m_bitmap-Detach(); } waiting for reply........**

    Read the article

  • Is it possible to create a CImageList with alpha blending transparency?

    - by Sorin Sbarnea
    I would like to knwo if it is possible to create a CImageList with alpha blending transparency. Sample code that creates a CImageList with ugly transparency (no alpha blending) CGdiPlusBitmapResource m_pBitmap; m_pBitmap.Load(IDB_RIBBON_FILESMALL,_T("PNG"),AfxGetResourceHandle()); HBITMAP hBitmap; m_pBitmap.m_pBitmap->GetHBITMAP(RGB(0,0,0),&hBitmap ); CImageList *pList=new CImageList; CBitmap bm; bm.Attach(hBitmap); pList->Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 4); pList->Add(&bm, RGB(255,0,255));

    Read the article

  • VMRMixerControl9 & GDI problem!

    - by freefallr
    I'm attempting to overlay a bitmap on some video. I create a bitmap in memory, then I call SelectObject to select it into a memoryDC, so I can perform a DrawText operation on it. I'm not getting any results on screen at all - can anyone suggest why? thanks HRESULT MyGraph::MixTextOverVMR9(LPCTSTR szText) { // create a bitmap object using GDI, render the text to it accordingly // then Sets the bitmap as an alpha bitmap to the VMR9, so that it can be overlayed. HRESULT hr = S_OK; CBitmap bmpMem; CFont font; LOGFONT logicfont; CRect rcText; CRect rcVideo; VMR9AlphaBitmap alphaBmp; HWND hWnd = this->GetFirstRendererWindow(); COLORREF clrText = RGB(255, 255, 0); COLORREF clrBlack = RGB(0,0,0); HDC hdcHwnd = NULL; CDC dcMem; LONG lWidth; LONG lHeight; if( ! m_spVideoRenderer.p ) return E_NOINTERFACE; if( !m_spWindowlessCtrl.p ) return E_NOINTERFACE; if( ! m_spIMixerBmp9.p ) { m_spIMixerBmp9 = m_spVideoRenderer; if( ! m_spIMixerBmp9.p ) return E_NOINTERFACE; } // create the font.. LPCTSTR sFont = _T("Times New Roman"); memset(&logicfont, 0, sizeof(LOGFONT)); logicfont.lfHeight = 42; logicfont.lfWidth = 20; logicfont.lfStrikeOut = 0; logicfont.lfUnderline = 0; logicfont.lfItalic = FALSE; logicfont.lfWeight = FW_NORMAL; logicfont.lfEscapement = 0; logicfont.lfCharSet = ANSI_CHARSET; logicfont.lfQuality = ANTIALIASED_QUALITY; logicfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; wcscpy_s( &logicfont.lfFaceName[0], wcslen(sFont)*2, sFont ); font.CreateFontIndirectW(&logicfont); // create a compatible memDC from the video window's HDC if( hWnd == NULL ) return E_FAIL; hdcHwnd = GetDC(hWnd); dcMem = CreateCompatibleDC(hdcHwnd); // get the required bitmap metrics from the MediaBuffer if( ! SUCCEEDED(m_spWindowlessCtrl->GetNativeVideoSize(&lWidth, &lHeight, NULL, NULL)) ) return E_FAIL; // create a bitmap for the text bmpMem.CreateCompatibleBitmap(dcMem.m_hDC, lWidth, lHeight); SelectBitmap (dcMem.m_hDC, bmpMem); SetBkMode (dcMem.m_hDC, TRANSPARENT); SetTextColor (dcMem.m_hDC, clrText); SelectFont (dcMem.m_hDC, font.m_hFont); // draw the text DrawTextW(dcMem.m_hDC, szText, wcslen(szText), rcText, DT_CALCRECT | DT_NOPREFIX ); DrawTextW(dcMem.m_hDC, szText, wcslen(szText), rcText, DT_NOPREFIX ); // Set the alpha bitmap on the VMR9 renderer memset(&alphaBmp, 0, sizeof(VMR9AlphaBitmap)); alphaBmp.rDest.left = 0; alphaBmp.rDest.top = 0.5; alphaBmp.rDest.right = 0.5; alphaBmp.rDest.bottom = 1; alphaBmp.dwFlags = VMR9AlphaBitmap_hDC; alphaBmp.hdc = dcMem.m_hDC; alphaBmp.pDDS = NULL; alphaBmp.rSrc = rcText; // rect to copy from the source image alphaBmp.fAlpha = 0.5f; // transparency value (1.0 is opaque, 0.0 is transparent) alphaBmp.clrSrcKey = clrText; // alphaBmp.dwFilterMode = MixerPref9_AnisotropicFiltering; hr = m_spIMixerBmp9->SetAlphaBitmap(&alphaBmp); DeleteDC(hdcHwnd); dcMem.DeleteDC(); bmpMem.DeleteObject(); font.DeleteObject(); return hr; }

    Read the article

1