<br><br><div class="gmail_quote">2009/1/22 Tomas Carnecky <span dir="ltr"><<a href="mailto:tom@dbservice.com">tom@dbservice.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On 01/22/2009 06:15 AM, Amos Tibaldi wrote:<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">
<br>
Hello,<br>
I am trying to use the Xv extension in order to display images on<br>
windows. I have obtained the image formats with<br>
</div><a href="http://xvc.fo" target="_blank">xvc.fo</a> <<a href="http://xvc.fo" target="_blank">http://xvc.fo</a>> = XvListImageFormats( xvc.display, xvc.port, (int<div class="Ih2E3d"><br>
*)&formats );<br>
and I have chosen the format<br>
id: 0x59565955 (UYVY)<br>
guid: 55595659-0000-0010-8000-00aa00389b71<br>
bits per pixel: 16<br>
number of planes: 1<br>
type: YUV (packed)<br>
</div></blockquote>
<br>
[snip]<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
and to display the image with<br>
void XVWindow::Redraw()<br>
{<br>
unsigned short int u, y, v;<br>
RGBToUYVY(255,255,0,&u,&y,&v);<br>
unsigned short int thecolor = u << 12 | y << 8 | v << 4 | y;<br>
<br>
for ( int y=0; y<ImageHeight; y++ )<br>
for ( int x=0; x<ImageWidth; x++ )<br>
((unsigned short int *)BGimage->data)[ y * ImageWidth + x ] = thecolor;<br>
<br>
counter++;<br>
XvPutImage( xvc.display, xvc.port, window, gc,<br>
BGimage, 0, 0, ImageWidth, ImageHeight,<br>
0, 0, WindowWidth, WindowHeight );<br>
}<br>
</blockquote>
<br></div>
I think you are confused by 'bits per pixel: 16' in the Xv format list. Your code in :Redraw() that composes the pixel is wrong. I know I couldn't explain it better, so I'm including a link to a website that explains it pretty well:<br>
<a href="http://www.fourcc.org/yuv.php#YUY2" target="_blank">http://www.fourcc.org/yuv.php#YUY2</a><br>
(Each macropixel is 32 bits, so each of the YUV components is 8 bit and not 4 like you used in your code)<br>
<br>
tom<br>
<br>
<br>
</blockquote></div>Hello, BGImage->data_size is equal to w x h x 2 bytes (2B per pixel in the data allocated), and X has calculated it. Moreover I have tried even with<br><<24 |<<16|<<8 and the thing is the same. Are you sure of that?<br>
<br>Thanks,<br><br clear="all"><br>-- <br>Amos Tibaldi<br>