Cringel
Cringel
CC#
Created by Cringel on 10/24/2023 in #help
❔ Trying to return
using System;
using System.Drawing;
using System.Windows.Forms;
using AForge.Imaging;
using AForge.Imaging.Filters;
using Image = System.Drawing.Image;

namespace Program_ui_test
{
public partial class Form1 : Form
{

private Bitmap savedImage;

public Form1()
{
InitializeComponent();

// Load the saved image you want to match
savedImage = (Bitmap)Image.FromFile("C:\\Users\\kingk\\RiderProjects\\Program ui test\\Program ui test\\Icon.png");
}

public FindMatchingImage()
{
// Capture the screen
Bitmap screenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(screenshot);
g.CopyFromScreen(0, 0, 0, 0, screenshot.Size);

// Apply grayscale filter to both images
Grayscale grayscaleFilter = new Grayscale(0.2125, 0.7154, 0.0721);
Bitmap processedSavedImage = grayscaleFilter.Apply(savedImage);
Bitmap processedScreenshot = grayscaleFilter.Apply(screenshot);

// Find the difference between the images
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0.8f);
TemplateMatch[] matches = tm.ProcessImage(processedScreenshot, processedSavedImage);

if (matches.Length > 0)
{
// Get the center coordinates of the matched region
Rectangle matchRect = matches[0].Rectangle;
int centerX = matchRect.X + matchRect.Width / 2;
int centerY = matchRect.Y + matchRect.Height / 2;

// Display the center coordinates
// MessageBox.Show($"Match found at ({centerX}, {centerY})");
Console.WriteLine($"Match found at ({centerX}, {centerY})");
return (centerX, centerY);
}
using System;
using System.Drawing;
using System.Windows.Forms;
using AForge.Imaging;
using AForge.Imaging.Filters;
using Image = System.Drawing.Image;

namespace Program_ui_test
{
public partial class Form1 : Form
{

private Bitmap savedImage;

public Form1()
{
InitializeComponent();

// Load the saved image you want to match
savedImage = (Bitmap)Image.FromFile("C:\\Users\\kingk\\RiderProjects\\Program ui test\\Program ui test\\Icon.png");
}

public FindMatchingImage()
{
// Capture the screen
Bitmap screenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(screenshot);
g.CopyFromScreen(0, 0, 0, 0, screenshot.Size);

// Apply grayscale filter to both images
Grayscale grayscaleFilter = new Grayscale(0.2125, 0.7154, 0.0721);
Bitmap processedSavedImage = grayscaleFilter.Apply(savedImage);
Bitmap processedScreenshot = grayscaleFilter.Apply(screenshot);

// Find the difference between the images
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0.8f);
TemplateMatch[] matches = tm.ProcessImage(processedScreenshot, processedSavedImage);

if (matches.Length > 0)
{
// Get the center coordinates of the matched region
Rectangle matchRect = matches[0].Rectangle;
int centerX = matchRect.X + matchRect.Width / 2;
int centerY = matchRect.Y + matchRect.Height / 2;

// Display the center coordinates
// MessageBox.Show($"Match found at ({centerX}, {centerY})");
Console.WriteLine($"Match found at ({centerX}, {centerY})");
return (centerX, centerY);
}
66 replies
CC#
Created by Cringel on 10/24/2023 in #help
❔ Some image detecting thing
No description
112 replies
CC#
Created by Cringel on 6/24/2023 in #help
❔ Just beginning the stuff
I found that c# is what I need basically, because I can do a lot of funny stuff with it. I need to know how do I start with it. I want to make some stuff like Soundpad and maybe some others I dont know the idea of. Youtube is poor of good guides, maybe I need help from someone with it.. First of all, I have an experience of lego hacking roblox scripts (luau) and I'm very good at it how I think, but I was really bad at learning how to make scripts. I did it as a hobby. I don't have any idea on how to make multiple languages apps but I know its possible but I dont know how to make it. Basically the question is, how do I make some app in Visual Studio Code and first of all how do I start a project in it? Later I also want to modify it with lua but I dont know how and how its possible to do it.
12 replies