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. a windows API function to convert JPG into BMP [modified]

a windows API function to convert JPG into BMP [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
9 Posts 4 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.
  • V Offline
    V Offline
    V_shr
    wrote on last edited by
    #1

    topic says all :D is there any? thnx

    C M P 3 Replies Last reply
    0
    • V V_shr

      topic says all :D is there any? thnx

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      there are dozens. did you try searching this site? or Google?

      image processing toolkits | batch image processing

      V 2 Replies Last reply
      0
      • C Chris Losinger

        there are dozens. did you try searching this site? or Google?

        image processing toolkits | batch image processing

        V Offline
        V Offline
        V_shr
        wrote on last edited by
        #3

        i searched ... nothing , i wonder maybe i use bad key words !

        1 Reply Last reply
        0
        • C Chris Losinger

          there are dozens. did you try searching this site? or Google?

          image processing toolkits | batch image processing

          V Offline
          V Offline
          V_shr
          wrote on last edited by
          #4

          actually i searched in articles for "jpg to bmp API" the answers was s.th else ! for example changing icons to ... !!! i also looked in my API book but i couldnt find , man plz hlp

          1 Reply Last reply
          0
          • V V_shr

            topic says all :D is there any? thnx

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

            If you don't need to write the JPEG decompression yourself, here's the simplest way I know:

            #include <atlimage.h>
            ...
            // (error handling omitted)
            CImage image;
            image.Load(_T("c:\\some.jpg"));
            image.Save(_T("c:\\some.bmp"), ImageFormatBMP);

            Mark

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

            V 1 Reply Last reply
            0
            • M Mark Salsbery

              If you don't need to write the JPEG decompression yourself, here's the simplest way I know:

              #include <atlimage.h>
              ...
              // (error handling omitted)
              CImage image;
              image.Load(_T("c:\\some.jpg"));
              image.Save(_T("c:\\some.bmp"), ImageFormatBMP);

              Mark

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

              V Offline
              V Offline
              V_shr
              wrote on last edited by
              #6

              do u know where can i get atlimage.h ??? CImage is a new class included with VC7 i think, but i use BC++ :( -- modified at 17:26 Thursday 25th October, 2007

              M 1 Reply Last reply
              0
              • V V_shr

                do u know where can i get atlimage.h ??? CImage is a new class included with VC7 i think, but i use BC++ :( -- modified at 17:26 Thursday 25th October, 2007

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

                V_shr wrote:

                CImage is a new class included with VC7 i think, but i dont use VisualStudio.NET

                :doh: Ok, try this ...

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

                Gdiplus::GdiplusShutdown(dwToken);
                    }

                I took the GetEncoderClsId() function right from the GDI+ docs in the Platform SDK. It looks like this:

                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
                }

                Mark

                V 1 Reply Last reply
                0
                • M Mark Salsbery

                  V_shr wrote:

                  CImage is a new class included with VC7 i think, but i dont use VisualStudio.NET

                  :doh: Ok, try this ...

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

                  Gdiplus::GdiplusShutdown(dwToken);
                      }

                  I took the GetEncoderClsId() function right from the GDI+ docs in the Platform SDK. It looks like this:

                  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
                  }

                  Mark

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

                  thnx , here its 3:00 pm , ill try it tomarrow :D

                  1 Reply Last reply
                  0
                  • V V_shr

                    topic says all :D is there any? thnx

                    P Offline
                    P Offline
                    Paresh Chitte
                    wrote on last edited by
                    #9

                    Please refer this[^]. Hope this will solve your purpose. Regards, Paresh.

                    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