diff --git a/prs/prs_file.cpp b/prs/prs_file.cpp index ddaba3aa7..8ee97dc33 100644 --- a/prs/prs_file.cpp +++ b/prs/prs_file.cpp @@ -258,7 +258,7 @@ void PRSFile::DrawFrame(int n,PRSVideoFrame *frame) { PRSVideoFrame *overFrame = image->GetDecodedFrame(); // Draw image on frame - // TODO + if (overFrame) overFrame->Overlay(frame,display->x,display->y,display->alpha,display->blend); // Clean up delete overFrame; diff --git a/prs/prs_video_frame.cpp b/prs/prs_video_frame.cpp index 8d46d842c..bd93a2005 100644 --- a/prs/prs_video_frame.cpp +++ b/prs/prs_video_frame.cpp @@ -39,6 +39,21 @@ #include "prs_video_frame.h" +////////// +// Macros +#ifndef MIN +#define MIN(a,b) ((a)<(b))?(a):(b) +#endif + +#ifndef MAX +#define MAX(a,b) ((a)>(b))?(a):(b) +#endif + +#ifndef MID +#define MID(a,b,c) MAX(a,MIN(b,c)) +#endif + + /////////////// // Constructor PRSVideoFrame::PRSVideoFrame () { @@ -60,5 +75,52 @@ PRSVideoFrame::~PRSVideoFrame () { /////////////////////////////////// // Overlay frame on top of another -void PRSVideoFrame::Overlay(PRSVideoFrame *dst,int x,int y,unsigned char alpha) { +void PRSVideoFrame::Overlay(PRSVideoFrame *dstFrame,int x,int y,unsigned char alpha,unsigned char blend) { + // TODO: Colorspace conversion, for now, the function assumes RGB32 on RGB32! + + // Get pointers + const unsigned char *src; + unsigned char *dst; + + // Get boundaries + int srcBpp = 4; + int dstBpp = 4; + int srcRowLen = w * srcBpp; + int dstRowLen = dstFrame->w * dstBpp; + int dstStarty = MAX(0,y); + int dstEndy = MIN(y+h,dstFrame->h); + int height = dstEndy - dstStarty; + int rowLen = MID(0,w,dstFrame->w - x); + + // Values + char sc1,sc2,sc3,a,ia; + char dc1,dc2,dc3,da; + + // Draw each row + for (int j=0;jdata[0] + (j+dstStarty)*dstRowLen + x*dstBpp; + + // Draw the row + for (int i=0;i