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. ATL / WTL / STL
  4. Bitblit with WTL

Bitblit with WTL

Scheduled Pinned Locked Moved ATL / WTL / STL
c++graphicshelp
5 Posts 3 Posters 2 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.
  • T Offline
    T Offline
    Tommy2k
    wrote on last edited by
    #1

    Hi, I can't get bitblit to work with WTL. It keeps printing a black square. But the size of the square is equal to the size of the image it should print so i think i'm forgetting something. I'm converting my Win32/SDK app to WTL and in Win32/SDK it works. This is the code i'm using: //to load: CBitmap Image; Image.LoadBitmap(238); //to paint: CPaintDC dc(m_hWnd); CDC hdc; hdc.CreateCompatibleDC(dc.m_hDC); BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0); I tried making a filledrect with the same DC object and it worked. Thanks for all help.

    S B 2 Replies Last reply
    0
    • T Tommy2k

      Hi, I can't get bitblit to work with WTL. It keeps printing a black square. But the size of the square is equal to the size of the image it should print so i think i'm forgetting something. I'm converting my Win32/SDK app to WTL and in Win32/SDK it works. This is the code i'm using: //to load: CBitmap Image; Image.LoadBitmap(238); //to paint: CPaintDC dc(m_hWnd); CDC hdc; hdc.CreateCompatibleDC(dc.m_hDC); BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0); I tried making a filledrect with the same DC object and it worked. Thanks for all help.

      S Offline
      S Offline
      saierdia
      wrote on last edited by
      #2

      modify the line to : SelectObject(hdc.m_hDC,Image);

      T 1 Reply Last reply
      0
      • S saierdia

        modify the line to : SelectObject(hdc.m_hDC,Image);

        T Offline
        T Offline
        Tommy2k
        wrote on last edited by
        #3

        Doesn't seem to help. It keeps blitting an empty (black) surface to my screen...the size is correct though so the loading prolly is ok.... Anyone?

        1 Reply Last reply
        0
        • T Tommy2k

          Hi, I can't get bitblit to work with WTL. It keeps printing a black square. But the size of the square is equal to the size of the image it should print so i think i'm forgetting something. I'm converting my Win32/SDK app to WTL and in Win32/SDK it works. This is the code i'm using: //to load: CBitmap Image; Image.LoadBitmap(238); //to paint: CPaintDC dc(m_hWnd); CDC hdc; hdc.CreateCompatibleDC(dc.m_hDC); BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0); I tried making a filledrect with the same DC object and it worked. Thanks for all help.

          B Offline
          B Offline
          Ben Burnett
          wrote on last edited by
          #4

          Try replacing: Tommy2k wrote: BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0); with something like:

          HBITMAP hOldBitmap = hdc.SelectBitmap ( (HBITMAP) Image );
          SIZE dim;
          Image.GetBitmapDimension ( &dim );
          dc.BitBlt ( 50, 50, dim.cx, dim.cy, (HDC) hdc, 0, 0, SRCCOPY );
          dcBW.SelectBitmap ( hOldBitmap );

          cheers, -B

          T 1 Reply Last reply
          0
          • B Ben Burnett

            Try replacing: Tommy2k wrote: BITMAP Temp; Image.GetBitmap(&Temp); SelectObject(hdc.m_hDC,&Temp); dc.BitBlt(50,50,Temp.bmWidth,Temp.bmHeight,hdc,0,0,0); with something like:

            HBITMAP hOldBitmap = hdc.SelectBitmap ( (HBITMAP) Image );
            SIZE dim;
            Image.GetBitmapDimension ( &dim );
            dc.BitBlt ( 50, 50, dim.cx, dim.cy, (HDC) hdc, 0, 0, SRCCOPY );
            dcBW.SelectBitmap ( hOldBitmap );

            cheers, -B

            T Offline
            T Offline
            Tommy2k
            wrote on last edited by
            #5

            Thanks, i works now :-)

            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