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 i can save DC in Hbitmap...so i can use it Cimage...in SDI MFC

How i can save DC in Hbitmap...so i can use it Cimage...in SDI MFC

Scheduled Pinned Locked Moved C / C++ / MFC
c++
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.
  • H humais

    How i can save DC in Hbitmap...so i can use in Cimage to save shapes(Rectangles,Circles) on image...

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #2

    You cannot, a DC is effectively an output device that is created as and when you need to draw on it. Just save enough information about your shapes to redraw them on any DC.

    It's time for a new signature.

    H 1 Reply Last reply
    0
    • L Lost User

      You cannot, a DC is effectively an output device that is created as and when you need to draw on it. Just save enough information about your shapes to redraw them on any DC.

      It's time for a new signature.

      H Offline
      H Offline
      humais
      wrote on last edited by
      #3

      i'm not trying to save dc......i'm trying to attach HBITMAP in CIMAGE...i also want to know tht how i can save shapes in Hbitmap??? so i can save jpg through CIMAGE... :confused:

      L 1 Reply Last reply
      0
      • H humais

        i'm not trying to save dc......i'm trying to attach HBITMAP in CIMAGE...i also want to know tht how i can save shapes in Hbitmap??? so i can save jpg through CIMAGE... :confused:

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #4

        humais wrote:

        i'm not trying to save dc

        Well the subject of your post says "How i can save DC in Hbitmap".

        humais wrote:

        .i'm trying to attach HBITMAP in CIMAGE

        I'm not sure what you mean by this, can you make your question clearer?

        humais wrote:

        .i also want to know tht how i can save shapes in Hbitmap??? so i can save jpg through CIMAGE

        Again your question is not clear. As I said earlier, you can save all the information about your shapes so that they may be recreated in some future application.

        It's time for a new signature.

        1 Reply Last reply
        0
        • H humais

          How i can save DC in Hbitmap...so i can use in Cimage to save shapes(Rectangles,Circles) on image...

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

          See, for instance, "Capturing an Image". :)

          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]

          H 1 Reply Last reply
          0
          • C CPallini

            See, for instance, "Capturing an Image". :)

            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]

            H Offline
            H Offline
            humais
            wrote on last edited by
            #6

            i draw some shapes on Cimage & i want to save (shape + CImage)...so how can i do this?? :confused:

            C 1 Reply Last reply
            0
            • H humais

              i draw some shapes on Cimage & i want to save (shape + CImage)...so how can i do this?? :confused:

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

              Save the CImage then. :)

              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]

              H 1 Reply Last reply
              0
              • C CPallini

                Save the CImage then. :)

                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]

                H Offline
                H Offline
                humais
                wrote on last edited by
                #8

                plzzz tell me the coding plzzzz :sigh:

                C L 2 Replies Last reply
                0
                • H humais

                  plzzz tell me the coding plzzzz :sigh:

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

                  Could you please post your code? Isn't so clear what you have really done and what you're trying to accomplish. :)

                  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]

                  1 Reply Last reply
                  0
                  • H humais

                    plzzz tell me the coding plzzzz :sigh:

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #10

                    Try reading the documentation[^]. Hint: look at the Save method.

                    It's time for a new signature.

                    H 1 Reply Last reply
                    0
                    • L Lost User

                      Try reading the documentation[^]. Hint: look at the Save method.

                      It's time for a new signature.

                      H Offline
                      H Offline
                      humais
                      wrote on last edited by
                      #11

                      Here is the code... //hbm & image are decleared in ChildView class but not initialized in any function...if i have to initialized them ,then how i can initialized them??

                      HBitmap hbm;CImage image;

                      //the following code is in OnPaint(); function

                      CDC *mdc = GetDC ();
                      HGDIOBJ tmp = mdc->SelectObject(hbm);
                      mdc->TextOutA (50, 50, Text("Testing"));
                      image.Attach (hbm);

                      also tell me tht where i have to put image.Atach();function..i mean in OnPaint(); or in Save function?? :confused: //I'm drawing different shapes in OnPaint(); function using

                      CPaintDC dc(this);//Like dc.Rectangle(&rect);

                      & i want to attach it with CImage so i can save them... It is a SDI MFC non View/Doc arch. application...Plz tell me in Detail

                      L 1 Reply Last reply
                      0
                      • H humais

                        Here is the code... //hbm & image are decleared in ChildView class but not initialized in any function...if i have to initialized them ,then how i can initialized them??

                        HBitmap hbm;CImage image;

                        //the following code is in OnPaint(); function

                        CDC *mdc = GetDC ();
                        HGDIOBJ tmp = mdc->SelectObject(hbm);
                        mdc->TextOutA (50, 50, Text("Testing"));
                        image.Attach (hbm);

                        also tell me tht where i have to put image.Atach();function..i mean in OnPaint(); or in Save function?? :confused: //I'm drawing different shapes in OnPaint(); function using

                        CPaintDC dc(this);//Like dc.Rectangle(&rect);

                        & i want to attach it with CImage so i can save them... It is a SDI MFC non View/Doc arch. application...Plz tell me in Detail

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        I'm not sure of all the steps you need to follow to achieve what you are trying to do, but I would suggest you follow my previous advice and study the CImage class and its members to see what functions are available to create your bitmap and save it to a file. You could also search the articles here on CodeProject and Google for sample code. [edit]I just saw this article[^] which contains some useful tips.[/edit]

                        It's time for a new signature.

                        H 1 Reply Last reply
                        0
                        • L Lost User

                          I'm not sure of all the steps you need to follow to achieve what you are trying to do, but I would suggest you follow my previous advice and study the CImage class and its members to see what functions are available to create your bitmap and save it to a file. You could also search the articles here on CodeProject and Google for sample code. [edit]I just saw this article[^] which contains some useful tips.[/edit]

                          It's time for a new signature.

                          H Offline
                          H Offline
                          humais
                          wrote on last edited by
                          #13

                          i want to know the mistakes in my code... CPallini plzz tell me how i can do that??

                          L 1 Reply Last reply
                          0
                          • H humais

                            i want to know the mistakes in my code... CPallini plzz tell me how i can do that??

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #14

                            humais wrote:

                            i want to know the mistakes in my code

                            What code? I have no idea what you are trying to do apart from saving something to do with GDI, for which incidentally, you have been given the answer in a previous thread.

                            humais wrote:

                            CPallini

                            Who he?

                            humais wrote:

                            plzz tell me how i can do that??

                            The word is please! And you can do whatever it is you need by studying samples and the documentation that I pointed you to earlier (both cases).

                            It's time for a new signature.

                            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