Displaying JPEGs in an Image Control

D

Dave Monks

Stored in a field in a SQL database I have the raw JPEG data for numerous
photograhs.
I've used the code found LoadSaveJPG from Stephen Lebans website
(www.lebans.com) that takes the raw JPEG converts it to a DIB and then
displays it in an Access image control.
This works really well until I change the Image control from Clip to Zoom.
When showing different sized JPEGs anything other than 320x240 (which the
image control is sized for) they look absolutely dreadful.
If I just write the JPEG data out to a file and then set the picture
property of the image control to the file they look fine. However, I don't
want to have to write files all over a user's hard disk, plus I want it to
work on a bog standard PC without full Office installed.
I've tried combining the LoadSaveJPG code with the LoadJPGGIF code but made
a right mess of things and could not suss it.

Anyone any idea what I could do? (esp. Stpehen as you seem to be the expert
in this sort of thing.)

Dave Monks
 
L

Larry Linson

Take a look at the Imaging examples at http://accdevel.tripod.com. They
don't convert the image before displaying it, and work OK if you are not
displaying a large number of images in a Report. If you are doing it in a
Report, then Stephen's method may be necessary, if you have many images.

Larry Linson
Microsoft Access MVP
 
D

Dave Monks

Thanks for that Larry, it's certainly given me another method to try.
The only possible problem I can see with it is that I think each PC will
need to have the office filter files installed for this method to work. One
of the advantages of Stephen's code is that they don't need these files.
However, having said that, I just want the photos to look good and most PCs
would have Office installed anyway.
I didn't know about the GetTempFileName API before only the GetTempPath, so
that may give me another thing to try and use.

Regards,

Dave Monks
 
D

Dave Monks

Thanks for that Larry, it's certainly given me another method to try.
The only possible problem I can see with it is that I think each PC will
need to have the office filter files installed for this method to work. One
of the advantages of Stephen's code is that they don't need these files.
However, having said that, I just want the photos to look good and most PCs
would have Office installed anyway.
I didn't know about the GetTempFileName API before only the GetTempPath, so
that may give me another thing to try and use.

Regards,

Dave Monks
 
S

Stephen Lebans

David I am finishing my last week of vacation and have promised myself
no programming. Id be glad to help you out with your issue next week
though. Any time after Tuesday.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
D

Dave Monks

Stephen,

Thanks for your response and the offer of help. You must be very
iron-willed to resist the programming urge ;-)

I think the issue I'm having is something that you've already experienced.
Reading through your web site in particular the LoadJPGGIF code and the
Imaging FAQ you do make mention of the fact that the Access Image control is
not very good at resizing DIBs. As the code for LoadSaveJPG converts into a
DIB and then sticks it in the image control, I guess this is what is going
on.

What I am currently going to try is rather than use the IJL to convert it
into a DIB, I'm going to use a stream to write a temp file and then try the
code in LoadJPGGIF to then load it in. My question for this approach would
be does this code require the Office filters or not? Apologies if this
question has been answered in your example code, but I can't get it clear in
my head whether it does or doesn't. If it doesn't require the Office
filters then this approach may be the one I end up using. I'm going to set
up some test PCs with different OS/Office/ART installs and see, although
this may take some time.

I'll post back in this newsgroup how I get on.

Regards,

Dave Monks
 
S

Stephen Lebans

Hi David,
apologies for the late reply but the weather up here was so nice this
week that my vacation got slightly extended.

Just to help me understand the issue, you have an image of a Jpeg disk
file stored in your SQL table. You simply want to display this image on
a form.

If you write the JPG to a temp file and then use my code to load it into
the Image control then no Office graphics filters are required. Temp
files are created all of the time by existing apps on your computer. As
long as you carefully create and destroy them it is an acceptable
solution as long as the inherint delay is acceptable in the performance
of your app.

Another possible solution to your issue would be to simply resize the
incoming JPG to exactly fit the Image control. Then you could leave the
Image control's SizeMode prop set to CLIP. It would only require a minor
modification to my existing code. This way you would eliminate the use
of a temp file on your user's hard drive.

As this subject comes up from time to time I would not mind helping you
create a sample MDB, that I could post on my Web site. If you are
interested let me know.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
D

Dave Monks

Stephen,

Thanks for the reply.

Since the Office filters are not required for the temp file method, I'm
going to give that method a try.

I'd be happy to try and help you create a sample mdb. Let me know what you
would like me to do, bearing in mind I don't have any idea at the moment how
to do the resize! Just remove the obvious from the email address if you
want to drop me a line.

Dave
 
D

Dave Monks

Just to finish off the thread.

I've tried using the temp file method and it does work.
So all I do is write the photo to a temp file using an ADO stream, then use
Stephen's code to read it back in and stick it in the image control. This
does then resize properly, unlike the other method that does it all in
memory.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top