Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6740 Discussions

Moving from IJL to UIC ( Jpeg to DIB and vice versa)

akshoy
Beginner
304 Views

I am porting a function which was written using IJL. It was decoding a JPEG to DIB buffer. Currently i want to use UIC.For doing this i am taking reference from the following code snippet which is also available in the UIC documentation and forums (http://software.intel.com/en-us/forums/showthread.php?t=81584). Is this code applicable for this case too? I have not yet tried for DIB to JPEG.

Please help to know what all I am missing to convert a Jpeg to DIB.

Ref code snippet.

int i;

CStdFileInput fi;

JPEGDecoder jpegdec;

ExcStatus status;

if( !BaseStream::IsOk(fi.Open(argv[1])) )

return 1;

status = jpegdec.Init();

if(ExcStatusOk != status)

return 1;

status = jpegdec.AttachStream(fi);

if(ExcStatusOk != status)

return 1;

ImageColorSpec colorSpec;

ImageSamplingGeometry geometry;

status = jpegdec.ReadHeader(colorSpec,geometry);

if(ExcStatusOk != status)

return 1;

Image imageCn;

ImageDataOrder dataOrder;

int nOfComponents = geometry.NOfComponents();

if(colorSpec.DataRange()->BitDepth() + 1 <= 8)

dataOrder.SetDataType(T8u);

else

dataOrder.SetDataType(T16u);

dataOrder.ReAlloc(Interleaved, nOfComponents);

dataOrder.PixelStep()[0] = nOfComponents;

dataOrder.LineStep() [0] = AlignStep(geometry.RefGridRect().Width() * nOfComponents);

geometry.SetEnumSampling(S444);

imageCn.Buffer().ReAlloc(dataOrder, geometry);

imageCn.ColorSpec().ReAlloc(nOfComponents);

imageCn.ColorSpec().SetColorSpecMethod(Enumerated);

imageCn.ColorSpec().SetComponentToColorMap(Direct);

for(i = 0; i < nOfComponents; i++)

{

if(colorSpec.DataRange()->BitDepth() + 1 <= 8)

imageCn.ColorSpec().DataRange().SetAsRange8u(255);

else

imageCn.ColorSpec().DataRange().SetAsRange16u(1 <<

colorSpec.DataRange()->BitDepth());

}

imageCn.ColorSpec().SetEnumColorSpace(RGB);

status = jpegdec.SetParams(imageCn.ColorSpec(),imageCn.Buffer().BufferFormat().SamplingGeometry());

if(ExcStatusOk != status)

return 1;

status = jpegdec.ReadData(imageCn.Buffer().DataPtr(),dataOrder);

if(ExcStatusOk != status)

return 1;

0 Kudos
1 Reply
Chao_Y_Intel
Moderator
304 Views
Hello,

The main examplefor using UIC for JPEG decoding can be found at jpeg.cpp file. You may can check that file for the code.

Thanks,
Chao
0 Kudos
Reply