 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
MAC Guest
|
Posted: Sat Apr 07, 2007 2:14 am Post subject: Stretched TImage |
|
|
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
|
Posted: Sat Apr 07, 2007 2:29 am Post subject: Re: Stretched TImage |
|
|
"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
|
Posted: Sat Apr 07, 2007 4:07 am Post subject: Re: Stretched TImage |
|
|
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 |
|
 |
|
|
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
|
|