Board index » cppbuilder » TOpenPictureDialog refuse to show JPEG files

TOpenPictureDialog refuse to show JPEG files


2008-03-15 11:32:52 AM
cppbuilder48
I'm using BC++ 6, tried to open some pictures for processing. I used a
TOpenPictureDialog to select the picture, however, the dialog refuses to
display any JPEG files. I used the Dialog "as is", I didn't changed any
setting in it(except, I changed the Dialog Title). I have checked over and
over again the Filter did contain .JPG and .JPEG in both its own filter and
the ALL Picture Format filter. At design time, if I right click on the
Dialog and select "Test Dialog", the filter does contail JPEG files and I
could choose the JPEG files without problem. However, if I compiled the code
and test the dialog in run time, the JPEG filters disappeared *magically*
all togather. I can't select any JPEG files since the dialog just won't
display the files, it only displays .BMP, .WMF, .EMF and .ICO files, all
other extensions are ignored.
So, what is the reason for such behavior, and how do I overcome it?
T.I.A.
 
 

Re:TOpenPictureDialog refuse to show JPEG files

"choykw" < XXXX@XXXXX.COM >撰寫於郵件新聞: XXXX@XXXXX.COM ...
Quote
I'm using BC++ 6, tried to open some pictures for processing. I used a
TOpenPictureDialog to select the picture, however, the dialog refuses to
display any JPEG files. I used the Dialog "as is", I didn't changed any
setting in it(except, I changed the Dialog Title). I have checked over and
over again the Filter did contain .JPG and .JPEG in both its own filter
and the ALL Picture Format filter. At design time, if I right click on the
Dialog and select "Test Dialog", the filter does contail JPEG files and I
could choose the JPEG files without problem. However, if I compiled the
code and test the dialog in run time, the JPEG filters disappeared
*magically* all togather. I can't select any JPEG files since the dialog
just won't display the files, it only displays .BMP, .WMF, .EMF and .ICO
files, all other extensions are ignored.

So, what is the reason for such behavior, and how do I overcome it?

T.I.A.

Okay, I found the solution, by adding a "ALL(*.*)" filter to the dialog, I
some how forced the dialog to refresh it's setting and showed the JPEG
files. Sheesh....
 

Re:TOpenPictureDialog refuse to show JPEG files

Quote
Okay, I found the solution, by adding a "ALL(*.*)" filter to the dialog, I
some how forced the dialog to refresh it's setting and showed the JPEG
files. Sheesh....
Yes, you can force the dialog to show JPEG files by adding ALL(*.*) filter
, but if you write a code something like this:
if(OpenPictureDialog1->Execute())
{
Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
}
and select a .jpg file you will get the error message:
Unknown picture file extension (*.jpg).
Just add
#include <jpeg.hpp>
Then, the dialog will show jpeg files automatically, and you won't get
a message in "LoadFromFile".
 

{smallsort}

Re:TOpenPictureDialog refuse to show JPEG files

"choykw" < XXXX@XXXXX.COM >wrote in message
Quote
So, what is the reason for such behavior, and how do I overcome it?
TOpenPictureDialog uses the features of TPicture to determine which file
types your application supports. TPicture maintains a list of registered
TGraphic class descendants. At design-time every package has been loaded by
the IDE therefore every graphic class is supported by TOpenPictureDialog.
When you run an application only the graphic classes that have been
registered by your application will be supported. Sometimes you just need
to include the correct header files to cause the registration to take place
for your application, like "UO" suggested with <Jpeg.hpp>. However,
sometimes you need to add a "#pragma link" of the unit that contains the
package registration code. It depends on how the unit was designed.
Clayton
 

Re:TOpenPictureDialog refuse to show JPEG files

"UO" <uo@uott>撰寫於郵件新聞:47dc1db4$ XXXX@XXXXX.COM ...
Quote
>Okay, I found the solution, by adding a "ALL(*.*)" filter to the dialog,
>I some how forced the dialog to refresh it's setting and showed the JPEG
>files. Sheesh....

Yes, you can force the dialog to show JPEG files by adding ALL(*.*) filter
, but if you write a code something like this:

if(OpenPictureDialog1->Execute())
{
Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
}
and select a .jpg file you will get the error message:
Unknown picture file extension (*.jpg).

Just add
#include <jpeg.hpp>

Then, the dialog will show jpeg files automatically, and you won't get
a message in "LoadFromFile".

Thanks for the reply but no, I'm not forcing the dialog to show JPEG files
with the ALL(*.*) filter, but rather, the inclusion of a new filter (it
could be any fileter, like *.dat) has caused the dialog to CORRECTLY
displaying JPEG fils in the *.jpg and the All Picture Format filters (i.e.,
I didn't even need to select the *.* filter to select a JPEG file).
I have a lot of trouble trying to get the TDBImage component to load JPEG
files even with inclusion of the jpeg.hpp header, none of the solution in
Code Gear is designed for C++ Builder 6, none of the Delphi projects are
loadable in C++B6, so I just forget all the {*word*99} about JPEG files and wrote
a utility to convert all the JPEG files to BMP file.
 

Re:TOpenPictureDialog refuse to show JPEG files

Hi choykw
choykw says:
Quote
I have a lot of trouble trying to get the TDBImage component to load JPEG
files even with inclusion of the jpeg.hpp header, none of the solution in
Code Gear is designed for C++ Builder 6, none of the Delphi projects are
loadable in C++B6, so I just forget all the {*word*99} about JPEG files and wrote
a utility to convert all the JPEG files to BMP file.
Couldn't You just handle the jpg files as data streams and
save them as such in the DB, then when You need to show them
You could use TJPEGImage::LoadFromStream.
Just an idea.
Kind regards
Asger
 

Re:TOpenPictureDialog refuse to show JPEG files

"choykw" < XXXX@XXXXX.COM >wrote in message
Quote
I'm using BC++ 6, tried to open some pictures for processing.
I used a TOpenPictureDialog to select the picture, however,
the dialog refuses to display any JPEG files.
The VCL's JPEG support is not enabled by default. You need to include
jpeg.hpp in your code.
Quote
if I compiled the code and test the dialog in run time, the JPEG filters
disappeared *magically* all togather.
Because the JPEG support code is not being compiled into the exeutable so it
they can be activated at runtime.
Quote
I can't select any JPEG files since the dialog just won't display the
files,
it only displays .BMP, .WMF, .EMF and .ICO files
Those are the only formats that are natively implemented in the VCL. JPEG
is implemented separately and has to be specified manually in your code.
Gambit
 

Re:TOpenPictureDialog refuse to show JPEG files

"choykw" < XXXX@XXXXX.COM >wrote in message
Quote
I have a lot of trouble trying to get the TDBImage component
to load JPEG files even with inclusion of the jpeg.hpp header
TDBImage only supports BMP images. That is a hard-coded limitation.
Gambit
 

Re:TOpenPictureDialog refuse to show JPEG files

"Asger Joergensen" < XXXX@XXXXX.COM >wrote in message
Quote
Couldn't You just handle the jpg files as data streams and
save them as such in the DB, then when You need to show
them You could use TJPEGImage::LoadFromStream.
That is the way he is going to have to go. He will also have to use TImage
instead of TDBImage. This has been discussed in detail many times before.
Go to www.deja.com to search the newsgroup archives.
Gambit
 

Re:TOpenPictureDialog refuse to show JPEG files

"Asger Joergensen" < XXXX@XXXXX.COM >撰寫於郵件新聞: XXXX@XXXXX.COM ...
Quote

Hi choykw

choykw says:
>I have a lot of trouble trying to get the TDBImage component to load JPEG
>files even with inclusion of the jpeg.hpp header, none of the solution in
>Code Gear is designed for C++ Builder 6, none of the Delphi projects are
>loadable in C++B6, so I just forget all the {*word*99} about JPEG files and
>wrote
>a utility to convert all the JPEG files to BMP file.

Couldn't You just handle the jpg files as data streams and
save them as such in the DB, then when You need to show them
You could use TJPEGImage::LoadFromStream.

I know, but it's too time consuming (considering the debugging that might
involve) compared to load a picture with TJPEGImage, assign the loaded
graphics to a TBitmap and save them as a Bitmap file. I got my problem
solved in less than 5 minutes and can go on processing the graphics as
planned (It doesn't matter the processed output is save in BMP or JPG file,
for my case, since I'm saving them as a TBlobField in my database, the
graphics files are discardable after the process).
Thanks for the suggestion anyway.
Quote
Just an idea.

Kind regards
Asger
 

Re:TOpenPictureDialog refuse to show JPEG files

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >撰寫於郵件新聞:47dea2ee$ XXXX@XXXXX.COM ...
Quote

"Asger Joergensen" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Couldn't You just handle the jpg files as data streams and
>save them as such in the DB, then when You need to show
>them You could use TJPEGImage::LoadFromStream.

That is the way he is going to have to go. He will also have to use
TImage instead of TDBImage. This has been discussed in detail many times
before. Go to www.deja.com to search the newsgroup archives.
well true only if I _must_ process the graphics in JPEG form, but for now,
simply converting them to BMP is good enough for me.
By the way, anybody know how to used those so called solutions in Code Gear
(for example case
17989:jpg_wmf_emf_ico_bmp_graphicsupport_for_tdbimage_and_tqrdbi.ZIP)? Those
projects are all written in Delphi, though I know they all boiled down to
VCL components in the end, but looks like projects for Delphi 6 and above
will not load properly in BC++B 6 Enterprise.
Quote
Gambit