Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
Announcements
Intel Customer Support will be observing the Martin Luther King holiday on Monday, Jan. 17, and will return on Tues. Jan. 18.
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646
6599 Discussions

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

akshoy
Beginner
84 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
Employee
84 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
Reply