Board index » delphi » OpenPictureDialog

OpenPictureDialog

I am having a problem using the OpenPictureDialog component.  It works great
on bmp's and ico's but when i select a jpg I get this msg.

Thanks lk

Project1.exe raised exception class Elvalidgraphic with Message 'Unknown
picture file extension .jpg'

Here is the code i am using:
procedure TForm1.Button1Click(Sender: TObject);
var fname:string;
begin
if OpenPictureDialog1.execute then
begin
edit1.text:=OpenPictureDialog1.filename;
end

end;

 

Re:OpenPictureDialog


I am having a problem using the OpenPictureDialog component.  It works great
on bmp's and ico's but when i select a jpg I get this msg.

Thanks lk

Project1.exe raised exception class Elvalidgraphic with Message 'Unknown
picture file extension .jpg'

Here is the code i am using:
procedure TForm1.Button1Click(Sender: TObject);
var fname:string;
begin
if OpenPictureDialog1.execute then
begin
edit1.text:=OpenPictureDialog1.filename;
end

end;

Re:OpenPictureDialog


I am trying to use the Delphi 4 OpenPictureDialog component.  It works great
on bmp's and ico's but when selecting a jpg i get the following error msg.

Project1.exe raised exception class Elvalidgraphic with message 'Unknown
picture extension jpg.

the code i am using is :
procedure TForm1.Button1Click(Sender: TObject);
var fname:string;
begin
if OpenPictureDialog1.execute then
begin
edit1.text:=OpenPictureDialog1.filename;
end

end;

Is this a bug ?  Any help greatly appreciated ..

Thanks
lk

Re:OpenPictureDialog


Add jpeg to the Unit's uses clause:

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtDlgs, jpeg;

Quote
Larry Keatts wrote:
> I am having a problem using the OpenPictureDialog component.  It works great
> on bmp's and ico's but when i select a jpg I get this msg.

> Thanks lk

> Project1.exe raised exception class Elvalidgraphic with Message 'Unknown
> picture file extension .jpg'

> Here is the code i am using:
> procedure TForm1.Button1Click(Sender: TObject);
> var fname:string;
> begin
> if OpenPictureDialog1.execute then
> begin
> edit1.text:=OpenPictureDialog1.filename;
> end

> end;

--
Harmans

Omaha NE

Re:OpenPictureDialog


On Mon, 8 Feb 1999 09:40:40 -0600, "Larry Keatts"

Quote
<l...@heritage-bag.com> wrote:
>I am having a problem using the OpenPictureDialog component.  It works great
>on bmp's and ico's but when i select a jpg I get this msg.

Add JPEG to your uses clause.

---
Yorai Aminov (TeamB)
http://ourworld.compuserve.com/homepages/yaminov
(TeamB cannot answer questions received via email.
To contact me for any other reason remove nospam from my address)

Re:OpenPictureDialog


Answer below is correct. But, here is the EXPLAINATION as to the WHYS of the
matter. There are various methods that you will use like, LoadFromFile and such.
Well, these cooool methods are cool only because they can be setup to use ANY
format as long as you have a decoder for a particular graphics type. These
decoders REGISTER themselves when your program starts. The REGISTER code is in
the respective unit. For example the registration code for JPG and JPEG are in
the jpeg unit. And if you don't specify it, then when you run your program you
will get those errors :) Keep that in mind if you wish to ADD graphic formats
yourself like gif or tga or png etc... You need to make the code REGISTER itself
as a valid graphic format so that the openpicturedialog will work and the
loadfromfile etc...

Davie
P.S. Maybe this was too much info, but sometimes it's nice to know the why
instead of just an answer.

Quote
"Yorai Aminov (TeamB)" wrote:
> On Mon, 8 Feb 1999 09:40:40 -0600, "Larry Keatts"
> <l...@heritage-bag.com> wrote:

> >I am having a problem using the OpenPictureDialog component.  It works great
> >on bmp's and ico's but when i select a jpg I get this msg.

> Add JPEG to your uses clause.

> ---
> Yorai Aminov (TeamB)
> http://ourworld.compuserve.com/homepages/yaminov
> (TeamB cannot answer questions received via email.
> To contact me for any other reason remove nospam from my address)

Other Threads