Convert YUV2 to JPEG
Posted: 2011-02-08T07:02:29-07:00
Hello together,
i have a problem to convert a yuv2 file to jpeg with the magicwand api.
Ich want to convert the image but the result is always wrong. The color or brightness is wrong.
In my opinion, the image has YUV2 Format knows as YUYV.
When ich convert the image first witrh a c function to rgb, than i can convert it to jpeg.
Is threre a way to convert the YUV2 image direkt to JPEG?
Code:
i have a problem to convert a yuv2 file to jpeg with the magicwand api.
Ich want to convert the image but the result is always wrong. The color or brightness is wrong.
In my opinion, the image has YUV2 Format knows as YUYV.
When ich convert the image first witrh a c function to rgb, than i can convert it to jpeg.
Is threre a way to convert the YUV2 image direkt to JPEG?
Code:
Code: Select all
double factors211[3] = {2.0,1.0,1.0};
double factors422[3] = {4.0,2.0,2.0};
wand = NewMagickWand();
dwand = NewDrawingWand();
status = MagickSetFormat(wand, "yuv");
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickSetSize(wand, 768, 288);
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickSetDepth(wand, 16);
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickSetSamplingFactors(wand, 3, factors422);
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickReadImageBlob(wand, pic, picsize);
if(status == MagickTrue) {
size_t compression = 70;
status = MagickSetFormat(wand, "JPG");
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickSetImageDepth(wand, 8);
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickSetSamplingFactors(wand, 3, factors211);
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickSetImageCompressionQuality(wand, compression);
if(status != MagickTrue) {
ThrowWandException(wand);
}
status = MagickWriteImage(wand, filename2);
if(status != MagickTrue) {
ThrowWandException(wand);
}
}