Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

·TImage size.. what happens ???

Posted on 1999-07-21
10
Medium Priority
?
166 Views
Last Modified: 2010-04-04
I have this FORM:
(FeJpeg is a component like TImage, only that it supports Jpeg)

unit ViewForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, TJpgImg, ComCtrls, StdCtrls, Buttons;

type
  TView = class(TForm)
    Panel2: TPanel;
    FEJpeg1: TFEJpeg;
    Panel1: TPanel;
    procedure FEJpeg1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  View: TView;

implementation

{$R *.DFM}

procedure TView.FEJpeg1Click(Sender: TObject);
begin
View.Hide;
FEJpeg1.Picture.Bitmap.FreeImage;
FEJpeg1.Align:= alNone;
end;

procedure TView.FormShow(Sender: TObject);
begin
 width:= FEJpeg1.Width;
 height:= FEJpeg1.height;
 FEJpeg1.Align:= alClient;
end;

procedure TView.FormCreate(Sender: TObject);
begin
 FEJpeg1.Align:= alClient;
end;

end.



-------

I call it like this from another form:

with View do
 begin
 FeJpeg1.Picture.LoadFromFile(c:\Image1.jpg');
 FEJpeg1.Hint:=''; position:= poScreenCenter;
 Show;
 end;

----

ok, this is the prob: when I call it for the FIRST time, the SIZE is not correct.. then after this, whenever I call it again, the window *autosizes* itself depending on the image size.. but it doesn't on the FIRST time I call it..

why ?
0
Comment
Question by:bryan7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 1390240
What's wrong with using TJPEGImage?

uses JPEG

var j: TJPEGImage;

j := TJPEGImage.Create;
j.LoadFromFile('....');


or

Image1.Picture.LoadFromFile('image.jpg');
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 40 total points
ID: 1390241
try this:

uses JPEG;

var j: TJPEGImage;
begin
  j := TJPEGImage.Create;
  j.LoadFromFile('c:\my documents\pictures\spidersm.jpg');
  Image1.Picture.Assign(j);
  j.Free;
end;

0
 
LVL 3

Author Comment

by:bryan7
ID: 1390242
>>What's wrong with using TJPEGImage?

it's more easy having the FeJpeg component.. it's just like a TImage..

--

would your code work ?
I would have to change too many things in my program to use the code u posted..
the FeJpeg is like a TImage... so I would a solution that would work on that..
withouth the

var j: TJPEGImage;
      begin
        j := TJPEGImage.Create;
        j.LoadFromFile('c:\my documents\pictures\spidersm.jpg');
        Image1.Picture.Assign(j);
        j.Free;

..
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:Epsylon
ID: 1390243
My code works, I verified that.


If that component has a AutoSize property then use

AutoSize := true

instead of

width:= FEJpeg1.Width;
height:= FEJpeg1.height;
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1390244
Oops, just set the AutoSize property of the form to true  :o)
0
 
LVL 3

Author Comment

by:bryan7
ID: 1390245
>> If that component has a AutoSize property then use
>> AutoSize := true
>>  instead of
>> width:= FEJpeg1.Width;
>> height:= FEJpeg1.height;

it's set to true..
and width:= ... etc is for the FORM

>>Oops, just set the AutoSize property of the form to true  :o)

???¿?¿¿??? forms don't have that property.. at least in my Delphi3 ..
0
 
LVL 3

Author Comment

by:bryan7
ID: 1390246
my code actually works.. but not the FIRST time I call View.Show..

it's weird.. it works ok for the 2nd time..3rd.. and so on.. but not the FIRST time..
0
 
LVL 3

Author Comment

by:bryan7
ID: 1390247
.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1390248
Sorry, it was kinda late yesterday and I completely forgot about this question.
I think you should use somthing like this:

  FeJpeg1.AutoSize := true;
  FeJpeg1.Align := alClient;
  FeJpeg1.Picture.LoadFromFile('image.jpg');
  ClientWidth := FeJpeg1.Picture.Width;
  ClientHeight := FeJpeg1.Picture.Height;


Cheers,

Epsylon.
0
 
LVL 3

Author Comment

by:bryan7
ID: 1390249
hi.. it worked now using this:

procedure TView.FormCreate(Sender: TObject);
begin
 Clientwidth:= FEJpeg1.Width;
 Clientheight:= FEJpeg1.height;
end;

thnx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question