BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Read Pixel Color from control

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
Andrea
Guest





PostPosted: Sat Jan 24, 2004 11:59 am    Post subject: Read Pixel Color from control Reply with quote



Hi, all.

I' try-ing to read some pixel color in a visible control.

I try it with a canvas, but it return always -1.

canv-Pixels[0][0];

I see the x,y coordinate are on ClipRect ( 0,0 - 243,149) so I don't
understand why the code return -1.

Any hints?

Many thanks,

Andrea Peri.

Back to top
Damon Chandler (TeamB)
Guest





PostPosted: Fri Jan 30, 2004 8:08 am    Post subject: Re: Read Pixel Color from control Reply with quote



Hi Andrea,
When you call the Pixels property on a TCanvas object for a particular
window, you need to make sure that the point in the window is visible
and not covered by another window or a child windowed control. For
example, calling Form1->Canvas->Pixels[x][y] will return -1 if some
other window or windowed control (e.g., a TPanel) occupies the point
(x,y) on Form1. You can get around this limitation by using a Canvas
associated with the screen...

#include <memory>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
std::auto_ptr<TCanvas> ScreenCanvas(new TCanvas());
ScreenCanvas->Handle = GetDC(NULL);
try
{
TPoint const P = ClientOrigin;
ShowMessage(ScreenCanvas->Pixels[P.x][P.y]);
}
__finally
{
ReleaseDC(NULL, ScreenCanvas->Handle);
ScreenCanvas->Handle = NULL;
}
}

HTH,
Damon (TeamB)


Andrea wrote:
Quote:
I' try-ing to read some pixel color in a visible control.

I try it with a canvas, but it return always -1.

canv-Pixels[0][0];

I see the x,y coordinate are on ClipRect ( 0,0 - 243,149) so I don't
understand why the code return -1.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.