Hi all,
i’m writing an application that use 4 SDL_Rect in a single SDL_Surface. The
source image came from a videograbber and are in YUV format. So i create 4
YUVOverlay and link them with the Y, U and V components of my image in the
follow manner.
overlay = SDL_CreateYUVOverlay(horz, vert, SDL_IYUV_OVERLAY, screen);
overlay2= SDL_CreateYUVOverlay(horz, vert, SDL_IYUV_OVERLAY, screen);
overlay3= SDL_CreateYUVOverlay(horz, vert, SDL_IYUV_OVERLAY, screen);
overlay4= SDL_CreateYUVOverlay(horz, vert, SDL_IYUV_OVERLAY, screen);
pY=image1;
pU=image1+DIM_WIDTH*DIM_HEIGHT;
pV=pU+(DIM_WIDTH*DIM_HEIGHT/4);
pY2=image2;
pU2=image2+DIM_WIDTH*DIM_HEIGHT;
pV2=pU+(DIM_WIDTH*DIM_HEIGHT/4);
.....................
....................
overlay->pixels[0] = pY;
overlay->pixels[1] = pU;
overlay->pixels[2] = pV;
overlay2->pixels[0] = pY2;
overlay2->pixels[1] = pU2;
overlay2->pixels[2] = pV2;
overlay3->pixels[0] = pY3;
overlay3->pixels[1] = pU3;
overlay3->pixels[2] = pV3;
overlay4->pixels[0] = pY4;
overlay4->pixels[1] = pU4;
overlay4->pixels[2] = pV4;
............................
After I set the position and the size of SDL_Rect in the SDL_Surface and copy
a new image in the 4 YUVOverlay like the follow.
…
dstrect.x = 0;
dstrect.y = 0;
dstrect.w = (horz-1)/2;
dstrect.h = (vert-1)/2;
dstrect2.x = (horz-1)/2;
dstrect2.y = 0;
dstrect2.w = horz/2;
dstrect2.h = vert/2;
dstrect3.x = 0;
dstrect3.y = vert/2;
dstrect3.w = (horz-1)/2;
dstrect3.h = vert/2;
dstrect4.x = (horz-1)/2;
dstrect4.y = vert/2;
dstrect4.w = (horz-1)/2;
dstrect4.h = vert/2;
SDL_LockYUVOverlay(overlay);
memcpy(image1, data+(IMG_BYTE_SIZE_YUV*0), IMG_BYTE_SIZE_YUV);
SDL_DisplayYUVOverlay(overlay, &dstrect);
SDL_UnlockYUVOverlay(overlay);
SDL_LockYUVOverlay(overlay2);
memcpy(image2, data+(IMG_BYTE_SIZE_YUV*1), IMG_BYTE_SIZE_YUV);
SDL_DisplayYUVOverlay(overlay2, &dstrect2);
SDL_UnlockYUVOverlay(overlay2);
SDL_LockYUVOverlay(overlay3);
memcpy(image3, data+(IMG_BYTE_SIZE_YUV*0), IMG_BYTE_SIZE_YUV);
SDL_DisplayYUVOverlay(overlay3, &dstrect3);
SDL_UnlockYUVOverlay(overlay3);
SDL_LockYUVOverlay(overlay4);
memcpy(image4, data+(IMG_BYTE_SIZE_YUV*1), IMG_BYTE_SIZE_YUV);
SDL_DisplayYUVOverlay(overlay4, &dstrect4);
SDL_UnlockYUVOverlay(overlay4);
.......................
The result is incorrect because the image on the left-up corner with the face
is reflected in the other images with the clock. Are my steps correct?
There is something i can do to avoid this problem?
Thanks a lot by now and sorry for my english.
PS: May i attach an image to illustrate this problem?-------------------------------------------------------
Carlo Alberto Scarpato