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. how to paint a bitmap on client?

how to paint a bitmap on client?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsperformancetutorialquestion
5 Posts 4 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.
  • D Offline
    D Offline
    derek7
    wrote on last edited by
    #1

    case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hdcMem = CreateCompatibleDC (hdc) ; SelectObject (hdcMem, hBitmap) ; BitBlt (hdc, 0, 0, cx , cy, hdcMem, 0, 0, SRCCOPY) ; DeleteDC (hdcMem) ; EndPaint (hwnd, &ps) ; return 0 ; it is a way,but how to paint without memory device context? but SelectObject (hdc, hBitmap) does not put bitmap on screen.

    C H 2 Replies Last reply
    0
    • D derek7

      case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hdcMem = CreateCompatibleDC (hdc) ; SelectObject (hdcMem, hBitmap) ; BitBlt (hdc, 0, 0, cx , cy, hdcMem, 0, 0, SRCCOPY) ; DeleteDC (hdcMem) ; EndPaint (hwnd, &ps) ; return 0 ; it is a way,but how to paint without memory device context? but SelectObject (hdc, hBitmap) does not put bitmap on screen.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      derek7 wrote:

      but how to paint without memory device context?

      if you can get your image as a DIB, you can use StretchDIBits (and related functions). but if you have an HBITMAP/CBitmap, you'll need to use a memory DC. Cleek | Image Toolkits | Thumbnail maker

      1 Reply Last reply
      0
      • D derek7

        case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; hdcMem = CreateCompatibleDC (hdc) ; SelectObject (hdcMem, hBitmap) ; BitBlt (hdc, 0, 0, cx , cy, hdcMem, 0, 0, SRCCOPY) ; DeleteDC (hdcMem) ; EndPaint (hwnd, &ps) ; return 0 ; it is a way,but how to paint without memory device context? but SelectObject (hdc, hBitmap) does not put bitmap on screen.

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        Hi derek7, CImage m_Image; m_Image.Load("c:\\picture.bmp"); void CAnswerView::OnPaint() { CPaintDC dc(this); // device context for painting m_Image.BitBlt(dc.m_hDC,CRect(0,0,800,600),CPoint(0,0)); } -- modified at 9:04 Monday 13th March, 2006

        J 1 Reply Last reply
        0
        • H Hamid Taebi

          Hi derek7, CImage m_Image; m_Image.Load("c:\\picture.bmp"); void CAnswerView::OnPaint() { CPaintDC dc(this); // device context for painting m_Image.BitBlt(dc.m_hDC,CRect(0,0,800,600),CPoint(0,0)); } -- modified at 9:04 Monday 13th March, 2006

          J Offline
          J Offline
          James R Twine
          wrote on last edited by
          #4

          -Although you do NOT want to keep on loading the image file each time you get a paint message...    Peace! -=- James


          If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          DeleteFXPFiles & CheckFavorites (Please rate this post!)

          H 1 Reply Last reply
          0
          • J James R Twine

            -Although you do NOT want to keep on loading the image file each time you get a paint message...    Peace! -=- James


            If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
            Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
            DeleteFXPFiles & CheckFavorites (Please rate this post!)

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            Thank you for remind

            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