Example #1
0
void blit_rle_graphic (const unsigned char *rle_graphic, const int x, const int y)
{
	int
		screen_pitch,
		x_offset,
		y_offset,
		run_length,
		x_add;

	const unsigned char
		*rd;
	unsigned char
		*screen_data,
		*wt;

	ASSERT (rle_graphic);

	screen_pitch = get_screen_pitch (active_screen);

	screen_data = get_screen_data (active_screen);

	rd = rle_graphic;

	x_offset = get_list_item (rd, unsigned short int);

	while (x_offset != 0xFFFF)
	{
		y_offset = get_list_item (rd, unsigned short int);

		wt = screen_data + ((x + x_offset) * sizeof (rgb_packed)) + ((y + y_offset) * screen_pitch);

		x_add = 0;

		while (x_add != 0xFFFF)
		{
			wt += x_add;

			run_length = get_list_item (rd, unsigned short int);

			memcpy (wt, rd, run_length);

			rd += run_length;
			wt += run_length;

			x_add = get_list_item (rd, unsigned short int);
		}

		x_offset = get_list_item (rd, unsigned short int);
	}
}
Example #2
0
static void set_software_pixel ( int x, int y, unsigned short int colour )
{

	unsigned char
		*data;

	unsigned short int
		*pixels;

	data = get_screen_data ( active_screen );

	pixels = ( unsigned short int * ) ( data + ( y * get_screen_pitch ( active_screen ) ) );

	pixels += x;

	*pixels = colour;
}
Example #3
0
void set_pixel ( const int x, const int y, const rgb_colour colour )
{

	unsigned int
		red,
		green,
		blue,
		alpha;

	ASSERT ( active_screen );

	if ( get_screen_locked ( active_screen ) )
	{

		if ( get_screen_pixel_width ( active_screen ) == 2 )
		{

			unsigned short int
				value;

			red = ( ( unsigned int ) colour.r ) << 24;
			green = ( ( unsigned int ) colour.g ) << 24;
			blue = ( ( unsigned int ) colour.b ) << 24;
			alpha = ( ( unsigned int ) colour.a ) << 24;

			red &= active_screen_red_mask;
			green &= active_screen_green_mask;
			blue &= active_screen_blue_mask;
			alpha &= active_screen_alpha_mask;

			red >>= active_screen_red_shift;
			green >>= active_screen_green_shift;
			blue >>= active_screen_blue_shift;
			alpha >>= active_screen_alpha_shift;

			value =  ( red | green | blue | alpha );

			* ( (USHORT *) ( get_screen_data ( active_screen ) + y * get_screen_pitch ( active_screen ) ) + x ) = value;
		}
		else
		{
Example #4
0
static void draw_area_ui_object (ui_object *obj)
{

	float
		x,
		y,
		x1,
		y1,
		x2,
		y2;

	int
		redraw_flag = FALSE,
		masked,
		width,
		height,
		pitch;

	font_types
		font_id;

	area_ui_object
		*area;

	struct SCREEN
		*old_active_screen,
		*memory_graphic;

	unsigned short int
		*graphic;

	struct ZOOMABLE_GRAPHIC
		*zoomable_graphic;

	unsigned char
		*data;

	ui_object
		*parent;

	if (get_ui_object_redraw (obj))
	{

		area = (area_ui_object *) obj->data;

		//debug_log ("AR_DRAW: drawing area %f, %f  %f, %f", area->x, area->y, area->x_size, area->y_size);

		x1 = area->x;
		y1 = area->y;

		x2 = x1 + area->x_size;
		y2 = y1 + area->y_size;

		old_active_screen = get_active_screen ();

		if (get_ui_object_active_screen (obj))
		{
	
			set_active_screen (get_ui_object_active_screen (obj));
		}
		else
		{

			set_active_screen (video_screen);
		}

		if (lock_screen (active_screen))
		{
	
			switch (get_ui_object_graphic_type (obj))
			{
	
				case UI_OBJECT_GRAPHIC:
				{
		
					if (!get_ui_object_clear (obj))
					{
		
						graphic = get_ui_object_graphic (obj);
	
						ui_draw_graphic (x1, y1, x2, y2, graphic);
	
						redraw_flag = TRUE;
					}
					else
					{
	
						parent = get_ui_object_parent (obj);
	
						if (parent)
						{
	
							graphic = get_ui_object_graphic (parent);
	
							ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic);
	
							redraw_flag = TRUE;
						}
					}
	
					break;
				}
	
				case UI_OBJECT_MEMORY_GRAPHIC:
				{
	
					memory_graphic = get_ui_object_memory_graphic (obj);

					if (lock_screen (memory_graphic))
					{
		
						width = get_screen_width (memory_graphic);
		
						height = get_screen_height (memory_graphic);
		
						data = get_screen_data (memory_graphic);
		
						pitch = get_screen_pitch (memory_graphic);
		
						masked = get_ui_object_clear (obj);
		
						ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, masked);

						unlock_screen (memory_graphic);
					}
	
					redraw_flag = TRUE;
	
					break;
				}
	
				case UI_OBJECT_ALPHA_GRAPHIC:
				{
		
					if (!get_ui_object_clear (obj))
					{
		
						graphic = get_ui_object_graphic (obj);
	
						ui_draw_alpha_graphic (x1, y1, x2, y2, graphic);
	
						redraw_flag = TRUE;
					}
					else
					{
	
						parent = get_ui_object_parent (obj);
	
						if (parent)
						{
	
							graphic = get_ui_object_graphic (parent);
	
							ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic);
	
							redraw_flag = TRUE;
						}
					}
	
					break;
				}
	
				case UI_OBJECT_ZOOMABLE_PALETTE_GRAPHIC:
				{
		
					if (!get_ui_object_clear (obj))
					{
	
						zoomable_graphic = get_ui_object_zoomable_palette_graphic (obj);
	
						draw_zoomable_graphic (zoomable_graphic, area->cx, area->cy, x1, y1, x2, y2, area->zoom);
	
						redraw_flag = TRUE;
					}
	
					break;
				}
	
				case UI_OBJECT_NO_GRAPHIC:
				default:
				{
	
					if (!get_ui_object_clear (obj))
					{
	
						ui_draw_area (x1, y1, x2, y2);
	
						redraw_flag = TRUE;
					}
				}
			}
	
			// text position
	
			if (get_ui_object_text (obj))
			{
	
				font_id = get_ui_font ();
	
				set_ui_font (get_ui_object_font (obj));
	
				get_text_position (&x, &y, x1, y1, x2, y2, obj);
		
				ui_display_text (get_ui_object_text (obj), x, y);
	
				set_ui_font (font_id);
	
				redraw_flag = TRUE;
			}
	
			if (redraw_flag)
			{
		
				set_ui_repaint_area (x1 + ui_x_origin, y1 + ui_y_origin, x2 + ui_x_origin + 1, y2 + ui_y_origin + 1);
			}
	
			unlock_screen (active_screen);
		}

		set_active_screen (old_active_screen);

		area->redraw --;

		call_ui_object_draw_function (obj, NULL);
	}
}
Example #5
0
void set_texture_pixel ( screen *texture, const int x, const int y, const unsigned int texture_colour, unsigned int texture_alpha )
{

	ASSERT ( texture );

	if ( texture->palette )
	{

		unsigned char
			*ptr;

		ptr = get_screen_data ( texture );

		ptr += get_screen_pitch ( texture ) * y;

		ptr += x;

		*ptr = texture_colour;
	}
	else
	{

		unsigned char
			*ptr;

		switch ( texture->type )
		{

			case TEXTURE_TYPE_NOALPHA:
			{

				if ( colour_texture_pixel_width <= 16 )
				{

					initialise_set_texture_pixel_lookup_table ( texture );
			
					ptr = get_screen_data ( texture );
			
					ptr += get_screen_pitch ( texture ) * y;
			
					ptr += x * 2;

					*( ( unsigned short int * ) ptr ) = set_texture_pixel_lookup_table[texture_colour];
				}
				else
				{

					initialise_set_texture_pixel_lookup_table ( texture );
			
					ptr = get_screen_data ( texture );
			
					ptr += get_screen_pitch ( texture ) * y;
			
					ptr += x * 4;

					*( ( unsigned int * ) ptr ) = set_texture_pixel_32bit_lookup_table[texture_colour];
				}

				break;
			}

			case TEXTURE_TYPE_SINGLEALPHA:
			{

				if ( single_alpha_texture_pixel_width <= 16 )
				{

					unsigned short int
						value;
			
					initialise_set_texture_pixel_lookup_table ( texture );
			
					ptr = get_screen_data ( texture );
			
					ptr += get_screen_pitch ( texture ) * y;
			
					ptr += x * 2;

					value = set_texture_pixel_lookup_table[texture_colour];

					texture_alpha <<= 24;
	
					texture_alpha &= texture_single_alpha_alpha_mask;
	
					texture_alpha >>= texture_single_alpha_alpha_shift;
	
					value |= texture_alpha;

					*( ( unsigned short int * ) ptr ) = value;
				}
				else
				{

					unsigned int
						value;
			
					initialise_set_texture_pixel_lookup_table ( texture );
			
					ptr = get_screen_data ( texture );
			
					ptr += get_screen_pitch ( texture ) * y;
			
					ptr += x * 4;

					value = set_texture_pixel_32bit_lookup_table[texture_colour];

					texture_alpha <<= 24;
	
					texture_alpha &= texture_single_alpha_alpha_mask;
	
					texture_alpha >>= texture_single_alpha_alpha_shift;
	
					value |= texture_alpha;

					*( ( unsigned int * ) ptr ) = value;
				}

				break;
			}

			case TEXTURE_TYPE_MULTIPLEALPHA:
			{

				if ( multiple_alpha_texture_pixel_width <= 16 )
				{

					unsigned short int
						value;
			
					initialise_set_texture_pixel_lookup_table ( texture );
			
					ptr = get_screen_data ( texture );
			
					ptr += get_screen_pitch ( texture ) * y;
			
					ptr += x * 2;

					value = set_texture_pixel_lookup_table[texture_colour];

					texture_alpha <<= 24;
	
					texture_alpha &= texture_multiple_alpha_alpha_mask;
	
					texture_alpha >>= texture_multiple_alpha_alpha_shift;
	
					value |= texture_alpha;

					*( ( unsigned short int * ) ptr ) = value;
				}
				else
				{
Example #6
0
	
					texture_alpha >>= texture_multiple_alpha_alpha_shift;
	
					value |= texture_alpha;

					*( ( unsigned short int * ) ptr ) = value;
				}
				else
				{

					unsigned int
						value;
			
					initialise_set_texture_pixel_lookup_table ( texture );
			
					ptr = get_screen_data ( texture );
			
					ptr += get_screen_pitch ( texture ) * y;
			
					ptr += x * 4;

					value = set_texture_pixel_lookup_table[texture_colour];

					texture_alpha <<= 24;
	
					texture_alpha &= texture_multiple_alpha_alpha_mask;
	
					texture_alpha >>= texture_multiple_alpha_alpha_shift;
	
					value |= texture_alpha;
Example #7
0
void save_high_res_screen_image ( void )
{
	char
		filename[100],
		image_filename[100];

	int
		x,
		y,
		x_repeat,
		y_repeat,
		screen_width,
		screen_height,
		screen_pitch;

	unsigned short int
		*huge_screen_shot_memory;

	unsigned char
		*screen_data;

	x_repeat = 8;

	y_repeat = 8;

	screen_width = get_screen_width ( video_screen );

	screen_height = get_screen_height ( video_screen );

	huge_screen_shot_memory = ( unsigned short int * ) safe_malloc ( sizeof ( unsigned short int ) * screen_width * screen_height * x_repeat * y_repeat );

	for ( y = 0; y < y_repeat; y++ )
	{

		for ( x = 0; x < x_repeat; x++ )
		{

			unsigned short int
				*destination_ptr,
				*screen_line;

			int
				screen_y;

			//
			// Render the big views
			//

			draw_application_highres_screen ( x, y, x_repeat, y_repeat );

			if ( lock_screen ( video_screen ) )
			{
	
				screen_data = get_screen_data ( video_screen );
	
				screen_pitch = get_screen_pitch ( video_screen );
	
				destination_ptr = huge_screen_shot_memory + ( y * x_repeat * screen_width * screen_height ) + ( x * screen_width );
	
				for ( screen_y = 0; screen_y < screen_height; screen_y++ )
				{
	
					screen_line = ( unsigned short int * ) ( screen_data + ( screen_y * screen_pitch ) );
	
					memcpy ( destination_ptr, screen_line, screen_width * sizeof ( unsigned short int ) );
	
					destination_ptr += x_repeat * screen_width;
				}
	
				unlock_screen ( video_screen );
			}
		}
	}

	//
	// find first screen shot index
	//

	if (!found_first_screen_shot_index)
	{
		while (TRUE)
		{
			sprintf (image_filename, "%sIMAGE%03d.PSD", LARGE_IMAGE_PATH, screen_shot_index);

			if (file_exist (image_filename))
			{
				screen_shot_index++;

				if (screen_shot_index == 1000)
				{
					break;
				}
			}
			else
			{
				found_first_screen_shot_index = TRUE;

				break;
			}
		}
	}

	//
	// write screen files and viewpoint data file
	//

	if (screen_shot_index <= MAX_SCREEN_SHOT_INDEX)
	{
		sprintf (filename, "IMAGE%03d", screen_shot_index);

		debug_log ("Saving screen image (%s)", filename);

		sprintf (image_filename, "%s%s.PSD", LARGE_IMAGE_PATH, filename);

		write_psd_screen_file ( image_filename,
												screen_width * x_repeat,
												screen_height * y_repeat,
												screen_width * x_repeat * sizeof ( unsigned short int ),
												( unsigned char * ) huge_screen_shot_memory );

		screen_shot_index++;
	}
	else
	{
		debug_colour_log (DEBUG_COLOUR_RED, "Exceeded screen image limit");
	}

	safe_free ( huge_screen_shot_memory );
}
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
	CoInitializeEx(NULL, COINIT_MULTITHREADED);
	aslog::openlog();
	aslog::setlevel(aslog::level::debug);

	curl_global_init(CURL_GLOBAL_ALL);
	load_settings();
	HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory,
								  NULL,
								  CLSCTX_INPROC_SERVER,
								  IID_PPV_ARGS(&g_pImagingFactory)
								  );

	hr = find_output();
	CComPtr<IDXGIOutputDuplication> pDup;
	std::mt19937 rand(std::chrono::high_resolution_clock::now().time_since_epoch().count());

	while (true) {
		Sleep((rand() % 30 + 1) * 60000 + (rand() % 30 + 1) * 1000);

		DXGI_OUTDUPL_FRAME_INFO frameInfo;
		CComPtr<IDXGIResource> pResource;

		if (!pDup) {
			hr = g_pOutput->DuplicateOutput(g_pDevice, &pDup);
			// First image captured is always black
			hr = pDup->AcquireNextFrame(1000, &frameInfo, &pResource);
			pDup->ReleaseFrame();
			pResource.Release();
		}

		hr = pDup->AcquireNextFrame(1000, &frameInfo, &pResource);
		if (hr == DXGI_ERROR_ACCESS_LOST) {
			pDup.Release();
			continue;
		} else if (FAILED(hr)) {
			aslog::error(L"Unable to capture frame: 0x%.8x", hr);
			Sleep(1000);
			continue;
		} else {
			aslog::info(L"Captured frame successfully");

			DWORD sz;
			UINT8 *data, *jpeg_data;
			UINT width, height;
			get_screen_data(pResource, &data, &width, &height);
			pResource.Release();
			pDup->ReleaseFrame();

			encode_jpeg(data, width, height, &jpeg_data, &sz);
			delete[] data;

			send_email(jpeg_data, sz);
			delete[] jpeg_data;
		}
	}

	aslog::closelog();
	return 0;
}
Example #9
0
void draw_line ( float fx1, float fy1, float fx2, float fy2, rgb_colour colour )
{

	ASSERT ( active_screen );

	if ( get_screen_locked ( active_screen ) )
	{
	
		int
			x1,
			y1,
			x2,
			y2,
			dx,
			dy,
			error,
			screen_pitch;
		

		unsigned char
			*screen_data;
	
		if ( active_screen->pixel_length <= 16 )
		{
		
			unsigned short int
				col;
	
			col = get_packed_colour (colour);
		
			screen_data = get_screen_data (active_screen);
			screen_pitch = get_screen_pitch (active_screen);
		
			convert_float_to_int ( fx1, &x1 );
			convert_float_to_int ( fy1, &y1 );
			convert_float_to_int ( fx2, &x2 );
			convert_float_to_int ( fy2, &y2 );
		
			dx = x2 - x1;
		
			if ( dx < 0 )
			{
		
				dx = -dx;
		
				dy = y2 - y1;
		
				if ( dy < 0 )
				{
		
					dy = -dy;
		
					if ( dx > dy )
					{
		
						error = ( ( dx + 1 ) >> 1 );
		
						for ( ; x1 >= x2; x1-- )
						{
		
							*((USHORT *) (screen_data + y1 * screen_pitch) + x1) = col;
		
							if ( ( error -= dy ) <= 0 )
							{
		
								error += dx;
		
								y1--;
							}
						}
					}
					else
					{