Hi, after a big research I finally found a solution to make sreenshots;p But what is bothering me - when I do some tests it shows up that analizing about 66.000 pixels takes 50-60% of my CPU resources(Intel Core Duo 1.66 GHz). Is there a faster way to do that?
Here is the code:

//---------------------------------------------------------------------------
	#include <vcl.h>
	#pragma hdrstop
	#include "Unit1.h"
	//---------------------------------------------------------------------------
	#pragma package(smart_init)
	#pragma resource "*.dfm"
	#include <windows.h>
	#include <stdio.h>
	#include <winuser.h>
	#include "fstream.h"
	 
	String dir;
	String czas;
	String data;
	int b=0;
	int s=0;
	 	 
	TForm1 *Form1;
	//---------------------------------------------------------------------------
	__fastcall TForm1::TForm1(TComponent* Owner)
	        : TForm(Owner)
	{
	}
	//---------------------------------------------------------------------------
	 
	 
	void __fastcall TForm1::Timer1Timer(TObject *Sender)
	{
	 
	b++;
	if(b>1000) return;
	 
	         TCanvas &PulpitCanvas = *new TCanvas();
	         Graphics::TBitmap *bitmap = new Graphics::TBitmap;
	         COLORREF k[116][114];
	         HWND Wnd=FindWindow(NULL,"WINDOW");
	         if(Wnd==0)
                 {MessageBox(0,"Didnt found the window!",0,0);}
	         PulpitCanvas.Handle = GetDC(Wnd);
	         bitmap->Width = 800;
	         bitmap->Height = 600;
	 
	bitmap->Canvas->CopyRect(Rect(0, 0, bitmap->Width,    bitmap->Height), &PulpitCanvas, Rect(0, 0, bitmap->Width, bitmap->Height));
	 
	for(int i=0; i<116; i++)
	{
	    for(int j=0; j<114; j++)
	    {
	       if(bitmap->Canvas->Pixels[i][j]==RGB(0,0,0));
	       if(bitmap->Canvas->Pixels[i][j]==RGB(0,0,0));
	       if(bitmap->Canvas->Pixels[i][j]==RGB(0,0,0));
	       if(bitmap->Canvas->Pixels[i][j]==RGB(0,0,0));
	       if(bitmap->Canvas->Pixels[i][j]==RGB(0,0,0));
	    }
	}
	 
	ReleaseDC(0, PulpitCanvas.Handle);
	delete &PulpitCanvas;
	delete bitmap;
	   
	 }
	 
	//---------------------------------------------------------------------------

Split into two threads, and give each one half the screen (since you have 2 cores, and only using one of them)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.