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 Convert a BMP Image to a JPEG ...

How to Convert a BMP Image to a JPEG ...

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
15 Posts 9 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.
  • T Offline
    T Offline
    tns_ranjith
    wrote on last edited by
    #1

    How to Convert a BMP Image to a JPEG ...

    R J M H 4 Replies Last reply
    0
    • T tns_ranjith

      How to Convert a BMP Image to a JPEG ...

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      Can you be a little less lazier than that?

      Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

      M T C 3 Replies Last reply
      0
      • T tns_ranjith

        How to Convert a BMP Image to a JPEG ...

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

        Open it in MSPaint, File - Save As, save as JPEG file type.    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * 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!
        Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        1 Reply Last reply
        0
        • R Rajesh R Subramanian

          Can you be a little less lazier than that?

          Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

          M Offline
          M Offline
          Michael Schubert
          wrote on last edited by
          #4

          Probably not - read between the lines: How to Convert urgentzz BMP Image to a JPEG plzz sendz codez

          1 Reply Last reply
          0
          • R Rajesh R Subramanian

            Can you be a little less lazier than that?

            Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

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

            thx for reply

            1 Reply Last reply
            0
            • R Rajesh R Subramanian

              Can you be a little less lazier than that?

              Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

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

              Rajesh R Subramanian wrote:

              Can you be a little less lazier than that?

              Yes, he can add another

              How to Convert a BMP Image to a JPEG ...

              line to the message text. ;P :-D

              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
              • T tns_ranjith

                How to Convert a BMP Image to a JPEG ...

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

                #include <atlimage.h>
                ...
                CImage bmpimg;
                bmpimg.Load(_T("c:\\some.bmp"));
                bmpimg.Save(_T("c:\\some.jpg"), ImageFormatJPEG);

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

                A 1 Reply Last reply
                0
                • T tns_ranjith

                  How to Convert a BMP Image to a JPEG ...

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

                  You can use of CImage class with Save function of it.

                  R 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    You can use of CImage class with Save function of it.

                    R Offline
                    R Offline
                    reddy78
                    wrote on last edited by
                    #9

                    Hi to all, I need to convert an array of bitmap to a compress format (avi, mpeg4 and so on). Do you have any idea how to do it in C++??? Regards, Daniele

                    H 1 Reply Last reply
                    0
                    • R reddy78

                      Hi to all, I need to convert an array of bitmap to a compress format (avi, mpeg4 and so on). Do you have any idea how to do it in C++??? Regards, Daniele

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

                      Do you want to make a video files?

                      1 Reply Last reply
                      0
                      • M Mark Salsbery

                        #include <atlimage.h>
                        ...
                        CImage bmpimg;
                        bmpimg.Load(_T("c:\\some.bmp"));
                        bmpimg.Save(_T("c:\\some.jpg"), ImageFormatJPEG);

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

                        A Offline
                        A Offline
                        aa_zz
                        wrote on last edited by
                        #11

                        i need covert JPEG to BMP. can you tell specific for CImage. thank very much.

                        M 1 Reply Last reply
                        0
                        • A aa_zz

                          i need covert JPEG to BMP. can you tell specific for CImage. thank very much.

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

                          #include <atlimage.h>
                          ...
                          CImage img;
                          img.Load(_T("c:\\some.jpg"));
                          img.Save(_T("c:\\some.bmp"), ImageFormatBMP);

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

                          A 1 Reply Last reply
                          0
                          • M Mark Salsbery

                            #include <atlimage.h>
                            ...
                            CImage img;
                            img.Load(_T("c:\\some.jpg"));
                            img.Save(_T("c:\\some.bmp"), ImageFormatBMP);

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

                            A Offline
                            A Offline
                            aa_zz
                            wrote on last edited by
                            #13

                            this is CImage of .net. i need source = VC++6.0. thank very much

                            M 1 Reply Last reply
                            0
                            • A aa_zz

                              this is CImage of .net. i need source = VC++6.0. thank very much

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

                              CImage is a class shared by ATL and MFC these days. It uses GDI+ for image loading and saving. Here's the GDI+ version:

                              #include <gdiplus.h>

                              // This function stolen from the GDI+ docs

                              int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
                              {
                              UINT num = 0; // number of image encoders
                              UINT size = 0; // size of the image encoder array in bytes

                              ImageCodecInfo\* pImageCodecInfo = NULL;
                              
                              GetImageEncodersSize(&num, &size);
                              if(size == 0)
                              	return -1;  // Failure
                              
                              pImageCodecInfo = (ImageCodecInfo\*)(malloc(size));
                              if(pImageCodecInfo == NULL)
                              	return -1;  // Failure
                              
                              GetImageEncoders(num, size, pImageCodecInfo);
                              
                              for(UINT j = 0; j < num; ++j)
                              {
                              	if( wcscmp(pImageCodecInfo\[j\].MimeType, format) == 0 )
                              	{
                              		\*pClsid = pImageCodecInfo\[j\].Clsid;
                              		free(pImageCodecInfo);
                              		return j;  // Success
                              	}    
                              }
                              
                              free(pImageCodecInfo);
                              return -1;  // Failure
                              

                              }

                              ...

                              // Convert a JPEG to a BMP with GDI+

                              ULONG dwToken;
                              Gdiplus::GdiplusStartupInput input;
                              Gdiplus::GdiplusStartupOutput output;
                              Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output);
                              if(status == Gdiplus::Ok)
                              {
                              	Gdiplus::Bitmap \*pSrcBitmap = new Gdiplus::Bitmap(L"c:\\\\test.jpg", FALSE);
                              	CLSID bmpClsid;
                              	GetEncoderClsid(L"image/bmp", &bmpClsid);
                              	pSrcBitmap->Save(L"c:\\\\test.bmp", &bmpClsid);
                              	delete pSrcBitmap;
                              
                              	Gdiplus::GdiplusShutdown(dwToken);
                              }
                              

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

                              A 1 Reply Last reply
                              0
                              • M Mark Salsbery

                                CImage is a class shared by ATL and MFC these days. It uses GDI+ for image loading and saving. Here's the GDI+ version:

                                #include <gdiplus.h>

                                // This function stolen from the GDI+ docs

                                int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
                                {
                                UINT num = 0; // number of image encoders
                                UINT size = 0; // size of the image encoder array in bytes

                                ImageCodecInfo\* pImageCodecInfo = NULL;
                                
                                GetImageEncodersSize(&num, &size);
                                if(size == 0)
                                	return -1;  // Failure
                                
                                pImageCodecInfo = (ImageCodecInfo\*)(malloc(size));
                                if(pImageCodecInfo == NULL)
                                	return -1;  // Failure
                                
                                GetImageEncoders(num, size, pImageCodecInfo);
                                
                                for(UINT j = 0; j < num; ++j)
                                {
                                	if( wcscmp(pImageCodecInfo\[j\].MimeType, format) == 0 )
                                	{
                                		\*pClsid = pImageCodecInfo\[j\].Clsid;
                                		free(pImageCodecInfo);
                                		return j;  // Success
                                	}    
                                }
                                
                                free(pImageCodecInfo);
                                return -1;  // Failure
                                

                                }

                                ...

                                // Convert a JPEG to a BMP with GDI+

                                ULONG dwToken;
                                Gdiplus::GdiplusStartupInput input;
                                Gdiplus::GdiplusStartupOutput output;
                                Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output);
                                if(status == Gdiplus::Ok)
                                {
                                	Gdiplus::Bitmap \*pSrcBitmap = new Gdiplus::Bitmap(L"c:\\\\test.jpg", FALSE);
                                	CLSID bmpClsid;
                                	GetEncoderClsid(L"image/bmp", &bmpClsid);
                                	pSrcBitmap->Save(L"c:\\\\test.bmp", &bmpClsid);
                                	delete pSrcBitmap;
                                
                                	Gdiplus::GdiplusShutdown(dwToken);
                                }
                                

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

                                A Offline
                                A Offline
                                aa_zz
                                wrote on last edited by
                                #15

                                can you sent full code to me. wish your help. thanks very much

                                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