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 display the Bitmap that created by CreateBitmap function?

How to display the Bitmap that created by CreateBitmap function?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiongraphicsperformancetutorial
14 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.
  • N Naveen

    vasu_sri wrote:

    CDC dcCompatible; if ( !dcCompatible.CreateCompatibleDC( pDC ) )

    this will not work. Yous should pass the pointer of original device context. it can be modified as follows CClientDc dc(this) CDC dcCompatible; if ( !dcCompatible.CreateCompatibleDC( &dc ) )

    nave

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #4

    I don't think this is the problem. Actually I don't think it is a problem.

    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.

    In testa che avete, signor di Ceprano?

    N 1 Reply Last reply
    0
    • N Naveen

      In addition to the above post, you must bitblit the content from memdc to dc in the CThumbBmpView::OnPaint()function after the statement OnDraw(&memDC);

      nave

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #5

      I agree only on this (see my reply above). Additionally, the OP have to first select the bitmap inside the memDC. To summarize, the OP has to: (1) Create a compatible (memory) DC (2) Select the bitmap inside the memory DC. (3) Preform Perform BitBlt from the MemDC to the actual one. Hope that helps :)

      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.

      In testa che avete, signor di Ceprano?

      N 1 Reply Last reply
      0
      • CPalliniC CPallini

        I agree only on this (see my reply above). Additionally, the OP have to first select the bitmap inside the memDC. To summarize, the OP has to: (1) Create a compatible (memory) DC (2) Select the bitmap inside the memory DC. (3) Preform Perform BitBlt from the MemDC to the actual one. Hope that helps :)

        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.

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #6

        CPallini wrote:

        (1) Create a compatible (memory) DC (2) Select the bitmap inside the memory DC.

        I think the CXTPBufferDC will be hadling this.

        nave

        V 1 Reply Last reply
        0
        • CPalliniC CPallini

          I don't think this is the problem. Actually I don't think it is a problem.

          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.

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #7

          I bet itwill not work unless you change it.

          nave

          CPalliniC 1 Reply Last reply
          0
          • N Naveen

            CPallini wrote:

            (1) Create a compatible (memory) DC (2) Select the bitmap inside the memory DC.

            I think the CXTPBufferDC will be hadling this.

            nave

            V Offline
            V Offline
            vasu_sri
            wrote on last edited by
            #8

            i did all what u asked me to do. i converted CDC to CClientDc. But still it doesn't work. i am doing this for the first time and so can u please explain me a little more clearly?? or can u give me any related link that can help me???

            Regards, Srinivas

            N 1 Reply Last reply
            0
            • N Naveen

              I bet itwill not work unless you change it.

              nave

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #9

              And why? :)

              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.

              In testa che avete, signor di Ceprano?

              N 1 Reply Last reply
              0
              • CPalliniC CPallini

                And why? :)

                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.

                N Offline
                N Offline
                Naveen
                wrote on last edited by
                #10

                try for your self..

                nave

                CPalliniC 1 Reply Last reply
                0
                • V vasu_sri

                  i did all what u asked me to do. i converted CDC to CClientDc. But still it doesn't work. i am doing this for the first time and so can u please explain me a little more clearly?? or can u give me any related link that can help me???

                  Regards, Srinivas

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #11

                  if(!bitmap.CreateBitmap(1000,500,1,32,Buffer)) The bitmap file not only contains the pixel data information. It also contain a file header. But the CreateBitmap funtion only need bufffer information. So you must remove the header information from the buffer before passing it to CreateBitmap function. But still I dont understand why you directly read the bitmap. My suggestion is to use the LoadImage() instead of this.

                  nave

                  V 1 Reply Last reply
                  0
                  • N Naveen

                    if(!bitmap.CreateBitmap(1000,500,1,32,Buffer)) The bitmap file not only contains the pixel data information. It also contain a file header. But the CreateBitmap funtion only need bufffer information. So you must remove the header information from the buffer before passing it to CreateBitmap function. But still I dont understand why you directly read the bitmap. My suggestion is to use the LoadImage() instead of this.

                    nave

                    V Offline
                    V Offline
                    vasu_sri
                    wrote on last edited by
                    #12

                    Naveen R wrote:

                    But still I dont understand why you directly read the bitmap. My suggestion is to use the LoadImage() instead of this.

                    its because i don't have the File name or the file path with me. i just have the addresses of the starting sector and ending sector of the image file to work with. i am then reading the data between those sectors (which is nothing but the data of the image file) into a buffer. now i want to show the preview of that image by just using the data in the buffer before storing it as a file. i am still not able to succeed in what i am trying to do.

                    Regards, Srinivas

                    N 1 Reply Last reply
                    0
                    • V vasu_sri

                      Naveen R wrote:

                      But still I dont understand why you directly read the bitmap. My suggestion is to use the LoadImage() instead of this.

                      its because i don't have the File name or the file path with me. i just have the addresses of the starting sector and ending sector of the image file to work with. i am then reading the data between those sectors (which is nothing but the data of the image file) into a buffer. now i want to show the preview of that image by just using the data in the buffer before storing it as a file. i am still not able to succeed in what i am trying to do.

                      Regards, Srinivas

                      N Offline
                      N Offline
                      Naveen
                      wrote on last edited by
                      #13

                      pls check the article http://www.codeproject.com/bitmap/graphicsuite.asp[^] it have code for reading a bitmap file...

                      nave

                      1 Reply Last reply
                      0
                      • N Naveen

                        try for your self..

                        nave

                        CPalliniC Offline
                        CPalliniC Offline
                        CPallini
                        wrote on last edited by
                        #14

                        Good (though empirical) point. I will try... :)

                        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.

                        In testa che avete, signor di Ceprano?

                        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