CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Jan 2010
    Posts
    6

    Analyzing 70.000 pixels color as fast as is possible.

    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:

    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;
    	   
    	 }
    	 
    	//---------------------------------------------------------------------------
    Last edited by Marc G; January 28th, 2010 at 09:34 AM. Reason: fixed code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured