ist stehe gerade vor dem Problem, dass ich mit Hilfe der libjpeg die YUV-Daten aus einer JPEG Datei lesen möchte.
Mein Bild ist 864x496 Pixel groß. Also alles Vielfache von 16.
Mit folgendem Code versuche ich dsa zu bewerkstelligen:
Code: Alles auswählen
if (jpeg_read_header(&cinfo, TRUE) != JPEG_HEADER_OK)
{
return false;
}
cinfo.raw_data_out = 1;
cinfo.out_color_space = JCS_YCbCr;
jpeg_start_decompress(&cinfo);
JSAMPIMAGE sampleImage = new JSAMPARRAY[3];
JSAMPARRAY sampleArray = new JSAMPROW[cinfo.output_height + cinfo.output_height];
sampleImage[0] = sampleArray;
sampleImage[1] = sampleArray+cinfo.output_height;
sampleImage[2] = sampleArray+cinfo.output_height+cinfo.output_height/2;
JSAMPLE *SampleImageBuffer = new JSAMPLE[cinfo.output_width * cinfo.output_height * 3 >> 1];
for (int i = 0; i < cinfo.output_height; ++i)
{
sampleImage[0][i] = SampleImageBuffer+ i*cinfo.output_width;
}
int offset = cinfo.output_height;
for (int i = 0; i < cinfo.output_height/2; ++i)
{
sampleImage[1][i] = offset + SampleImageBuffer+ i*cinfo.output_width/2;
}
offset = cinfo.output_height+cinfo.output_height/2;
for (int i = 0; i < cinfo.output_height/2; ++i)
{
sampleImage[2][i] = offset + SampleImageBuffer+ i*cinfo.output_width/2;
}
for (; cinfo.output_scanline < cinfo.output_height;)
{
jpeg_read_raw_data(&cinfo, sampleImage, 16);
sampleImage[0] += 16;
sampleImage[1] += 8;
sampleImage[2] += 8;
}
Kann mir jemand sagen was ich falsch mache? Die Doku ist nicht besonders hilfreich.
Danke!