Exemplo n.º 1
0
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ GetPixel16
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Ignores attempts to read outside of bounds
TBLColour16 CBLCanvas::GetPixel16(
	SInt16			inX,
	SInt16			inY)
{
	RGBColour		colour;
	
	GetPixelRGB(inX,inY,colour);
	return RGBColourToBlastColour16(&colour);
}
Exemplo n.º 2
0
// Averages each cell's color
void GetGems()
{
	int y, py;
	int x, px;

	COLORREF color;

	int r_avg = 0;
	int g_avg = 0;
	int b_avg = 0;

	Screenshot();

	for (y = 0; y < cell_count; y++)
	{
		for (x = 0; x < cell_count; x++)
		{
			// Reset averages for cell
			r_avg = 0;
			g_avg = 0;
			b_avg = 0;

			for (py = 0; py < box_size; py++)
			{
				for (px = 0; px < box_size; px++)
				{
					// Get pixel by calculating it relative to the game_origin
					// (game_origin) then the current cell_size (x * 40) then by the
					// current_center of the cell, finally by the position
					color = GetPixelRGB(game_origin.x + (x * 40) + current_center + px,
						(game_origin.y + (y * 40) + current_center + py));

					// Add up R, G, B separately
					r_avg += GetRValue(color);
					g_avg += GetGValue(color);
					b_avg += GetBValue(color);
				}
			}

			// Calculate averages, then construct RGB COLORREF
			grid[y][x] = RGB(r_avg / box_size * box_size,
				g_avg / box_size * box_size,
				b_avg / box_size * box_size);
		}
	}

}
Exemplo n.º 3
0
void DisplayGrid()
{
	FILE* f;
	
	// Attempt to open file for debugging
	if (fopen_s(&f, debug_path, "w"))
	{
		printf("Couldn't open the file located at debug_path!\n");
		return;
	}

	// Display average color table for RED
	fprintf(f, "<meta http-equiv=\"refresh\" content=\"1\"><h2>Average Red Colors</h2>"
		"<table cellpadding=0 cellspacing=0>");
	for (int i = 0; i < cell_count; i++)
	{
		fprintf(f, "<tr>");
		for (int j = 0; j < cell_count; j++)
		{
			COLORREF color = grid[i][j];
			fprintf(f, "  <td bgcolor=\"#%02X0000\" width=15 height=15></td>\n",
				GetRValue(color));
		}
		fprintf(f, "</tr>\n");
	}
	fprintf(f, "</table>");

	// Display average color table for GREEN
	fprintf(f, "<h2>Average Green Colors</h2>"
		"<table cellpadding=0 cellspacing=0>");
	for (int i = 0; i < cell_count; i++)
	{
		fprintf(f, "<tr>");
		for (int j = 0; j < cell_count; j++)
		{
			COLORREF color = grid[i][j];
			fprintf(f, "  <td bgcolor=\"#00%02X00\" width=15 height=15></td>\n",
				GetGValue(color));
		}
		fprintf(f, "</tr>\n");
	}
	fprintf(f, "</table>");

	// Display average color table for BLUE
	fprintf(f, "<h2>Average Blue Colors</h2>"
		"<table cellpadding=0 cellspacing=0>");
	for (int i = 0; i < cell_count; i++)
	{
		fprintf(f, "<tr>");
		for (int j = 0; j < cell_count; j++)
		{
			COLORREF color = grid[i][j];
			fprintf(f, "  <td bgcolor=\"#0000%02X\" width=15 height=15></td>\n",
				GetBValue(color));
		}
		fprintf(f, "</tr>\n");
	}
	fprintf(f, "</table>");

	// Display Heuristic Table
	fprintf(f, "<h2>Heuristic Table</h2>"
		"<table cellpadding=0 cellspacing=0>");
	for (int y = 0; y < cell_count; y++)
	{
		fprintf(f, "<tr>");
		for (int x = 0; x < cell_count; x++)
		{
			fprintf(f, "<td><table cellpadding=0 cellspacing=0>");
			for (int py = 0; py < box_size; py++)
			{
				fprintf(f, "<tr>");
				for (int px = 0; px < box_size; px++)
				{
					COLORREF color = GetPixelRGB(game_origin.x + (x * 40) + 15 + px,
						(game_origin.y + (y * 40) + 15 + py));
					fprintf(f, "<td bgcolor=\"#%02X%02X%02X\" width=1 height=1></td>",
						GetRValue(color), GetGValue(color), GetBValue(color));
				}
				fprintf(f, "</tr>");
			}
			fprintf(f, "</table></td>");
		}
		fprintf(f, "</tr>");
	}
	fprintf(f, "</table>");
	fclose(f);
}