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 

Stretched TImage

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





PostPosted: Sat Apr 07, 2007 2:14 am    Post subject: Stretched TImage Reply with quote



Hi All,

I have a TImage that is being stretched to fit a window, I want to select
certain pixels in the image how do I go about doing this. What I want to
know is how do I get the coordinates where I clicked to match that of the
stretched TImage.

Regards
MAC
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Apr 07, 2007 2:29 am    Post subject: Re: Stretched TImage Reply with quote



"MAC" <none (AT) none (DOT) com> wrote in message
news:4616b831 (AT) newsgroups (DOT) borland.com...

Quote:
I have a TImage that is being stretched to fit a window, I want
to select certain pixels in the image how do I go about doing this.
What I want to know is how do I get the coordinates where I
clicked to match that of the stretched TImage.

You have access to the Width/Height of the TImage and the Width/Height
of the original graphic. The mouse coordinates are within the
TImage's stretched area, so a simple algebraic calculation can convert
the TImage coordinates into TGraphic coordinates. For example:

void __fastcall TForm1::Image1MouseDown(TObject* Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
int PixelX = ((Image1->Picture->Width * X) / Image1->Width);
int PixelY = ((Image1->Picture->Height * Y) / Image1->Height);
// access the Pixel at PixelX,PixelY as needed...
}

Alternatively:

void __fastcall TForm1::Image1MouseDown(TObject* Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
int PixelX = ((Image1->Width / Image1->Picture->Width) * X);
int PixelY = ((Image1->Height / Image1->Picture->Height) * Y);
// access the Pixel at PixelX,PixelY as needed...
}


Gambit
Back to top
MAC
Guest





PostPosted: Sat Apr 07, 2007 4:07 am    Post subject: Re: Stretched TImage Reply with quote



Thanks

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:4616bbb2$1 (AT) newsgroups (DOT) borland.com...
Quote:

"MAC" <none (AT) none (DOT) com> wrote in message
news:4616b831 (AT) newsgroups (DOT) borland.com...

I have a TImage that is being stretched to fit a window, I want
to select certain pixels in the image how do I go about doing this.
What I want to know is how do I get the coordinates where I
clicked to match that of the stretched TImage.

You have access to the Width/Height of the TImage and the Width/Height
of the original graphic. The mouse coordinates are within the
TImage's stretched area, so a simple algebraic calculation can convert
the TImage coordinates into TGraphic coordinates. For example:

void __fastcall TForm1::Image1MouseDown(TObject* Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
int PixelX = ((Image1->Picture->Width * X) / Image1->Width);
int PixelY = ((Image1->Picture->Height * Y) / Image1->Height);
// access the Pixel at PixelX,PixelY as needed...
}

Alternatively:

void __fastcall TForm1::Image1MouseDown(TObject* Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
int PixelX = ((Image1->Width / Image1->Picture->Width) * X);
int PixelY = ((Image1->Height / Image1->Picture->Height) * Y);
// access the Pixel at PixelX,PixelY as needed...
}


Gambit

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.