Пример #1
0
void draw_grid_lines(uint16_t x, uint16_t y){
         int16_t light_width = 1; 
     //GRID LINES
    fill_rec(lefts[x][y],lefts[x][y]+light_width,tops[x][y],tops[x][y]+button_width,BLACK);
    fill_rec(lefts[x][y],lefts[x][y]+button_width,tops[x][y],tops[x][y]+light_width,BLACK);
    int16_t temp = button_width - light_width;
    fill_rec(lefts[x][y]+temp,lefts[x][y]+button_width,tops[x][y],tops[x][y]+button_width, BLACK);
    fill_rec(lefts[x][y],lefts[x][y]+button_width,tops[x][y]+temp,tops[x][y]+button_width, BLACK);
       
}
Пример #2
0
void draw_shading(uint16_t x, uint16_t y){
   
    int16_t light_width = 2; 
     //light
    fill_rec(lefts[x][y],lefts[x][y]+light_width,tops[x][y],tops[x][y]+button_width,WHITE);
    fill_rec(lefts[x][y],lefts[x][y]+button_width,tops[x][y],tops[x][y]+light_width,WHITE);
    //shadow
    int16_t temp = button_width - light_width;
    fill_rec(lefts[x][y]+temp,lefts[x][y]+button_width,tops[x][y],tops[x][y]+button_width, DARK_GRAY);
    fill_rec(lefts[x][y],lefts[x][y]+button_width,tops[x][y]+temp,tops[x][y]+button_width, DARK_GRAY);
  
}
void CLS_DlgStreamPusher::FillDisplayRect()
{
	struct_stream_info* streamInfo = GetStreamStrcInfo();
	if (NULL == streamInfo){
		TRACE("NULL == streamInfo");
		return;
	}

	streamInfo->m_screen_surface = SDL_GetWindowSurface(streamInfo->m_show_screen);
	if (NULL == streamInfo->m_screen_surface){
		TRACE("NULL == streamInfo->m_screen_surface");
		return;
	}

	//背景色
	int bgcolor = SDL_MapRGB(streamInfo->m_screen_surface->format, 0x00, 0x00, 0x00);
	fill_rec(streamInfo->m_screen_surface, m_pStreamInfo->m_xleft, m_pStreamInfo->m_ytop, m_pStreamInfo->m_width, m_pStreamInfo->m_height,bgcolor);

	if (SDL_UpdateWindowSurface(streamInfo->m_show_screen) != 0){
		TRACE("SDL_UpdateWindowSurface ERR");
	}
}
void CLS_DlgStreamPusher::audio_display(struct_stream_info *_pstrct_streaminfo)
{
	if (audio_callback_time == 0){
		TRACE("audio_callback_time == 0");
		return;
	}
	int i, i_start, x, y1, y, ys, delay, n, nb_display_channels;
	int ch, channels, h, h2, bgcolor, fgcolor;
	int16_t time_diff;
	int rdft_bits, nb_freq;

	for (rdft_bits = 1; (1 << rdft_bits) < 2 * _pstrct_streaminfo->m_height; rdft_bits++)
		;
	nb_freq = 1 << (rdft_bits - 1);

	/* compute display index : center on currently output samples */
	channels = _pstrct_streaminfo->m_audio_tgt.channels;
	nb_display_channels = channels;
	if (!_pstrct_streaminfo->m_paused) {
		int data_used = _pstrct_streaminfo->m_show_mode == SHOW_MODE_WAVES ? _pstrct_streaminfo->m_width : (2 * nb_freq);
		n = 2 * channels;
		delay = _pstrct_streaminfo->m_audio_write_buf_size;
		delay /= n;

		/* to be more precise, we take into account the time spent since
		the last buffer computation */
		if (audio_callback_time) {
			time_diff = av_gettime() - audio_callback_time;
			delay -= (time_diff * _pstrct_streaminfo->m_audio_tgt.freq) / 1000000;
		}

		delay += 2 * data_used;
		if (delay < data_used)
			delay = data_used;

		i_start = x = compute_mod(_pstrct_streaminfo->m_sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
		if (_pstrct_streaminfo->m_show_mode == SHOW_MODE_WAVES) {
			h = INT_MIN;
			for (i = 0; i < 1000; i += channels) {
				int idx = (SAMPLE_ARRAY_SIZE + x - i) % SAMPLE_ARRAY_SIZE;
				int a = _pstrct_streaminfo->m_sample_array[idx];
				int b = _pstrct_streaminfo->m_sample_array[(idx + 4 * channels) % SAMPLE_ARRAY_SIZE];
				int c = _pstrct_streaminfo->m_sample_array[(idx + 5 * channels) % SAMPLE_ARRAY_SIZE];
				int d = _pstrct_streaminfo->m_sample_array[(idx + 9 * channels) % SAMPLE_ARRAY_SIZE];
				int score = a - d;
				if (h < score && (b ^ c) < 0) {
					h = score;
					i_start = idx;
				}
			}
		}

		_pstrct_streaminfo->m_audio_last_i_start = i_start;
	}


	//背景色
	bgcolor = SDL_MapRGB(_pstrct_streaminfo->m_screen_surface->format, 0x00, 0x00, 0x00);
	if (_pstrct_streaminfo->m_show_mode == SHOW_MODE_WAVES) {
		SDL_Rect sdl_rect;
		_pstrct_streaminfo->m_xleft = 0;
		_pstrct_streaminfo->m_ytop = 0;
		sdl_rect.x = _pstrct_streaminfo->m_xleft;
		sdl_rect.y = _pstrct_streaminfo->m_ytop;
		sdl_rect.w = _pstrct_streaminfo->m_width;
		sdl_rect.h = _pstrct_streaminfo->m_height;

		fill_rec(_pstrct_streaminfo->m_screen_surface, _pstrct_streaminfo->m_xleft, _pstrct_streaminfo->m_ytop, _pstrct_streaminfo->m_width, _pstrct_streaminfo->m_height,bgcolor);

		fgcolor = SDL_MapRGB(_pstrct_streaminfo->m_screen_surface->format, 0xff, 0xff, 0xff);

		/* total height for one channel */
		h = _pstrct_streaminfo->m_height / nb_display_channels;
		/* graph height / 2 */
		h2 = (h * 9) / 20;
		for (ch = 0; ch < nb_display_channels; ch++) {
			i = i_start + ch;
			y1 = _pstrct_streaminfo->m_ytop + ch * h + (h / 2); /* position of center line */
			for (x = 0; x < _pstrct_streaminfo->m_width; x++) {
				y = (_pstrct_streaminfo->m_sample_array[i] * h2) >> 15;
				if (y < 0) {
					y = -y;
					ys = y1 - y;
				}
				else {
					ys = y1;
				}

				fill_rec(_pstrct_streaminfo->m_screen_surface, _pstrct_streaminfo->m_xleft + x, ys, 1, y, fgcolor);

				i += channels;
				if (i >= SAMPLE_ARRAY_SIZE)
					i -= SAMPLE_ARRAY_SIZE;
			}
		}

		fgcolor = SDL_MapRGB(_pstrct_streaminfo->m_screen_surface->format, 0x00, 0x00, 0xff);

		for (ch = 1; ch < nb_display_channels; ch++) {
			y = _pstrct_streaminfo->m_ytop + ch * h;

			fill_rec(_pstrct_streaminfo->m_screen_surface, _pstrct_streaminfo->m_xleft, y, _pstrct_streaminfo->m_width, 1, fgcolor);
		}
		if (SDL_UpdateWindowSurface(_pstrct_streaminfo->m_show_screen) != 0){
			TRACE("SDL_UpdateWindowSurface ERR");
		}
		//SDL_CreateRGBSurface();
		SDL_UpdateTexture(_pstrct_streaminfo->m_sdlTexture, NULL, _pstrct_streaminfo->m_screen_surface->pixels, _pstrct_streaminfo->m_screen_surface->pitch);
		SDL_RenderClear(_pstrct_streaminfo->m_sdlRenderer);
		SDL_RenderCopy(_pstrct_streaminfo->m_sdlRenderer, _pstrct_streaminfo->m_sdlTexture, &sdl_rect, &sdl_rect);
		SDL_RenderPresent(_pstrct_streaminfo->m_sdlRenderer);
	}
Пример #5
0
void draw_button_background(uint16_t x, uint16_t y) {

    fill_rec(lefts[x][y],lefts[x][y]+button_width-1,tops[x][y],tops[x][y]+button_width-1,button_col);
       
}