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 get a JPG image from an .jp2 image ? [modified]

How to get a JPG image from an .jp2 image ? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestionc++data-structuresjson
6 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.
  • K Offline
    K Offline
    kapardhi
    wrote on last edited by
    #1

    Hai! I am developing a dialog based application for a WINCE device in eVC++. I cannot use GDI, ImagingFactory, IPicture API's I need solution/suggestion to any of the following: 1. I have .jp2 image, how can i convert and save it as .jpg file. or 2. I have the byte array of .jp2 image, how can i convert to .jpg byte array or 3. How can i get the HBITMAP handle from .jp2 image's byte array. I am having one more doubt: Using picture Control i am not able to display a bitmap image mcsMyImage - is the control variable of the Picture control of my dialog, MyImage.bmp - is the bitmap file now i do the following: CString strError; DWORD dwError; HBITMAP hBitmap = (HBITMAP) LoadImageBitmap (NULL, _T("MyImage.bmp"), IMAGE_BITMAP, 0, 0, 0); // Tring to get last occured error dwError = GetLastError (); strError.Format (_T("%x"), dwError); AfxMessageBox (strError); // Set the bitmap on the dialog mcsMyImage.SetBitmap (hBitmap); Bitmap doesnot get loaded, i get 0x6 as the last error, which says "Invalid handle" How to solve this? Thanks!

    modified on Thursday, May 14, 2009 5:25 AM

    enhzflepE C 2 Replies Last reply
    0
    • K kapardhi

      Hai! I am developing a dialog based application for a WINCE device in eVC++. I cannot use GDI, ImagingFactory, IPicture API's I need solution/suggestion to any of the following: 1. I have .jp2 image, how can i convert and save it as .jpg file. or 2. I have the byte array of .jp2 image, how can i convert to .jpg byte array or 3. How can i get the HBITMAP handle from .jp2 image's byte array. I am having one more doubt: Using picture Control i am not able to display a bitmap image mcsMyImage - is the control variable of the Picture control of my dialog, MyImage.bmp - is the bitmap file now i do the following: CString strError; DWORD dwError; HBITMAP hBitmap = (HBITMAP) LoadImageBitmap (NULL, _T("MyImage.bmp"), IMAGE_BITMAP, 0, 0, 0); // Tring to get last occured error dwError = GetLastError (); strError.Format (_T("%x"), dwError); AfxMessageBox (strError); // Set the bitmap on the dialog mcsMyImage.SetBitmap (hBitmap); Bitmap doesnot get loaded, i get 0x6 as the last error, which says "Invalid handle" How to solve this? Thanks!

      modified on Thursday, May 14, 2009 5:25 AM

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      Hi, you may be able to find an implementation of jp2 in the source code for celestia. Haven't seen the LoadImageBitmap function before. I wonder if it works like LoadImage, if so, you'll need to throw it a copy of the hInstance, you'll also need to throw it the LR_LOADFROMFILE for the load flags. i.e - using plain GDI:

      HBITMAP hBitmap = (HBITMAP) LoadImage(
      GetModuleHandle(0), // get hInstance of this program
      "MyImage.bmp", // name of image to load
      IMAGE_BITMAP, // type of image (not a cursor or icon)
      0,0, // width, height - 0 = use image values
      LR_LOADFROMFILE // this is where we want it from - ! a resource
      );

      I apologise in advance if my ignorance about mfc has made this a wasted post.

      K 1 Reply Last reply
      0
      • enhzflepE enhzflep

        Hi, you may be able to find an implementation of jp2 in the source code for celestia. Haven't seen the LoadImageBitmap function before. I wonder if it works like LoadImage, if so, you'll need to throw it a copy of the hInstance, you'll also need to throw it the LR_LOADFROMFILE for the load flags. i.e - using plain GDI:

        HBITMAP hBitmap = (HBITMAP) LoadImage(
        GetModuleHandle(0), // get hInstance of this program
        "MyImage.bmp", // name of image to load
        IMAGE_BITMAP, // type of image (not a cursor or icon)
        0,0, // width, height - 0 = use image values
        LR_LOADFROMFILE // this is where we want it from - ! a resource
        );

        I apologise in advance if my ignorance about mfc has made this a wasted post.

        K Offline
        K Offline
        kapardhi
        wrote on last edited by
        #3

        Sorry i have wrongly typed it, it's LoadImage () only, when i am using LR_LOADFROMFILE, it gives an error error C2065: 'LR_LOADFROMFILE' : undeclared identifier Thanks!

        enhzflepE 1 Reply Last reply
        0
        • K kapardhi

          Sorry i have wrongly typed it, it's LoadImage () only, when i am using LR_LOADFROMFILE, it gives an error error C2065: 'LR_LOADFROMFILE' : undeclared identifier Thanks!

          enhzflepE Offline
          enhzflepE Offline
          enhzflep
          wrote on last edited by
          #4

          Uh-huh. Okay, have you included "winuser.h" - it defines LR_LOADFROMFILE (as 0x10) I don't need to include it explicitly using gcc 3.4.?? Taken from winuser.h

          #define LR_DEFAULTCOLOR 0
          #define LR_MONOCHROME 1
          #define LR_COLOR 2
          #define LR_COPYRETURNORG 4
          #define LR_COPYDELETEORG 8
          #define LR_LOADFROMFILE 16
          #define LR_LOADTRANSPARENT 32
          #define LR_LOADREALSIZE 128
          #define LR_DEFAULTSIZE 0x0040
          #define LR_VGACOLOR 0x0080
          #define LR_LOADMAP3DCOLORS 4096
          #define LR_CREATEDIBSECTION 8192
          #define LR_COPYFROMRESOURCE 0x4000
          #define LR_SHARED 32768

          Remember, the first param of LoadImage can be NULL only when loading a bitmap from a resource within the module. If loading from a file, you must (a) pass the hInstance, (b) give a valid filename (c) pass the LR_LOADFROMFILE loading flag. :)

          1 Reply Last reply
          0
          • K kapardhi

            Hai! I am developing a dialog based application for a WINCE device in eVC++. I cannot use GDI, ImagingFactory, IPicture API's I need solution/suggestion to any of the following: 1. I have .jp2 image, how can i convert and save it as .jpg file. or 2. I have the byte array of .jp2 image, how can i convert to .jpg byte array or 3. How can i get the HBITMAP handle from .jp2 image's byte array. I am having one more doubt: Using picture Control i am not able to display a bitmap image mcsMyImage - is the control variable of the Picture control of my dialog, MyImage.bmp - is the bitmap file now i do the following: CString strError; DWORD dwError; HBITMAP hBitmap = (HBITMAP) LoadImageBitmap (NULL, _T("MyImage.bmp"), IMAGE_BITMAP, 0, 0, 0); // Tring to get last occured error dwError = GetLastError (); strError.Format (_T("%x"), dwError); AfxMessageBox (strError); // Set the bitmap on the dialog mcsMyImage.SetBitmap (hBitmap); Bitmap doesnot get loaded, i get 0x6 as the last error, which says "Invalid handle" How to solve this? Thanks!

            modified on Thursday, May 14, 2009 5:25 AM

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

            <blockquote class="FQ"><div class="FQA">kapardhi wrote:</div> 1. I have .jp2 image, how can i convert and save it as .jpg file.</blockquote> JasPer

            image processing toolkits | batch image processing

            A 1 Reply Last reply
            0
            • C Chris Losinger

              <blockquote class="FQ"><div class="FQA">kapardhi wrote:</div> 1. I have .jp2 image, how can i convert and save it as .jpg file.</blockquote> JasPer

              image processing toolkits | batch image processing

              A Offline
              A Offline
              Alain Rist
              wrote on last edited by
              #6

              kapardhi wrote:

              I am developing a dialog based application for a WINCE device in eVC++.

              Chris Losinger wrote:

              JasPer

              Unfortunately Jasper should first be ported to WinCE :( Seriously, if you want to get a result in reasonable time, convert your jp2 file to a Imaging supported format(as jpg or png) on a server and use the Imaging API [^]on your device. cheers, AR

              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