JPEGLib: Bogus input colorspace

Hello,

I hope the problem I’m about to write about has not been discussed already, I couldn’t find anything with the search engine…

I am trying to save a TImage in TIFF format, using

[code]TImage *mymap = TImage::Create();

mymap->SetImage(val,l,w);
mymap->WriteImage(“fentes1a.tiff”);[/code]
This gives me a message “JPEGLib: Bogus input colorspace”, and no output image. When I add the line

The display is OK.

This problem is all the more strange that the “save as TIFF” command in the canvas menu works pretty well (although it does not do what I want : my image is very large and the canvas command saves an image with a smaller resolution).

Thank you very much for any hint !!!

Hello,

I cannot reproduce the problem.
Can you try this script (taking rose512.jpg from $(ROOTSYS)/tutorials) :

[code]void test_image()
{
TImage *img = TImage::Open(“rose512.jpg”);

if (!img) {
printf(“Could not create an image… exit\n”);
return;
}
img->SetImageQuality(TAttImage::kImgBest);

TImagePalette *pal = (TImagePalette *)&img->GetPalette();
TArrayD *arr = img->GetArray(img->GetWidth(), img->GetHeight(), pal);
img->SetImage(arr->GetArray(), img->GetWidth(), img->GetHeight(), pal);
img->Draw();
img->WriteImage(“fentes1a.tiff”);
}[/code]
If it works, could you provide a working script showing the problem ?

Cheers,
Bertrand.

Thank you for your answer ! This script works fine with me too. Here is what I am trying to do :

[code]{

gROOT->Reset();
c1 = new TCanvas(“c1”,“fente1”,200,0,1300,730);

UInt_t l=100;
UInt_t w=100;
double val[w*l];

for (int i= 0; i<l; ++i)
{
for (int j= 0; j<w; ++j)
{
double x= ((double)i)/20.;
double y= ((double)j)/20.;
val[i+l*j] = sin(sqrt(xx+yy));
}
}

TImage *mymap = TImage::Create();

mymap->SetImage(val,l,w);
mymap->TAttImage()->SetImageCompression(0);
mymap->TAttImage()->SetImageQuality(TAttImage::kImgBest);
mymap->WriteImage(“test2.tiff”);
mymap->Draw();
}
[/code]
which I run by .x …

Ok, thanks, I will investigate.

Bertrand.

Ok, replace : mymap->TAttImage()->SetImageCompression(0); mymap->TAttImage()->SetImageQuality(TAttImage::kImgBest);By: mymap->SetImageCompression(0); mymap->SetImageQuality(TAttImage::kImgBest); Cheers,
Bertrand

Thanks a lot !!! It works fine ! I’m sorry to have disturbed you with such a silly mistake…