Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: XE8 and OpenPictureDialog


This question is answered.


Permlink Replies: 6 - Last Post: Jan 22, 2016 1:49 PM Last Post By: Remy Lebeau (Te...
lib z

Posts: 9
Registered: 12/5/99
XE8 and OpenPictureDialog  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2016 8:40 AM
First time doing graphics in XE8.
Dropped an OpenPictureDialog1 on a form in XE8. Copied over code from a D7 program that successfully manipulates a jpg and uses the OpenPictureDialog.
.
First, the filetype filter on the XE8 component lists:
All (*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf)|*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf|Portable Network Graphics (*.png_old)|*.png_old|GIF Image (*.gif)|*.gif|Portable Network Graphics (*.png)|*.png|JPEG Image File (*.jpg)|*.jpg|JPEG Image File (*.jpeg)|*.jpeg|Bitmaps (*.bmp)|*.bmp|TIFF Images (*.tif)|*.tif|TIFF Images (*.tiff)|*.tiff|Icons (*.ico)|*.ico|Enhanced Metafiles (*.emf)|*.emf|Metafiles (*.wmf)|*.wmf

but when run will only shows
All(*.bmp;.tif;.tiff;.ico;.emf;*.wmf)

Second, when I manually change the filter on the component to only *.jpg it gives me an exception
EInvalidGraphic 'Unknown picture file extension (*.jpg)

What has changed since Delphi 7 that I have missed?
Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: XE8 and OpenPictureDialog  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2016 9:03 AM   in response to: lib z in response to: lib z
El 22/1/16 a las 17:40, lib z escribió:
First time doing graphics in XE8.
Dropped an OpenPictureDialog1 on a form in XE8. Copied over code from a D7 program that successfully manipulates a jpg and uses the OpenPictureDialog.
.
First, the filetype filter on the XE8 component lists:
All (*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf)|*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf|Portable Network Graphics (*.png_old)|*.png_old|GIF Image (*.gif)|*.gif|Portable Network Graphics (*.png)|*.png|JPEG Image File (*.jpg)|*.jpg|JPEG Image File (*.jpeg)|*.jpeg|Bitmaps (*.bmp)|*.bmp|TIFF Images (*.tif)|*.tif|TIFF Images (*.tiff)|*.tiff|Icons (*.ico)|*.ico|Enhanced Metafiles (*.emf)|*.emf|Metafiles (*.wmf)|*.wmf

but when run will only shows
All(*.bmp;.tif;.tiff;.ico;.emf;*.wmf)

Second, when I manually change the filter on the component to only *.jpg it gives me an exception
EInvalidGraphic 'Unknown picture file extension (*.jpg)

What has changed since Delphi 7 that I have missed?

You must add to the uses clausule of one of the source files (the .dpr file by example) the units which handle that formats:

uses
    ...
    Jpeg,
    PngImage,
    GifImg,
    ...
lib z

Posts: 9
Registered: 12/5/99
Re: XE8 and OpenPictureDialog  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2016 10:33 AM   in response to: Antonio Estevez in response to: Antonio Estevez
When did this happen? Do you know why? I have been using Delphi since D3 and never before needed this.

Antonio Estevez wrote:
El 22/1/16 a las 17:40, lib z escribió:
First time doing graphics in XE8.
Dropped an OpenPictureDialog1 on a form in XE8. Copied over code from a D7 program that successfully manipulates a jpg and uses the OpenPictureDialog.
.
First, the filetype filter on the XE8 component lists:
All (*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf)|*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf|Portable Network Graphics (*.png_old)|*.png_old|GIF Image (*.gif)|*.gif|Portable Network Graphics (*.png)|*.png|JPEG Image File (*.jpg)|*.jpg|JPEG Image File (*.jpeg)|*.jpeg|Bitmaps (*.bmp)|*.bmp|TIFF Images (*.tif)|*.tif|TIFF Images (*.tiff)|*.tiff|Icons (*.ico)|*.ico|Enhanced Metafiles (*.emf)|*.emf|Metafiles (*.wmf)|*.wmf

but when run will only shows
All(*.bmp;.tif;.tiff;.ico;.emf;*.wmf)

Second, when I manually change the filter on the component to only *.jpg it gives me an exception
EInvalidGraphic 'Unknown picture file extension (*.jpg)

What has changed since Delphi 7 that I have missed?

You must add to the uses clausule of one of the source files (the .dpr file by example) the units which handle that formats:

uses
    ...
    Jpeg,
    PngImage,
    GifImg,
    ...
Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: XE8 and OpenPictureDialog
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2016 11:00 AM   in response to: lib z in response to: lib z
El 22/1/16 a las 19:33, lib z escribió:
When did this happen?

I think it was always so. At least since the jpeg unit exists.

Do you know why?

The initialization section of the unit registers the file extension and the class of each image
format in the graphics system.

This is from the jpeg unit:
initialization
   InitDefaults;
   TPicture.RegisterFileFormat('jpeg', sJPEGImageFile, TJPEGImage);
   TPicture.RegisterFileFormat('jpg', sJPEGImageFile, TJPEGImage);
finalization
   TPicture.UnregisterGraphicClass(TJPEGImage);
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: XE8 and OpenPictureDialog [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2016 12:50 PM   in response to: Antonio Estevez in response to: Antonio Estevez
Antonio wrote:

The initialization section of the unit registers the file extension
and the class of each image format in the graphics system.

Right, and at design-time, it is possible that another loaded package has
linked to those units and registers the image formats, so TOpenPictureDialog
would sees them, but your compiled executable is not linking to those same
units, so they don't get registered at runtime.

--
Remy Lebeau (TeamB)
lib z

Posts: 9
Registered: 12/5/99
Re: XE8 and OpenPictureDialog  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2016 12:45 PM   in response to: lib z in response to: lib z
I did try as you suggested but got an error. I had to reinstall XE8 to get this to work

lib z wrote:
First time doing graphics in XE8.
Dropped an OpenPictureDialog1 on a form in XE8. Copied over code from a D7 program that successfully manipulates a jpg and uses the OpenPictureDialog.
.
First, the filetype filter on the XE8 component lists:
All (*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf)|*.png_old;.gif;.png;.jpg;.jpeg;.bmp;.tif;.tiff;.ico;.emf;.wmf|Portable Network Graphics (*.png_old)|*.png_old|GIF Image (*.gif)|*.gif|Portable Network Graphics (*.png)|*.png|JPEG Image File (*.jpg)|*.jpg|JPEG Image File (*.jpeg)|*.jpeg|Bitmaps (*.bmp)|*.bmp|TIFF Images (*.tif)|*.tif|TIFF Images (*.tiff)|*.tiff|Icons (*.ico)|*.ico|Enhanced Metafiles (*.emf)|*.emf|Metafiles (*.wmf)|*.wmf

but when run will only shows
All(*.bmp;.tif;.tiff;.ico;.emf;*.wmf)

Second, when I manually change the filter on the component to only *.jpg it gives me an exception
EInvalidGraphic 'Unknown picture file extension (*.jpg)

What has changed since Delphi 7 that I have missed?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: XE8 and OpenPictureDialog  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 22, 2016 1:49 PM   in response to: lib z in response to: lib z
lib wrote:

I did try as you suggested but got an error.

What kind of error?

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02