我想覆蓋另一個yuv圖像上的yuv圖像。假設如果有640x480圖像,我想在源圖像的右下方覆蓋一個小尺寸的圖像。 請幫忙。覆蓋另一個圖像上的yuv圖像
0
A
回答
2
平面YUV 420圖像由Y樣本的640 x 480字節組成,其後是320 x 240字節的U樣本和320 x 240字節的V樣本。由於每個2x2塊(而不是每個像素)只存在顏色信息,因此我將假設所有圖像尺寸ond位置都是2的倍數。(否則它會變得更加複雜。)
此外,I我們假設在一行的末尾沒有填充,在Y和U之間或者在U和V樣本之間。
void copyRect(unsigned char* targetImage, int targetWidth, int targetHeight,
unsigned char* sourceImage, int sourceWidth, int sourceHeight,
int sourceLeft, int sourceTop,
int width, int height,
int targetLeft, int targetTop)
{
// Y samples
unsigned char* tgt = targetImage + targetTop * targetWidth + targetLeft;
unsigned char* src = sourceImage + sourceTop * sourceWidth + sourceLeft;
for (int i = 0; i < height; i++) {
memcpy(tgt, src, width);
tgt += targetWidth;
src += sourceWidth;
}
// U samples
tgt = targetImage + targetHeight * targetWidth
+ (targetTop/2) * (targetWidth/2) + (targetLeft/2);
src = sourceImage + sourceHeight * sourceWidth
+ (sourceTop/2) * (sourceWidth/2) + (sourceLeft/2);
for (int i = 0; i < height/2; i++) {
memcpy(tgt, src, width/2);
tgt += targetWidth/2;
src += sourceWidth/2;
}
// V samples
tgt = targetImage + targetHeight * targetWidth + (targetHeight/2) * (targetWidth/2)
+ (targetTop/2) * (targetWidth/2) + (targetLeft/2);
src = sourceImage + sourceHeight * sourceWidth + (sourceHeight/2) * (sourceWidth/2)
+ (sourceTop/2) * (sourceWidth/2) + (sourceLeft/2);
for (int i = 0; i < height/2; i++) {
memcpy(tgt, src, width/2);
tgt += targetWidth/2;
src += sourceWidth/2;
}
}
我從來沒有試過編譯代碼。所以沒有保證。
的參數是:
targetImage:目標圖像,其中,所述其它圖像被複制到
targetWidth,targetHeigt的像素數據:對象圖像的尺寸
sourceImage:源圖像的像素數據,其中一部分被複制到其他圖像中
sourceWidth,sourceHeight:源圖像的尺寸
sourceLeft,sourceTop:區域的源圖像內的左上位置被複制
寬度,高度:的大小要複製的區域
targetLeft,targetTop:目標圖像中左上方的位置,其中區域被複制到
相關問題
- 1. 在css中覆蓋一個圖像與另一個圖像
- 2. 將圖像覆蓋在iOS中的另一幅圖像上
- 3. c#覆蓋另一個圖像
- 4. 在另一個頂部覆蓋圖像
- 5. 在另一個圖像(背景)的x,y上放置圖像(覆蓋圖)
- 6. 當另一個圖像覆蓋時,Android PNG圖像不可見
- 7. 用另一個透明圖像覆蓋圖像
- 8. 我想能夠與另一個上傳的圖像覆蓋圖像
- 9. 覆蓋圖像上的div
- 10. 覆蓋圖像
- 11. .NET Compact Framework:將兩個圖像合併爲一個/覆蓋另一個圖像
- 12. 如何在ImageView上覆蓋另一個圖像上的小圖標
- 13. 覆蓋地圖上的圖像
- 14. 覆蓋多個圖像
- 15. 覆蓋多個PNG圖像
- 16. javascript中的圖像覆蓋圖像
- 17. 在整個網頁上覆蓋圖像
- 18. XSLFO覆蓋圖像
- 19. Android圖像覆蓋
- 20. 圖像被覆蓋
- 21. 縮放時的圖像寬高比,一格覆蓋另一個
- 22. 覆蓋整個Google地圖的圖像
- 23. opencv在一個圖像上覆蓋另一個圖像,用蒙版和在圖中繪製
- 24. 在MapView上覆蓋圖像/地圖?
- 25. 在圖像上顯示覆蓋圖
- 26. 如何覆蓋另一個視圖上的modalViewController而不消失原始圖像?
- 27. 在android中的背景圖像上覆蓋圖像/圖標
- 28. 液體圖像覆蓋圖像
- 29. 覆蓋android中的兩個圖像來設置圖像視圖
- 30. YUV圖像處理
YUV圖像,平面和雙平面圖像,完整或減少的顏色信息(如422或420)有許多變體。你能否更具體地瞭解手頭的格式? – Codo
嗨Codo ...你可以請現在給yuv 420刨牀一些想法 – arccc
你打算重新問這個問題的每個圖像格式? –