📄 vfakeio.cxx
字号:
void PFakeVideoInputDevice::GrabBouncingBoxes(BYTE *resFrame)
{
unsigned width=0;
unsigned height=0;
GetFrameSize(width,height);
grabCount++;
FillRect(resFrame, width, height,
0, 0, //Position x,y
width, height, //Fill the whole frame with the colour.
200,200,200); //a light grey colour.
double t= (grabCount%50) -25 ;
double h= t*t*height*0.85/625;
int yBox = (int)h;
yBox= (yBox>>1) * 2; //yBox is even.
int boxHeight= (int)(height*0.1);
boxHeight= (boxHeight >>1) * 2;
int boxWidth = (int)(width*0.1);
boxWidth = (boxWidth >>1) * 2;
FillRect(resFrame, width, height,
width>>2,yBox,
boxWidth,boxHeight,
255, 0, 0); // Red Box.
t= (grabCount%40) -20 ;
h= t*t*height*0.85/400 ;
yBox = (int)h;
yBox= (yBox>>1) * 2; //yBox is even.
FillRect(resFrame, width, height,
width>>1,yBox,
boxWidth,boxHeight,
0, 255, 0); // Green
t= (grabCount%100) -50 ;
h= t*t*height*0.85/2500;
yBox = (int)h;
yBox= (yBox>>1) * 2; //yBox is even.
FillRect(resFrame, width, height,
(width>>1) + (width>>2),yBox,
boxWidth,boxHeight,
0, 0, 255); // Blue
}
void PFakeVideoInputDevice::GrabNTSCTestFrame(BYTE *resFrame)
{
// Test image # 1
// A static image is generated, consisting of a series of coloured block.
// Sample NTSC test frame is found at http://www.displaymate.com/patterns.html
//
static int row1[7][3] = {
{ 204, 204, 204 }, // 80% grey
{ 255, 255, 0 }, // yellow
{ 0, 255, 255 }, // cyan
{ 0, 255, 0 }, // green
{ 255, 0, 255 }, // magenta
{ 255, 0, 0 }, // red
{ 0, 0, 255 }, // blue
};
static int row2[7][3] = {
{ 0, 0, 255 }, // blue
{ 19, 19, 19 }, // black
{ 255, 0, 255 }, // magenta
{ 19, 19, 19 }, // black
{ 0, 255, 255 }, // cyan
{ 19, 19, 19 }, // black
{ 204, 204, 204 }, // grey
};
static int row3a[4][3] = {
{ 8, 62, 89 }, // I
{ 255, 255, 255 }, // white
{ 58, 0, 126 }, // +Q
{ 19, 19, 19 }, // black
};
static int row3b[3][3] = {
{ 0, 0, 0 }, // 3.5
{ 19, 19, 19 }, // 7.5
{ 38, 38, 38 }, // 11.5
};
static int row3c[3] = { 19, 19, 19 };
unsigned width=0;
unsigned height=0;
GetFrameSize(width,height);
int row1Height = (int)(0.66 * height);
int row2Height = (int)((0.75 * height) - row1Height);
row1Height = (row1Height>>1)*2; //Require that height is even.
row2Height = (row2Height>>1)*2;
int row3Height = height - row1Height - row2Height;
int columns[8];
PINDEX i;
for(i=0;i<7;i++){
columns[i]= i*width/7;
columns[i]= (columns[i]>>1)*2; // require that columns[i] is even.
}
columns[7] = width;
// first row
for (i = 0; i < 6; i++)
FillRect(resFrame, width, height,
columns[i], 0, //Position x,y
columns[i+1]-columns[i], row1Height, //Size (width*height)
row1[i][0], row1[i][1], row1[i][2]); // rgb
// second row
for (i = 0; i < 7; i++)
FillRect(resFrame, width, height,
columns[i], row1Height,
columns[i+1]-columns[i], row2Height,
row2[i][0], row2[i][1], row2[i][2]);
// third row
int columnBot[5];
for (i=0; i<4; i++) {
columnBot[i]= i*columns[5]/4;
columnBot[i] = 2 * (columnBot[i]>>1);
}
columnBot[4]= columns[5];
for (i = 0; i < 4; i++)
FillRect(resFrame, width, height,
columnBot[i],row1Height + row2Height,
columnBot[i+1]-columnBot[i], row3Height,
row3a[i][0], row3a[i][1], row3a[i][2]);
for (i=0; i<3; i++) {
columnBot[i] = columns[4]+(i*width)/(7*3);
columnBot[i] = 2 * (columnBot[i]>>1); //Force even.
}
columnBot[3]= columns[5];
for (i = 0; i < 3; i++)
FillRect(resFrame, width, height,
columnBot[i], row1Height + row2Height,
columnBot[i+1] - columnBot[i], row3Height,
row3b[i][0], row3b[i][1], row3b[i][2]);
FillRect(resFrame, width, height,
columns[6], row1Height + row2Height,
columns[7]-columns[6], row3Height,
row3c[0], row3c[1], row3c[2]);
}
void PFakeVideoInputDevice::GrabMovingBlocksTestFrame(BYTE * resFrame)
{
// Test image # 2
/*Brightness is set to alter, left to right.
Colour component alters top to bottom.
Image contains lots of high and low resolution areas.
*/
unsigned width, height, wi,hi, colourIndex,colNo, boxSize;
#define COL(b,x,y) ((b+x+y)%7)
static int background[7][3] = {
{ 254, 254, 254 }, // white
{ 255, 255, 0 }, // yellow
{ 0, 255, 255 }, // cyan
{ 0, 255, 0 }, // green
{ 255, 0, 255 }, // magenta
{ 255, 0, 0 }, // red
{ 0, 0, 255 }, // blue
};
width=0; //Stops compiler warning about unitialized variables.
height=0;
GetFrameSize(width,height);
int columns[8];
int heights[8];
for( wi=0; wi<8; wi++) {
columns[wi] = wi*width/14; //Absolutely guarantee columns is even
columns[wi] = columns[wi] * 2;
}
columns[7] = width;
for( hi=0; hi<8; hi++) {
heights[hi] = (hi * height) / 14; //Absolutely guarantee heights is even
heights[hi] = heights[hi] * 2;
}
heights[7] = height;
grabCount++;
colourIndex = time(NULL);//time in seconds since last epoch.
// Provides a difference if run on two ohphone sessions.
colNo= (colourIndex/10)%7; //Every 10 seconds, coloured background blocks move.
for(hi=0; hi<7 ;hi++) //Fill the background in.
for(wi=0 ; wi<7 ;wi++) {
FillRect(resFrame,width, height, //frame details.
columns[wi], heights[hi], //X,Y Pos.
columns[wi+1] - columns[wi], heights[hi+1] - heights[hi],
background[COL(colNo,wi,hi)][0], background[COL(colNo,wi,hi)][1],background[COL(colNo,wi,hi)][2]);
}
//Draw a black box rapidly moving down the left of the window.
boxSize= height/10;
hi = (2 * colourIndex) % ( (height-boxSize)/2); //Make certain hi is even.
hi = hi*2;
FillRect(resFrame, width, height, 10, hi, boxSize, boxSize, 0, 0, 0); //Black Box.
//Draw four parallel black lines, which move up the middle of the window.
colourIndex = colourIndex/3; //Every three seconds, lines move.
for(wi=0;wi<2; wi++) {
columns[wi]= ((wi+1)*width)/6;
columns[wi] = columns[wi]*2; //Force columns to be even.
}
hi = colourIndex % ((height - 16) / 2);
hi = (height - 16) - (hi * 2); //hi is even, Lines move in opp. direction to box.
unsigned yi;
for( yi=0; yi<4; yi++)
FillRect(resFrame, width, height,
columns[0],hi+(yi*4),
columns[1] - columns[0], 2, 0, 0, 0);
}
void PFakeVideoInputDevice::GrabMovingLineTestFrame(BYTE *resFrame)
{
// Test image # 3
// Faster image generation. Same every times system runs.
// Colours cycle through. Have a vertical lines style of pattern.
// There is a horizontal bar which moves down the screen .
unsigned width,height;
static int v=0;
int r,g,b;
width=0; //Stops compiler warning about unitialized variables.
height=0;
GetFrameSize(width,height);
v++;
r = (200+v) & 255;
g = (100+v) & 255;
b = (000+v) & 255;
FillRect(resFrame, width, height, 0, 0,width, height, r, g, b);
int hi = (v % (height-2) >> 1) *2;
FillRect(resFrame, width, height, 0, hi, width, 2, 0, 0, 0);
}
void PFakeVideoInputDevice::GrabBlankImage(BYTE *resFrame)
{
unsigned width=0;
unsigned height=0;
GetFrameSize(width,height);
grabCount++;
FillRect(resFrame, width, height,
0, 0, //Position x,y
width, height, //Fill the whole frame with the colour.
200,200,200); //a light grey colour.
}
// End Of File ///////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -