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 design a decoder in C++?

How to design a decoder in C++?

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

    Hello! I am going to develop a code that converts .jp2 image to either .bmp or .jpg. I need the algorithm or simplest procedure or suggestions. Recently i have been searching for free API's and libraries that converts .jp2 to .jpg (or .bmp), i have been successful with CxImage, other GDI + functions, CPicture etc (some 3 - 4 ways) on Windows XP Platform in VC++. But i have to do the above conversion in eMbedded VC++ for a pocket PC Device(all the above successful ways are either not supported or used to fail in Pocket PC Device). I gathered information about the file structures and formats of JPEG2000, JPEG, BITMAP files. There are many decoders that convert from JPEG to BITMAP, can i get a source code of the simplest decoder (Lossy or lossless) so that i can design a decoder that converts .jp2 to .jpg, that works for a Pocket PC device in eVC++ what i need is a simple function that can meet my requirements! Thanks!

    CPalliniC S 2 Replies Last reply
    0
    • K kapardhi

      Hello! I am going to develop a code that converts .jp2 image to either .bmp or .jpg. I need the algorithm or simplest procedure or suggestions. Recently i have been searching for free API's and libraries that converts .jp2 to .jpg (or .bmp), i have been successful with CxImage, other GDI + functions, CPicture etc (some 3 - 4 ways) on Windows XP Platform in VC++. But i have to do the above conversion in eMbedded VC++ for a pocket PC Device(all the above successful ways are either not supported or used to fail in Pocket PC Device). I gathered information about the file structures and formats of JPEG2000, JPEG, BITMAP files. There are many decoders that convert from JPEG to BITMAP, can i get a source code of the simplest decoder (Lossy or lossless) so that i can design a decoder that converts .jp2 to .jpg, that works for a Pocket PC device in eVC++ what i need is a simple function that can meet my requirements! Thanks!

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      I suppose this link [^] may help you. :)

      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]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • K kapardhi

        Hello! I am going to develop a code that converts .jp2 image to either .bmp or .jpg. I need the algorithm or simplest procedure or suggestions. Recently i have been searching for free API's and libraries that converts .jp2 to .jpg (or .bmp), i have been successful with CxImage, other GDI + functions, CPicture etc (some 3 - 4 ways) on Windows XP Platform in VC++. But i have to do the above conversion in eMbedded VC++ for a pocket PC Device(all the above successful ways are either not supported or used to fail in Pocket PC Device). I gathered information about the file structures and formats of JPEG2000, JPEG, BITMAP files. There are many decoders that convert from JPEG to BITMAP, can i get a source code of the simplest decoder (Lossy or lossless) so that i can design a decoder that converts .jp2 to .jpg, that works for a Pocket PC device in eVC++ what i need is a simple function that can meet my requirements! Thanks!

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        If I were you, I'd just try to port the Jasper JP2 decoder to your PocketPC platform. I suspect the code is mostly portable. In fact looking at it (by just inserting the libjasper header and source files into a new PocketPC 2003 static library project under VS2008), the only significant issue is jas_stream.c - that uses Unix style I/O (like open, read, close), which PocketPC 2003 doesn't have. You'd need to develop a PocketPC replacement for that (which should be relatively trivial - it's just file I/O, FFS!). Aside from that, the only changes I found were needed to compile the other source files were

        1. Tell the project not to use pre-compiled headers

        2. Add the jasper include folder to the project's include path

        3. Add the symbol JAS_WIN_MSVC_BUILD to the list of pre-processor defines

        4. Change jas_config2.h to contain the following:

          #ifndef JAS_CONFIG2_H
          #define JAS_CONFIG2_H

          /*
          * Configuration for Microsoft Windows and Microsoft Visual C.
          *
          * We are not using a configure-based build.
          * Try to compensate for this here, by specifying the preprocessor symbols
          * normally defined by configure.
          */

          //#define uchar unsigned char
          // #define ushort unsigned short
          // #define uint unsigned int
          // #define ulong unsigned long
          // #define longlong long long
          // #define ulonglong unsigned long long
          /*#define ssize_t int*/

          //#define HAVE_FCNTL_H 1
          #define HAVE_LIMITS_H 1
          //#define HAVE_IO_H 1
          #define HAVE_WINDOWS_H 1
          //#define HAVE_SYS_TYPES_H 1
          #define HAVE_STDLIB_H 1
          #define HAVE_STDDEF_H 1

          #define L_tmpnam MAX_PATH

          #endif

        That means that the JP2 codec part of the code builds relatively easily.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        K 1 Reply Last reply
        0
        • S Stuart Dootson

          If I were you, I'd just try to port the Jasper JP2 decoder to your PocketPC platform. I suspect the code is mostly portable. In fact looking at it (by just inserting the libjasper header and source files into a new PocketPC 2003 static library project under VS2008), the only significant issue is jas_stream.c - that uses Unix style I/O (like open, read, close), which PocketPC 2003 doesn't have. You'd need to develop a PocketPC replacement for that (which should be relatively trivial - it's just file I/O, FFS!). Aside from that, the only changes I found were needed to compile the other source files were

          1. Tell the project not to use pre-compiled headers

          2. Add the jasper include folder to the project's include path

          3. Add the symbol JAS_WIN_MSVC_BUILD to the list of pre-processor defines

          4. Change jas_config2.h to contain the following:

            #ifndef JAS_CONFIG2_H
            #define JAS_CONFIG2_H

            /*
            * Configuration for Microsoft Windows and Microsoft Visual C.
            *
            * We are not using a configure-based build.
            * Try to compensate for this here, by specifying the preprocessor symbols
            * normally defined by configure.
            */

            //#define uchar unsigned char
            // #define ushort unsigned short
            // #define uint unsigned int
            // #define ulong unsigned long
            // #define longlong long long
            // #define ulonglong unsigned long long
            /*#define ssize_t int*/

            //#define HAVE_FCNTL_H 1
            #define HAVE_LIMITS_H 1
            //#define HAVE_IO_H 1
            #define HAVE_WINDOWS_H 1
            //#define HAVE_SYS_TYPES_H 1
            #define HAVE_STDLIB_H 1
            #define HAVE_STDDEF_H 1

            #define L_tmpnam MAX_PATH

            #endif

          That means that the JP2 codec part of the code builds relatively easily.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

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

          First of all thanks for your valuable suggestion. Sorry for the delayed reply! But i am using eVC++ within which i have Pocket PC 2003 SDK, using this i develop application for my Win CE device. I am using the jasper folder from CxImage of WIN CE version The solution to the jasper project opens only in VISUAL STUDIO 2005, but mine is eVC++ 4.0, can i use that library developed in VS2005 with Pocket Pc 2003 CPU, in my eVC++ application? Now i am trying to port the source files into my eVC++ application. But all the functions in Jasper use structures, can you help me how to use those structures to open and save a .jp2 image present at a location to be opened and saved as .jpg or .bmp at the same location! thanks!

          S 1 Reply Last reply
          0
          • K kapardhi

            First of all thanks for your valuable suggestion. Sorry for the delayed reply! But i am using eVC++ within which i have Pocket PC 2003 SDK, using this i develop application for my Win CE device. I am using the jasper folder from CxImage of WIN CE version The solution to the jasper project opens only in VISUAL STUDIO 2005, but mine is eVC++ 4.0, can i use that library developed in VS2005 with Pocket Pc 2003 CPU, in my eVC++ application? Now i am trying to port the source files into my eVC++ application. But all the functions in Jasper use structures, can you help me how to use those structures to open and save a .jp2 image present at a location to be opened and saved as .jpg or .bmp at the same location! thanks!

            S Offline
            S Offline
            Stuart Dootson
            wrote on last edited by
            #5

            I downloaded this Jasper[^]. It has a VC6 solution (but don't use that directly). The jasper project in the software download contains code that will load image files in one format and save them in another. Look at that code to see how to open/save files. Also, CxImage will contain code to do that, as it uses Jasper to load JPG, JP2 images.

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            K 1 Reply Last reply
            0
            • S Stuart Dootson

              I downloaded this Jasper[^]. It has a VC6 solution (but don't use that directly). The jasper project in the software download contains code that will load image files in one format and save them in another. Look at that code to see how to open/save files. Also, CxImage will contain code to do that, as it uses Jasper to load JPG, JP2 images.

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

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

              Hai! I am developing the application in Visual studio 2008 using Pocket PC 2003 SDK, which works in my WINCE device. I imported CxImage CE version and tried to build solution without making any changes (even in jas_config2.h), i get the following errors: jasper.lib(jpg_dummy.obj) : error LNK2005: jpg_encode already defined in jasper.lib(jpg_enc.obj) jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol read referenced in function file_read jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol write referenced in function file_write jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol lseek referenced in function file_seek jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol unlink referenced in function file_close jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol close referenced in function file_close jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol open referenced in function jas_stream_fopen jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol tmpnam referenced in function jas_stream_tmpfile jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol setmode referenced in function jas_stream_fdopen jasper.lib(jpg_enc.obj) : error LNK2019: unresolved external symbol rewind referenced in function jpg_encode jasper.lib(jpg_enc.obj) : error LNK2019: unresolved external symbol tmpfile referenced in function jpg_encode then i made the changes suggested by you in jas_config2.h, on disabling #define HAVE_FCNTL_H 1 i get the following errors \base\jas_stream.c(253) : error C2065: 'O_RDWR' : undeclared identifier \base\jas_stream.c(255) : error C2065: 'O_RDONLY' : undeclared identifier \base\jas_stream.c(257) : error C2065: 'O_WRONLY' : undeclared identifier \base\jas_stream.c(262) : error C2065: 'O_APPEND' : undeclared identifier \base\jas_stream.c(268) : error C2065: 'O_CREAT' : undeclared identifier \base\jas_stream.c(268) : error C2065: 'O_TRUNC' : undeclared identifier \base\jas_stream.c(285) : warning C4013: 'open' undefined; assuming extern returning int \base\jas_stream.c(315) : error C2065: 'O_RDWR' : undeclared identifier \base\jas_stream.c(317) : error C2065: 'O_RDONLY' : undeclared identifier \base\jas_stream.c(319) : error C2065: 'O_WRONLY' : undeclared identifier \base\jas_stream.c(324) : error C2065: 'O_APPEND' : undeclared identifier \base\jas_stream.c(330) : error C2065: 'O_CREAT' : undeclared identifier \base\jas_stream.c(33

              S 1 Reply Last reply
              0
              • K kapardhi

                Hai! I am developing the application in Visual studio 2008 using Pocket PC 2003 SDK, which works in my WINCE device. I imported CxImage CE version and tried to build solution without making any changes (even in jas_config2.h), i get the following errors: jasper.lib(jpg_dummy.obj) : error LNK2005: jpg_encode already defined in jasper.lib(jpg_enc.obj) jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol read referenced in function file_read jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol write referenced in function file_write jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol lseek referenced in function file_seek jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol unlink referenced in function file_close jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol close referenced in function file_close jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol open referenced in function jas_stream_fopen jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol tmpnam referenced in function jas_stream_tmpfile jasper.lib(jas_stream.obj) : error LNK2019: unresolved external symbol setmode referenced in function jas_stream_fdopen jasper.lib(jpg_enc.obj) : error LNK2019: unresolved external symbol rewind referenced in function jpg_encode jasper.lib(jpg_enc.obj) : error LNK2019: unresolved external symbol tmpfile referenced in function jpg_encode then i made the changes suggested by you in jas_config2.h, on disabling #define HAVE_FCNTL_H 1 i get the following errors \base\jas_stream.c(253) : error C2065: 'O_RDWR' : undeclared identifier \base\jas_stream.c(255) : error C2065: 'O_RDONLY' : undeclared identifier \base\jas_stream.c(257) : error C2065: 'O_WRONLY' : undeclared identifier \base\jas_stream.c(262) : error C2065: 'O_APPEND' : undeclared identifier \base\jas_stream.c(268) : error C2065: 'O_CREAT' : undeclared identifier \base\jas_stream.c(268) : error C2065: 'O_TRUNC' : undeclared identifier \base\jas_stream.c(285) : warning C4013: 'open' undefined; assuming extern returning int \base\jas_stream.c(315) : error C2065: 'O_RDWR' : undeclared identifier \base\jas_stream.c(317) : error C2065: 'O_RDONLY' : undeclared identifier \base\jas_stream.c(319) : error C2065: 'O_WRONLY' : undeclared identifier \base\jas_stream.c(324) : error C2065: 'O_APPEND' : undeclared identifier \base\jas_stream.c(330) : error C2065: 'O_CREAT' : undeclared identifier \base\jas_stream.c(33

                S Offline
                S Offline
                Stuart Dootson
                wrote on last edited by
                #7

                kapardhi wrote:

                How to resolve them??

                By modifying jas_stream.c. The WinCE C runtime library doesn't have fcntl and the file operations it declares - ask Microsoft why not...

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                K 1 Reply Last reply
                0
                • S Stuart Dootson

                  kapardhi wrote:

                  How to resolve them??

                  By modifying jas_stream.c. The WinCE C runtime library doesn't have fcntl and the file operations it declares - ask Microsoft why not...

                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

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

                  But there is a folder in CxImage(wcecompat\include), which contains WINCE compatible files, fcntl is included in it, if i am wrong, Can you please give me any idea what to replace with fcntl that is supported in WINCE and has similiar functionalities Thanks!

                  modified on Thursday, June 4, 2009 9:56 AM

                  S 1 Reply Last reply
                  0
                  • K kapardhi

                    But there is a folder in CxImage(wcecompat\include), which contains WINCE compatible files, fcntl is included in it, if i am wrong, Can you please give me any idea what to replace with fcntl that is supported in WINCE and has similiar functionalities Thanks!

                    modified on Thursday, June 4, 2009 9:56 AM

                    S Offline
                    S Offline
                    Stuart Dootson
                    wrote on last edited by
                    #9

                    Well, it's really the low-level IO operations[^] in io.h that you need to implement equivalents of - that should be relatively simple to do with the WinCE file IO functions[^] - the low-level IO operation sin the C run-time are really just the Unix equivalents of the Win32/WinCE file IO functions I've pointed you at. They're relatively easy to implement - I've implemented them in embedded platforms before, transmitting the file operation over to a Windows host that performed them on the Windows file-system.

                    Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                    K 1 Reply Last reply
                    0
                    • S Stuart Dootson

                      Well, it's really the low-level IO operations[^] in io.h that you need to implement equivalents of - that should be relatively simple to do with the WinCE file IO functions[^] - the low-level IO operation sin the C run-time are really just the Unix equivalents of the Win32/WinCE file IO functions I've pointed you at. They're relatively easy to implement - I've implemented them in embedded platforms before, transmitting the file operation over to a Windows host that performed them on the Windows file-system.

                      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

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

                      Thanks!, I could replace most of the functions, but i couldn't replace two functions required in jas_stream.c and jpg_enc.c, the two files use tmpnam() and tmpfile() functions in jas_stream_tmpfile () and jpg_encode () functions sample code is below tempnam (obj->pathname); // within jas_stream_tmpfile () function and if (!(output_file = _tmpfile())) //// within jpg_encode () function { .. } What are the eqivalent functions of tmpnam() and tmpfile () for WINCE, i reffered the following : http://support.microsoft.com/kb/99456 Please tell equivalent functions or any workarround so that the overall functionality is not affected. Thanks!

                      S 1 Reply Last reply
                      0
                      • K kapardhi

                        Thanks!, I could replace most of the functions, but i couldn't replace two functions required in jas_stream.c and jpg_enc.c, the two files use tmpnam() and tmpfile() functions in jas_stream_tmpfile () and jpg_encode () functions sample code is below tempnam (obj->pathname); // within jas_stream_tmpfile () function and if (!(output_file = _tmpfile())) //// within jpg_encode () function { .. } What are the eqivalent functions of tmpnam() and tmpfile () for WINCE, i reffered the following : http://support.microsoft.com/kb/99456 Please tell equivalent functions or any workarround so that the overall functionality is not affected. Thanks!

                        S Offline
                        S Offline
                        Stuart Dootson
                        wrote on last edited by
                        #11

                        tempnam and tmpnam can be implemented with some combinations of GetTempFileName[^] and GetTempPath[^]. _tmpfile == fopen() a file whose filename was generated with tmpnam(), i.e. can be implemented entirely with other functions you should already have available to you.

                        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                        K 1 Reply Last reply
                        0
                        • S Stuart Dootson

                          tempnam and tmpnam can be implemented with some combinations of GetTempFileName[^] and GetTempPath[^]. _tmpfile == fopen() a file whose filename was generated with tmpnam(), i.e. can be implemented entirely with other functions you should already have available to you.

                          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

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

                          I have done a work arround using those functions but still i am not getting the image! Probably because i have not changed the some of old #defines like #define O_RDONLY _O_RDONLY #define O_WRONLY _O_WRONLY #define O_RDWR _O_RDWR #define O_APPEND _O_APPEND #define O_CREAT _O_CREAT #define O_TRUNC _O_TRUNC #define O_EXCL _O_EXCL #define O_TEXT _O_TEXT #define O_BINARY _O_BINARY Does these values need to be changed, if yes where can i get the values; I tried at msdn help by opening the functions like fopen (), createFile (), but i do get only few values for RDONLY, WRONLY, so what nned to be done ? Thanks!

                          S 1 Reply Last reply
                          0
                          • K kapardhi

                            I have done a work arround using those functions but still i am not getting the image! Probably because i have not changed the some of old #defines like #define O_RDONLY _O_RDONLY #define O_WRONLY _O_WRONLY #define O_RDWR _O_RDWR #define O_APPEND _O_APPEND #define O_CREAT _O_CREAT #define O_TRUNC _O_TRUNC #define O_EXCL _O_EXCL #define O_TEXT _O_TEXT #define O_BINARY _O_BINARY Does these values need to be changed, if yes where can i get the values; I tried at msdn help by opening the functions like fopen (), createFile (), but i do get only few values for RDONLY, WRONLY, so what nned to be done ? Thanks!

                            S Offline
                            S Offline
                            Stuart Dootson
                            wrote on last edited by
                            #13

                            You can get those values by looking at the Win32 version of the C run-time library.

                            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                            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