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. Buffer to HDC handle

Buffer to HDC handle

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelp
4 Posts 3 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.
  • E Offline
    E Offline
    Elsie
    wrote on last edited by
    #1

    I have an 3 rd party API that will a fill a buffer of type LPSTR, This buffer is actually in picture format, i have to convert make this appear in a CStatic control. what i have: BYTE pBuffer; HDC hDC; //HDC handle for the CSttaic Control API will fill this pBuffer (LPSTR)pBuffer I have to make this pBuffer to appear in picture format in CStatic control. Would apprecaite any help.

    C C 2 Replies Last reply
    0
    • E Elsie

      I have an 3 rd party API that will a fill a buffer of type LPSTR, This buffer is actually in picture format, i have to convert make this appear in a CStatic control. what i have: BYTE pBuffer; HDC hDC; //HDC handle for the CSttaic Control API will fill this pBuffer (LPSTR)pBuffer I have to make this pBuffer to appear in picture format in CStatic control. Would apprecaite any help.

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      What do you mean with 'in picture format' ? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      E 1 Reply Last reply
      0
      • C CPallini

        What do you mean with 'in picture format' ? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        E Offline
        E Offline
        Elsie
        wrote on last edited by
        #3

        This "pBuffer" i can save it as a Bitmap format like this..... But i want to draw this pBuffer into a CStatic without converting to Bitmap... CFile file; CString strTemp; char szTemp[MAX_PATH]; char *pDot; GetModuleFileName(AfxGetInstanceHandle(),szTemp,sizeof(szTemp)); pDot = strrchr(szTemp,'.'); *(pDot+1) = 'B'; *(pDot+2) = 'M'; *(pDot+3) = 'P'; strTemp.Format(szTemp,GetTickCount()); file.Open(strTemp,CFile::modeCreate | CFile::modeWrite); file.Write(pBuffer,dwSize); file.Close();

        1 Reply Last reply
        0
        • E Elsie

          I have an 3 rd party API that will a fill a buffer of type LPSTR, This buffer is actually in picture format, i have to convert make this appear in a CStatic control. what i have: BYTE pBuffer; HDC hDC; //HDC handle for the CSttaic Control API will fill this pBuffer (LPSTR)pBuffer I have to make this pBuffer to appear in picture format in CStatic control. Would apprecaite any help.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          According to your answer to CPallini, your buffer contains a BMP file. So, wiki[^] should contain all the information you need to access the pixel data. Also look for BITMAPFILEHEADER, BITMAPINFO and such structures in MSDN, these should help too. You could for example use CreateDIBSection[^] to get a HBITMAP from your data and use it to feed it to a picture (static) control or draw it yourself.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          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