How to get a JPG image from an .jp2 image ? [modified]
-
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
-
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
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.
-
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.
-
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!
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 32768Remember, 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. :)
-
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
<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
-
<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
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