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. Save an image using CImage class

Save an image using CImage class

Scheduled Pinned Locked Moved C / C++ / MFC
help
24 Posts 6 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.
  • C CPallini

    Could please post your code? :)

    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]

    V Offline
    V Offline
    VC Maniac
    wrote on last edited by
    #9

    I changed my code to use Image class. I still have the same problem. I open a image file. then try to save it in png format. Save fuction returns "Win32Error" status. GdiplusStartup is successful. What may be wrong?

    H C 2 Replies Last reply
    0
    • V VC Maniac

      I changed my code to use Image class. I still have the same problem. I open a image file. then try to save it in png format. Save fuction returns "Win32Error" status. GdiplusStartup is successful. What may be wrong?

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

      Can you show your code did you attach hbitmap handle to CImage class?

      Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

      V 1 Reply Last reply
      0
      • H Hamid Taebi

        Can you show your code did you attach hbitmap handle to CImage class?

        Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

        V Offline
        V Offline
        VC Maniac
        wrote on last edited by
        #11

        Another thing I noted is that if I give only the filename.jpg or png, it saves successfully, but if I give the whole path it fails with Win32Error.

        H M 2 Replies Last reply
        0
        • V VC Maniac

          Another thing I noted is that if I give only the filename.jpg or png, it saves successfully, but if I give the whole path it fails with Win32Error.

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

          When you use of filename.jpg it uses of current directory so I think your problem is of path.

          Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

          1 Reply Last reply
          0
          • V VC Maniac

            I changed my code to use Image class. I still have the same problem. I open a image file. then try to save it in png format. Save fuction returns "Win32Error" status. GdiplusStartup is successful. What may be wrong?

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

            no code => no help. :)

            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
            • V VC Maniac

              Im unable to save a image using CImage. Im able to load and draw it. At a later stage, I need to save it to a different path, so I call Save(). It gives an error '80004005' "Unspecified error". Please suggest.. TIA

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #14

              Hi, doesn't Save need a second parameter to tell which format to use (JPG/PNG/...)? :) Luc Pattyn [Forum Guidelines] [My Articles] I use ListBoxes for line-oriented text, and PictureBoxes for pictures, not drawings.

              V 1 Reply Last reply
              0
              • V VC Maniac

                Another thing I noted is that if I give only the filename.jpg or png, it saves successfully, but if I give the whole path it fails with Win32Error.

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #15

                Then probably either the path doesn't exist or you don't have sufficient rights to write to the path. Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                V 1 Reply Last reply
                0
                • H Hamid Taebi

                  How did you try like this: m_Image.Save(_T("c:\\123\\image.jpg"));

                  Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                  V Offline
                  V Offline
                  VC Maniac
                  wrote on last edited by
                  #16

                  This didnt work either..

                  H 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    Hi, doesn't Save need a second parameter to tell which format to use (JPG/PNG/...)? :) Luc Pattyn [Forum Guidelines] [My Articles] I use ListBoxes for line-oriented text, and PictureBoxes for pictures, not drawings.

                    V Offline
                    V Offline
                    VC Maniac
                    wrote on last edited by
                    #17

                    It has a default argument. If I dont pass, it will save it in a format identified by extension.

                    L 1 Reply Last reply
                    0
                    • M Mark Salsbery

                      Then probably either the path doesn't exist or you don't have sufficient rights to write to the path. Mark

                      Mark Salsbery Microsoft MVP - Visual C++ :java:

                      V Offline
                      V Offline
                      VC Maniac
                      wrote on last edited by
                      #18

                      I have given "D:\\123\\123.png" as the path. The path exists and I have full control of the folder.

                      M 1 Reply Last reply
                      0
                      • V VC Maniac

                        I have given "D:\\123\\123.png" as the path. The path exists and I have full control of the folder.

                        M Offline
                        M Offline
                        Mark Salsbery
                        wrote on last edited by
                        #19

                        If you step into the Save method in the debugger, where is the error occurring?

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        V 1 Reply Last reply
                        0
                        • V VC Maniac

                          It has a default argument. If I dont pass, it will save it in a format identified by extension.

                          L Offline
                          L Offline
                          Luc Pattyn
                          wrote on last edited by
                          #20

                          does that mean you got it to work? if so, how? :)

                          Luc Pattyn [Forum Guidelines] [My Articles]


                          I use ListBoxes for line-oriented text, and PictureBoxes for pictures, not drawings.


                          V 1 Reply Last reply
                          0
                          • M Mark Salsbery

                            If you step into the Save method in the debugger, where is the error occurring?

                            Mark Salsbery Microsoft MVP - Visual C++ :java:

                            V Offline
                            V Offline
                            VC Maniac
                            wrote on last edited by
                            #21

                            In the CBitmap Save call. It returns Win32Error.

                            M 1 Reply Last reply
                            0
                            • L Luc Pattyn

                              does that mean you got it to work? if so, how? :)

                              Luc Pattyn [Forum Guidelines] [My Articles]


                              I use ListBoxes for line-oriented text, and PictureBoxes for pictures, not drawings.


                              V Offline
                              V Offline
                              VC Maniac
                              wrote on last edited by
                              #22

                              Ya I got it to work. But it still doesn't work the way it should. I set the required path as current directory and then I call Save with only filename as the parameter (no path prefixed, since it still doesn't work that way.)

                              1 Reply Last reply
                              0
                              • V VC Maniac

                                This didnt work either..

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

                                Can you show your code for save and show how did you attach bithamp handle?

                                Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                                1 Reply Last reply
                                0
                                • V VC Maniac

                                  In the CBitmap Save call. It returns Win32Error.

                                  M Offline
                                  M Offline
                                  Mark Salsbery
                                  wrote on last edited by
                                  #24

                                  There shouldn't be a CBitmap::Save call....it should be a Gdiplus::Bitmap::Save call.

                                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                                  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