Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with CImage- at second call.

Problem with CImage- at second call.

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++dotnetcomtutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vgrigor
    wrote on last edited by
    #1

    I need to use class CImage, to get Pixels from hBitmap.. I want to use this class in ATL ActiveX dll, whick can be in more that one number created. But following simple code crushes after second call of it, due to some static members of CImage, (not first) It is need be correctly freed, how to do it? Thanks. Code which makes ASSERT, at second call - in other DLL: l_pImage = new CImage(); l_pImage->Attach(hBitmap); //hrgn = CreateRegionTrCr( l_pImage, cTransparentColor); pImage->GetPixel(0, 0); ///HERE !!!! //pImage->Detach(); //pImage->ReleaseGDIPlus(); delete l_pImage; __________ ATL code containing error: inline COLORREF CImage::GetPixel( int x, int y ) const throw() { ATLASSERT( m_hBitmap != NULL ); ATLASSERT( (x >= 0) && (x < m_nWidth) ); ATLASSERT( (y >= 0) && (y < m_nHeight) ); GetDC(); COLORREF clr = ::GetPixel( m_hDC, x, y ); ReleaseDC(); return( clr ); _________ inline void CImage::ReleaseDC() const throw() { HBITMAP hBitmap; ATLASSERT( m_hDC != NULL ); m_nDCRefCount--; if( m_nDCRefCount == 0 ) { hBitmap = HBITMAP( ::SelectObject( m_hDC, m_hOldBitmap ) ); ATLASSERT( hBitmap == m_hBitmap ); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE !!<<<<<< s_cache.ReleaseDC( m_hDC ); m_hDC = NULL; } }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups