Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
  We've upgraded to YaBB 2!
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
Print
JPEG2000 load problems (Read 173 times)
marcianito
YaBB Newbies
*
Offline


I Love YaBB 2!
Posts: 1

JPEG2000 load problems
06/17/08 at 03:44:00
 
I am trying to convert a bmp file to a jpeg2000 file. I am using the following code:

void BmpToJp2(char *rutaBmp){
     CxImage image;
     const char *aux;
     aux=(rutaBmp+AnsiString(".bmp")).c_str();
     image.Load(aux, CXIMAGE_FORMAT_BMP);
     if (image.IsValid()){
           aux=(rutaBmp+AnsiString(".jp2")).c_str();
           bool ok=image.Save(aux,CXIMAGE_FORMAT_JP2);
           ok=image.Load(aux,CXIMAGE_FORMAT_JP2);
     }
}


The file seems perfectly saved cause the value of the variable ok after the saving operation is true, and the file in the hard disk is right. Then I try to load the file, and the result of ok var is false, but the program is not stopped. Then in another function I try again to load the j2p image and an interruption happens. I don't know why the file can not be loaded if it is saved properly.

Thank you.
Regards.
Back to top
 
 
IP Logged
 
Davide
YaBB Moderator
*****
Offline



Posts: 589

Re: JPEG2000 load problems
Reply #1 - 06/17/08 at 19:31:20
 
I made a test in this way:
Code:
void BmpToJp2(char *rutaBmp){ 
CxImage image;
image.Load("test.bmp", CXIMAGE_FORMAT_BMP);
if (image.IsValid()){
bool ok=image.Save("test.jp2",CXIMAGE_FORMAT_JP2);
ok=image.Load("test.jp2",CXIMAGE_FORMAT_JP2);
}
}

it works without errors.

I think that this instruction is wrong:
aux=(rutaBmp+AnsiString(".bmp")).c_str();
because you add 2 pointers, and so the result is undefined.

Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Print