Subject [IBO] Re: Problems with strech (JPEGImage)
Author Popa Ovidiu Razvan
--- In IBObjects@yahoogroups.com, "Popa Ovidiu Razvan" <ropopa01@...>
wrote:
>
> --- In IBObjects@yahoogroups.com, Helen Borrie <helebor@> wrote:
> >
> > At 07:50 PM 29/10/2007, you wrote:
> > >--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@> wrote:
> > >>
> > >> At 09:24 PM 26/10/2007, you wrote:
> > >> >Hi
> > >> >I am using TIB_JPEGImage for showing some picture.
> > >> >My problem is.
> > >> >I set
> > >> >Stretch = True
> > >> >Center = True
> > >> >AutoSize = False (the real picture is smalleer)
> > >> >
> > >> >the picture dosent strecth like I need
> > >> >she put the original picture in the center and the rest is
> filled
> > >with
> > >> >color White (Component Color).
> > >> >any advice ?
> > >>
> > >> I think you want Autosize = True
> > >>
> > >> This should cause the image to be scaled up to fit into the
> > >TPicture, which seems to be what you really wanted to happen...
> > >>
> > >> Helen
> > >>
> > >
> > >NO I dont wanna do this.
> >
> > Yes, I understand that now.
> >
> > >I want the picture to scale the COMPONENT not vice versa.
> > >If I make component 100x200 I want the image displayed to be
> 100x200.
> >
> > What are you using as a container? Have you tried, for example,
> placing the IB_JPegImage inside an ordinary TPanel, sized to suit,
> and placing the image component in it, with the Align property set
to
> alClient?
> >
> > Helen
> >
>
> I tried.
> Dosent work :(
> R
>

actualy I find the problem but unable to give a right solution :)
I dont know if is a bug or was intendet to work like this.
dont understand the global implication ... maybe some advice ... tks

if Stretch then begin
if (DrawPict.Graphic = nil) or DrawPict.Graphic.Empty then
begin
FillRect(ClientRect);
end else begin
x := DrawPict.width;
y := DrawPict.height;

if x > Clientwidth then begin
y := round(y * (Clientwidth/x));
x := Clientwidth;
end;
if y > Clientheight then begin
x := round(x * (Clientheight/y));
y := Clientheight;
end;
RAspect := ClientRect;
// RAspect.right := x; // roPopa
// RAspect.bottom:= y; // roPopa
// SEE HERE (my opinion is... if is strech dosent need to
keep in mind the x and y computed)
RAspect.right := Clientwidth;
RAspect.bottom:= Clientheight;
if Center then begin
OffsetRect(RAspect, (ClientWidth - x) div 2,
(ClientHeight - y) div 2);
end;

StretchDraw( RAspect , DrawPict.Graphic);
ExcludeClipRect(Handle, RAspect.Left, RAspect.Top,
RAspect.Right, RAspect.Bottom);
FillRect(ClientRect);
SelectClipRgn(Handle, 0);
end
end else begin
SetRect(R, 0, 0, DrawPict.Width, DrawPict.Height);
if Center then OffsetRect(R, (ClientWidth - DrawPict.Width)
div 2,
(ClientHeight - DrawPict.Height) div 2);
StretchDraw(R, DrawPict.Graphic);
ExcludeClipRect(Handle, R.Left, R.Top, R.Right, R.Bottom);
FillRect(ClientRect);
SelectClipRgn(Handle, 0);
end;