Beispiel #1
0
//绘制棋盘
BOOL CMainWnd::DrawBoard(HDC hDC)
{
	SetBkMode(hDC, TRANSPARENT);//设置字体背景模式为透明

	//填充棋盘材质
	if (gameSet.BoardFileName[0] != 0)
	{
		DisplayImage(hDC, gameSet.BoardFileName, &rtBoard);
	}

	//绘制棋盘
	GameType->DrawBoard(hDC);

	return TRUE;
}
void CSoftWareConfig::OnNextFrame() 
{
	// TODO: Add your control notification handler code here
	if(m_imgBuff.IsNull()) return;

	CapsuleParam param;
	EIndex index= m_pProcessor->GetProcessIndex();

	switch(index)
	{
	case eFirst:
		param = GetListContent(0);
		break;
	case eSecond:
		param = GetListContent(2);
		break;
	}

	TImgDim	dim = m_imgBuff.Dimension();
	if((3 == dim.bytesPerPixel) && (!m_hue1VectPerFrame.empty()))
	{
		m_hue1Vect.insert(m_hue1Vect.end(), m_hue1VectPerFrame.begin(), m_hue1VectPerFrame.end());
		m_hue2Vect.insert(m_hue2Vect.end(), m_hue2VectPerFrame.begin(), m_hue2VectPerFrame.end());

		param.capColor	= GetStdHue(m_hue1Vect);
		param.bodyColor = GetStdHue(m_hue2Vect);
	}
	
	if((1 == dim.bytesPerPixel) && (!m_dimVectPerFrame.empty()))
	{
		m_dimVect.insert(m_dimVect.end(), m_dimVectPerFrame.begin(), m_dimVectPerFrame.end());
		param= GetStdDim(m_dimVect);
	}
	
	switch(index)
	{
	case eFirst:
		SetListContent(0, param);
		break;
	case eSecond:
		SetListContent(2, param);
		break;
	}

	m_imgBuff.GoNextFrame();
	DisplayImage();	
	Process(m_imgBuff);
}
//====================================================================================
void AnimationDemo(void)
{
	uint32_t frame_index;
	
	memset(DisplayBuffer, 0, sizeof(DisplayBuffer));
	DrawTextToBuffer(3, (uint8_t*)"   ANIMATION DEMO    ", DisplayBuffer);
	WriteBufferToDisplay(DisplayBuffer);
	sleep(1);
	
	for(frame_index = 0; frame_index < FRAME_COUNT; frame_index++)
	{
		usleep(FRAME_DEALY * 1000);
		DisplayImage((unsigned char*)BR_LOGO_ANIM[frame_index]);
	}
	sleep(2);
}
Beispiel #4
0
//====================================================================================
void AnimationDemo(void)
{
uint32_t frame_index;

// Splash screen
memset(DisplayBuffer, 0, sizeof(DisplayBuffer));
DrawTextToBuffer(3, " ANIMATION DEMO ", DisplayBuffer);
WriteBufferToDisplay(DisplayBuffer);
MsDelay(1000);

for(frame_index = 0; frame_index < FRAME_COUNT; frame_index++)
{
MsDelay(FRAME_DEALY);
DisplayImage((unsigned char*)BR_LOGO_ANIM[frame_index]);
}
MsDelay(2000);
}
Beispiel #5
0
void CFoosballDlg::OnBnClickedLoadImage()
{
//	OnBnClickedStop();
	char	DirectoryName[128];
	char	Filter[128];
	sprintf_s(Filter, "Bitmap Image (*.bmp)|*.bmp|| | TIFF Document (*.tif)|*.tif");
	sprintf_s(DirectoryName, "%sImages\\*.bmp", APP_DIRECTORY);
	CFileDialog dlg(TRUE, NULL, CA2W(DirectoryName), OFN_PATHMUSTEXIST, CA2W(Filter), NULL);
	if (dlg.DoModal() == IDOK) {
		char	FileName[512];
		strcpy_s(FileName, CT2A(dlg.GetPathName()));
		//AfxMessageBox(FileName);
		AcqBuf = imread(FileName, -1);
		AcqBuf.copyTo(DispBuf);
		DisplayImage(DispBuf, FALSE);
	}
}
Beispiel #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    timer= new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(DisplayImage()));
    //timer->start();
    vid=new cv::VideoCapture();
    termcrit = cv::TermCriteria(cv::TermCriteria::COUNT|cv::TermCriteria::EPS,20,0.03);
    subPixWinSize = cv::Size(10,10);
    winSize = cv::Size(31,31);
    needToInit=true;
    addRemovePt=false;

    imcount=0;

}
Beispiel #7
0
void MainWindow::on_pushButton_virtual_depth_clicked()
{
    qDebug() << "==============================";
    qDebug() << "Virtual Frame:" << ++g_frameIdx;

    VirtualRgbdSensor sensor;
    const QString shapefile = QString(PCApps_PATH) + "/IO/VirtualConfig/shapes.txt";
    const QString camerafile = QString(PCApps_PATH) + "/IO/VirtualConfig/camera.txt";
    const QString noisefile = QString(PCApps_PATH) + "/IO/VirtualConfig/noise.txt";
    sensor.MakeVirtualDepth(shapefile, camerafile, noisefile);
    sensor.GrabFrame(colorImg, depthImg);
    DisplayImage(colorImg, depthImg);

    // point cloud work
    pcworker->Work(colorImg, depthImg, annots, &sharedData);

    // show point cloud on the screen
    UpdateView();
}
void UltrasoundSupport::CreateQtPartControl( QWidget *parent )
{
m_Timer = new QTimer(this);

// create GUI widgets from the Qt Designer's .ui file
m_Controls.setupUi( parent );

connect( m_Controls.m_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this, SLOT(OnClickedAddNewDevice()) ); // Change Widget Visibilities
connect( m_Controls.m_DeviceManagerWidget, SIGNAL(NewDeviceButtonClicked()), this->m_Controls.m_NewVideoDeviceWidget, SLOT(CreateNewDevice()) ); // Init NewDeviceWidget
connect( m_Controls.m_ActiveVideoDevices, SIGNAL(ServiceSelectionChanged(us::ServiceReferenceU)), this, SLOT(OnChangedActiveDevice()) );
connect( m_Controls.m_RunImageTimer, SIGNAL(clicked()), this, SLOT(OnChangedActiveDevice()) );
connect( m_Controls.m_ShowImageStream, SIGNAL(clicked()), this, SLOT(OnChangedActiveDevice()) );
connect( m_Controls.m_NewVideoDeviceWidget, SIGNAL(Finished()), this, SLOT(OnNewDeviceWidgetDone()) ); // After NewDeviceWidget finished editing
connect( m_Controls.m_FrameRate, SIGNAL(valueChanged(int)), this, SLOT(OnChangedFramerateLimit(int)) );
connect( m_Controls.m_FreezeButton, SIGNAL(clicked()), this, SLOT(OnClickedFreezeButton()) );
connect( m_Timer, SIGNAL(timeout()), this, SLOT(DisplayImage()));

// Initializations
m_Controls.m_NewVideoDeviceWidget->setVisible(false);
std::string filter = "(&(" + us::ServiceConstants::OBJECTCLASS() + "="
+ "org.mitk.services.UltrasoundDevice)("
+ mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE + "=true))";
m_Controls.m_ActiveVideoDevices->Initialize<mitk::USDevice>(
mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL ,filter);
m_Controls.m_ActiveVideoDevices->SetAutomaticallySelectFirstEntry(true);
m_FrameCounter = 0;

// Create Node for US Stream
if (m_Node.IsNull())
{
m_Node = mitk::DataNode::New();
m_Node->SetName("US Support Viewing Stream");
//create a dummy image (gray values 0..255) for correct initialization of level window, etc.
mitk::Image::Pointer dummyImage = mitk::ImageGenerator::GenerateRandomImage<float>(100, 100, 1, 1, 1, 1, 1, 255,0);
m_Node->SetData(dummyImage);
m_OldGeometry = dynamic_cast<mitk::SlicedGeometry3D*>(dummyImage->GetGeometry());
}

m_Controls.tabWidget->setTabEnabled(1, false);

LoadUISettings();
}
Beispiel #9
0
void DisplayImageToScreen (Image * image, ScreenBuffer * buffer, Map const * map)
{
	assert (image && buffer);
	// Verify that image and buffer point to valid memory

	if (!ClipImageToScreen (image))
	{
		return;
	}

	if (map)	// Ensure that map points to something
	{
		DisplayImageToMap (image, buffer, map);
	}

	else
	{
		DisplayImage (image, buffer);
	}
}
void DisplayVideo(void) {
	int i, j;
	uchar tmp;

	Pr_SelectFIFO = ~Pr_SelectFIFO;
	al422b_SelectFIFO(Pr_SelectFIFO);
	al422b_Reset();

	for (j = 55; j >= 0; j--) {
		for(i=79;i>=0;i--) {
			tmp = ~ReadPixel();

			bufferImage[i][j/8][1] |= ((tmp&0x80)>>7)<<(j%8);
			bufferImage[i][j/8][0] |= ((tmp&0x40)>>6)<<(j%8);

			SkipOnePixel();
		}
		SkipOneLine();
	}
	DisplayImage(80, 56, 0, 0, grayLeave2);
}
Beispiel #11
0
int main(int argc, char **argv)
	{
	char *src_filespec, *dst_filespec ;
	static OPTION options[] =
		{
		{"Hue (%.0f deg)",		AdjustHue,			-45},
		{"Saturation (%.1f)",	AdjustSaturation,	 70},
		{"Value (%.1f)",		AdjustValue,		120},
		{NULL,					NULL,				  0}
		} ;
	OPTION *option ;
	IMAGE *image ;

	if (argc != 3 && argc != 4)
		{
		fprintf(stderr, "Usage: %s src-file dst-file {option#}\n", argv[0]) ;
		exit(255) ;
		}

	src_filespec = argv[1] ;
	dst_filespec = argv[2] ;

	image = ReadBMP24(src_filespec) ;

	if ((option = GetOption(argc, argv, options))== NULL)
		{
		fprintf(stderr, "Usage: %s src-file dst-file {option#}\n", argv[0]) ;
		exit(255) ;
		}

	image = (option->function)(image, option->param) ;

	WriteBMP24(dst_filespec, image) ;
	FreeImage(image) ;
	DisplayImage(dst_filespec, option->format, option->param) ;

	return 0 ;
	}
Beispiel #12
0
void MainWindow::slotOpenImgSrc()
{
    QFileInfo fileImage;
    int ret = optImgFile.OpenImage(fileImage);
    if(ret == 0)
    {
        nameSrcImg = fileImage.fileName();
        pathSrcImg = fileImage.filePath();
        dirSrcImg  = fileImage.absolutePath();

        //读取并显示源图像
        imgSrc = procCVImg.ReadImage(pathSrcImg);
        if(imgSrc.data)
        {
            DisplayImage(imgSrc,0);
        }
        else
        {
            QMessageBox::critical(this,tr("图像错误"),tr("读取图像失败!"),
                                  QMessageBox::Yes);
            return;
        }
    }
}
Beispiel #13
0
// Window procedure, handles all messages for this program
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HMENU	hMenu;
    static ILuint	Colours;
    static RECT		Rect;
    static HDROP	hDrop;

    static char OpenFileName[2048];
    static char OpenFilter[2048];
    static char *OFilter[] = {
        "All Files (*.*)", "*.*",
        "Half-Life Model Files (*.mdl)", "*.mdl",
        "Homeworld Image Files (*.lif)", "*.lif",
        "Image Files (All Supported Types)", "*.jpe;*.jpg;*.jpeg;*.lif;*.bmp;*.ico;*.pbm;*.pgm;*.pnm;*.ppm;*.png;*.bw;*.rgb;*.rgba;*.sgi;*.tga;*.tif;*.tiff;*.pcx",
        "Jpeg Files (*.jpe, *.jpg, *.jpeg)", "*.jpe;*.jpg;*.jpeg",
        "Microsoft Bitmap Files (*.bmp)", "*.bmp",
        "Microsoft Icon Files (*.ico)", "*.ico",
        "OpenIL Files (*.oil)", "*.oil",
        "Portable AnyMap Files (*.pbm, *.pgm, *.pnm, *.ppm)", "*.pbm;*.pgm;*.pnm;*.ppm",
        "Portable Network Graphics Files (*.png)", "*.png",
        "Sgi Files (*.sgi)", "*.bw;*.rgb;*.rgba;*.sgi",
        "Targa Files (*.tga)", "*.tga",
        "Tiff Files (*.tif)", "*.tif;*.tiff",
        "Quake Wal Files (*.wal)", "*.wal",
        "ZSoft Pcx Files (*.pcx)", "*.pcx",
        "\0\0"
    };

    static OPENFILENAME Ofn = {
        sizeof(OPENFILENAME),
        hWnd,
        NULL,
        OpenFilter,
        NULL,
        0,
        0,
        OpenFileName,
        512,
        NULL,
        0,
        NULL,
        NULL,
        OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST,
        0,
        0,
        NULL,
        NULL,
        NULL,
        NULL
    };

    switch (message)
    {
    case WM_CREATE:
        GenFilterString(OpenFilter, OFilter);

        hDC = GetDC(hWnd);
        DragAcceptFiles(hWnd, TRUE);

        break;

    case WM_CLOSE:
        DestroyGDI();
        ReleaseDC(hWnd, hDC);
        DestroyWindow(hWnd);
        UnregisterClass(TITLE, hInstance);
        break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;

    case WM_PAINT:
        DisplayImage();
        InvalidateRect(hWnd, NULL, FALSE);
        break;

    case WM_KEYDOWN:
        if (wParam == VK_ESCAPE)
            PostQuitMessage(0);
        InvalidateRect(hWnd, NULL, FALSE);
        break;

    case WM_DROPFILES:
        hDrop = (HDROP)wParam;
        DragQueryFile(hDrop, 0, OpenFileName, 512);

        DestroyGDI();
        LoadImages(OpenFileName);

        DragFinish (hDrop);
        return 0;

    case WM_COMMAND:
        FilterType = LOWORD(wParam);

        switch (LOWORD(wParam))
        {
        case ID_FILE_EXIT:
            PostMessage(hWnd, WM_CLOSE, 0, 0);
            return (0L);

        case ID_FILE_LOAD:
            sprintf(OpenFileName, "*.*");
            Ofn.lpstrFilter = OpenFilter;
            Ofn.lpstrFile = OpenFileName;
            Ofn.lpstrTitle = "Open File";
            Ofn.nFilterIndex = 1;
            Ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;

            if (!GetOpenFileName(&Ofn))
                return (0L);

            DestroyGDI();
            LoadImages(OpenFileName);

            return (0L);

        case ID_EDIT_PAUSE:
            IsPaused = true;
            return 0;

        case ID_EDIT_RESUME:
            IsPaused = false;
            QueryPerformanceCounter((LARGE_INTEGER*)&StartTime);
            return 0;
        }

    default:
        return (DefWindowProc(hWnd, message, wParam, lParam));
    }

    return (0L);
}
void UI_Handler()
{
    /* Up button */
    if (Button(&GPIO_PORTB_DATA, 0, 1, 0))
      oldstate_up = 1;
    if (oldstate_up && Button(&GPIO_PORTB_DATA, 0, 1, 1)) { // detect logical one to logical zero transition

      if (cursorPos > 0) {
        TFT_Set_Pen(MainScreen.Color, 0);
        TFT_Set_Brush(1, MainScreen.Color, 0, LEFT_TO_RIGHT, CL_WHITE, CL_WHITE);
        TFT_Rectangle(Image3.Left, Image3.Top, (Image3.Left+Image3.Width), (Image3.Top+Image3.Height));
        Image3.Top -= 16;
        DrawImage(&Image3);
        cursorPos--;
      } else if (filesListOffset > 0) {
        filesListOffset--;
        UI_UpdateFilesList();
      }
      oldstate_up = 0;
    }
    
    /* Down button */
    if (Button(&GPIO_PORTE_DATA, 5, 1, 0))
      oldstate_down = 1;
    if (oldstate_down && Button(&GPIO_PORTE_DATA, 5, 1, 1)) { // detect logical one to logical zero transition
      
      if (cursorPos < 11 && cursorPos < (FilesListCount-1)) {
        TFT_Set_Pen(MainScreen.Color, 0);
        TFT_Set_Brush(1, MainScreen.Color, 0, LEFT_TO_RIGHT, CL_WHITE, CL_WHITE);
        TFT_Rectangle(Image3.Left, Image3.Top, (Image3.Left+Image3.Width), (Image3.Top+Image3.Height));
        Image3.Top += 16;
        DrawImage(&Image3);
        cursorPos++;
      } else if ((cursorPos+filesListOffset+1) < FilesListCount) {
        filesListOffset++;
        UI_UpdateFilesList();
      }
      oldstate_down = 0;
    }
    
    /* Enter button */
    if (Button(&GPIO_PORTH_DATA, 2, 1, 0))
      oldstate_press = 1;
    if (oldstate_press && Button(&GPIO_PORTH_DATA, 2, 1, 1)) { // detect logical one to logical zero transition

      if (CurrentState == IMAGE_DISPLAY) {
        UI_ShowMainScreen();
        UI_UpdateFolderName();
        UI_UpdateFilesList();
        CurrentState = IDLE;
      } else if (CurrentState == IDLE) {
        if (FilesList[cursorPos+filesListOffset]->Type == 'A')  {
          if (DownloadMode == 0)
            PlayAudio(FilesList[cursorPos+filesListOffset]->ID);
          else if (DownloadMode == 1 && SDSave_Disabled == 0)
            SaveAudio(FilesList[cursorPos+filesListOffset]->ID, FilesList[cursorPos+filesListOffset]->Name);
        } else if (FilesList[cursorPos+filesListOffset]->Type == 'F') {
            if (CurrentFolderID == 0 || FilesList[cursorPos+filesListOffset]->ID == 0) // Only possible to enter folders if we are in the ROOT folder currently (Only 1-level deep folder tree currently supported!)
              RequestFolderContent(FilesList[cursorPos+filesListOffset]->ID, FilesList[cursorPos+filesListOffset]->Name, FilesList[cursorPos+filesListOffset]->NameLength);
        } else if (FilesList[cursorPos+filesListOffset]->Type == 'I') {
            DisplayImage(FilesList[cursorPos+filesListOffset]->ID);
        }
      } else if (CurrentState == FILE_RECEIVE) { // Stop the playback
        TerminateAudio();
        CurrentState = IDLE;
      }
      oldstate_press = 0;
    }
    
   /* Right button */
    if (Button(&GPIO_PORTE_DATA, 4, 1, 0))
      oldstate_right = 1;
    if (oldstate_right && Button(&GPIO_PORTE_DATA, 4, 1, 1)) { // detect logical one to logical zero transition
      if (SDSave_Disabled == 0) { // Enabling the SD Saving mode (right click) is only possible if SD card is inserted
        DownloadMode = ~DownloadMode;
        GPIO_PORTA_DATA6_bit = DownloadMode;
      }

      oldstate_right = 0;
    }
}
Beispiel #15
0
/**
 * Program entry point
 */
int main(int argc, char* argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB );
    glutInitWindowPosition(20, 20);
    glutInitWindowSize(kWindowWidth, kWindowHeight);
    glutCreateWindow("Metamorphosis: CS148 Assignment 4");
    
    glutDisplayFunc(DisplayCallback);
    glutReshapeFunc(ReshapeCallback);
    glutKeyboardFunc(KeyboardCallback);
    
    //
    // load the configuration from config.txt, or other file as specified
    //
    std::string configFile = "config.txt";
    if (argc > 1) configFile = argv[1];
    
    char sourceName[64], targetName[64];
    char saveName[64], loadName[64];
    STImage *sourceImage, *targetImage;
    parseConfigFile(configFile.c_str(),
                    sourceName, targetName,
                    saveName, loadName,
                    &sourceImage, &targetImage);
    delete sourceImage;
    delete targetImage;
    
    //
    // load the features from the saved features file
    //
    loadLineEditorFile(loadName, AddFeatureCallback,
                       sourceName, targetName,
                       &sourceImage, &targetImage);
    
    //
    // run the full morphing algorithm before going into the main loop to
    // display an image
    //
    
    // these weighting parameters (Beier & Nelly 1992) can be changed if desired
    const float a = 0.5f, b = 2.0f, p = 0.2f;
    
    GenerateMorphFrames(sourceImage, gSourceFeatures,
                        targetImage, gTargetFeatures,
                        a, b, p);
    
    
    //
    // display a test or debug image here if desired
    // (note: comment this out if you call DisplayImage from elsewhere)
    //
    //    STImage *result = sourceImage;
    
    // use this to test your image blending
    
    //    STImage *result = BlendImages(sourceImage, targetImage, 0.5f);
    
    
    // use this to test your field morph
    /*
    STImage *result = FieldMorph(sourceImage, gSourceFeatures, gTargetFeatures,
                                 0.5f, a, b, p);
    */
    
    // use this to test your image morphing
    
     STImage *result = MorphImages(sourceImage, gSourceFeatures,
     targetImage, gTargetFeatures,
     0.5f, a, b, p);
     
    
    DisplayImage(result);
    
    // enter the GLUT main loop
    glutMainLoop();
    
    return 0;
}
//*****************************************************************************
//
// This task manages the scurrying about of a spider.
//
//*****************************************************************************
static void
SpiderTask(void *pvParameters)
{
    uint32_t ui32Dir, ui32Image, ui32Temp;
    int32_t i32X, i32Y, i32Spider;

    //
    // Get the spider number from the parameter.
    //
    i32Spider = (long)pvParameters;

    //
    // Add the current tick count to the random entropy pool.
    //
    RandomAddEntropy(xTaskGetTickCount());

    //
    // Reseed the random number generator.
    //
    RandomSeed();

    //
    // Indicate that this spider is alive.
    //
    HWREGBITW(&g_ui32SpiderAlive, i32Spider) = 1;

    //
    // Indicate that this spider is not dead yet.
    //
    HWREGBITW(&g_ui32SpiderDead, i32Spider) = 0;

    //
    // Get a local copy of the spider's starting position.
    //
    i32X = g_pi32SpiderX[i32Spider];
    i32Y = g_pi32SpiderY[i32Spider];

    //
    // Choose a random starting direction for the spider.
    //
    ui32Dir = RandomNumber() >> 29;

    //
    // Start by displaying the first of the two spider animation images.
    //
    ui32Image = 0;

    //
    // Loop forever.
    //
    while(1)
    {
        //
        // See if this spider has been killed.
        //
        if(HWREGBITW(&g_ui32SpiderDead, i32Spider) == 1)
        {
            //
            // Wait for 2 seconds.
            //
            vTaskDelay((1000 / portTICK_RATE_MS) * 2);

            //
            // Clear the spider from the display.
            //
            DisplayImage(i32X - (SPIDER_WIDTH / 2), i32Y - (SPIDER_HEIGHT / 2),
                         g_pui8SpiderBlankImage);

            //
            // Indicate that this spider is not alive.
            //
            HWREGBITW(&g_ui32SpiderAlive, i32Spider) = 0;

            //
            // Delete the current task.  This should never return.
            //
            vTaskDelete(NULL);

            //
            // In case it does return, loop forever.
            //
            while(1)
            {
            }
        }

        //
        // Enter a critical section while the next move for the spider is
        // determined.  Having more than one spider trying to move at a time
        // (via preemption) would make the collision detection check fail.
        //
        taskENTER_CRITICAL();

        //
        // Move the spider.
        //
        i32X += g_pi32SpiderStepX[ui32Dir];
        i32Y += g_pi32SpiderStepY[ui32Dir];

        //
        // See if the spider has cross the boundary of its area, if it has
        // collided with another spider, or if random chance says that the
        // spider should turn despite not having collided with anything.
        //
        if((i32X < SPIDER_MIN_X) || (i32X > SPIDER_MAX_X) ||
           (i32Y < SPIDER_MIN_Y) || (i32Y > SPIDER_MAX_Y) ||
           (SpiderCollide(i32Spider, i32X, i32Y) != -1) ||
           (RandomNumber() < 0x08000000))
        {
            //
            // Undo the previous movement of the spider.
            //
            i32X -= g_pi32SpiderStepX[ui32Dir];
            i32Y -= g_pi32SpiderStepY[ui32Dir];

            //
            // Get a random number to determine the turn to be made.
            //
            ui32Temp = RandomNumber();

            //
            // Determine how to turn the spider based on the random number.
            // Half the time the spider turns to the left and half the time it
            // turns to the right.  Of each half, it turns a quarter of a turn
            // 12.5% of the time and an eighth of a turn 87.5% of the time.
            //
            if(ui32Temp < 0x10000000)
            {
                ui32Dir = (ui32Dir + 2) & 7;
            }
            else if(ui32Temp < 0x80000000)
            {
                ui32Dir = (ui32Dir + 1) & 7;
            }
            else if(ui32Temp < 0xf0000000)
            {
                ui32Dir = (ui32Dir - 1) & 7;
            }
            else
            {
                ui32Dir = (ui32Dir - 2) & 7;
            }
        }

        //
        // Update the position of the spider.
        //
        g_pi32SpiderX[i32Spider] = i32X;
        g_pi32SpiderY[i32Spider] = i32Y;

        //
        // Exit the critical section now that the spider has been moved.
        //
        taskEXIT_CRITICAL();

        //
        // Have the display task draw the spider at the new position.  Since
        // there is a one pixel empty border around all the images, and the
        // position of the spider is incremented by only one pixel, this also
        // erases any traces of the spider in its previous position.
        //
        DisplayImage(i32X - (SPIDER_WIDTH / 2), i32Y - (SPIDER_HEIGHT / 2),
                     g_ppui8SpiderImage[(ui32Dir * 2) + ui32Image]);

        //
        // Toggle the spider animation index.
        //
        ui32Image ^= 1;

        //
        // Delay this task for an amount of time based on the direction the
        // spider is moving.
        //
        vTaskDelay(g_pui32SpiderDelay[ui32Dir & 1]);

        //
        // Add the new tick count to the random entropy pool.
        //
        RandomAddEntropy(xTaskGetTickCount());

        //
        // Reseed the random number generator.
        //
        RandomSeed();
    }
}
Beispiel #17
0
// display logos
bool CPictureViewer::DisplayLogo(t_channel_id channel_id, int posx, int posy, int width, int height, bool upscale, bool center_x, bool center_y)
{	
        char fname[255];
	bool ret = false;
	bool logo_ok = false;
	
	int logo_w = width;
	int logo_h = height;
	int logo_bpp = 0;
	
	// first png, then jpg, then gif
	std::string strLogoExt[3] = { ".png", ".jpg" , ".gif" };
	
	// check for logo
	for (int i = 0; i < 3; i++)
	{
		sprintf(fname, "%s/%llx%s", g_settings.logos_dir.c_str(), channel_id & 0xFFFFFFFFFFFFULL, strLogoExt[i].c_str());
		if(!access(fname, F_OK)) 
		{
			logo_ok = true;
			break;
		}
	}
	
	if(logo_ok)
	{
		std::string logo_name = fname; // UTF-8
		
		// get logo real size
		getSize(fname, &logo_w, &logo_h, &logo_bpp);
	
		// scale only PNG logos
		if( logo_name.find(".png") == (logo_name.length() - 4) )
		{
			// upscale
			if(upscale)
			{	
				//rescale logo image
				float aspect = (float)(logo_w) / (float)(logo_h);
					
				if (((float)(logo_w) / (float)width) > ((float)(logo_h) / (float)height)) 
				{
					logo_w = width;
					logo_h = (int)(width / aspect);
				}
				else
				{
					logo_h = height;
					logo_w = (int)(height * aspect);
				}
			}
			
			ret = DisplayImage(fname, center_x?posx + (width - logo_w)/2 : posx, center_y?posy + (height - logo_h)/2 : posy, logo_w, logo_h);
		}
		else
		{
			ret = DisplayImage(fname, posx, posy, width, height);
		}
        }

	return ret;
}