Pictures stored in database

varrey
10-31-2004, 02:08 AM
I have some pictures of random sizes stored in the Access database. I am able to retrieve them from the database and display them in a Image box. I have set the stretch property of the image field on so that the image gets filled in the box. But this leads to distortion of the picture displayed on the screen. But if I can read the height and width of the retrieved picture before I display, I can change the dimensions of the image box to be proportional to the proportions of the picture, within the space constraints, to display the picture without distortion.

How do I get the retrieved picture file height and width? Please help.

Regards
Varrey

Gruff
10-31-2004, 02:23 AM
one way would be to dump it into a picturebox first and then check the picture height and width. Then set your image box size before you transfer the picture from the picturebox.

~T

varrey
10-31-2004, 02:31 AM
one way would be to dump it into a picturebox first and then check the picture height and width. Then set your image box size before you transfer the picture from the picturebox.

~T
Thanks for your suggestion Mr. Gruff. But isn't there a direct way of reading it. Please clarify

Regards

Varrey

Gruff
10-31-2004, 03:09 AM
I don't think there is a direct way to get a picture size from the bag of bytes stored in your Access DB file. (Unless the sizes were also written to accompaning fields)

I looked at the image control and just realized that the loaded picture size in twips is held within the picture property. (Example: Image1.picture.Width) The following snippet shows how one might adjust the size of a picture after it is loaded. (I use loadpicture from disk instead of a DB but the principle would be the same.


Option Explicit

Private Sub command1_Click()
Dim ht As Single
Dim wt As Single

Image1.Stretch = False
Image1.Picture = LoadPicture("C:\Box.bmp")
ht = Image1.Picture.Height 'Size in Twips
wt = Image1.Picture.Width 'Size in Twips

Image1.Stretch = True
Image1.Width = wt / 4
Image1.Height = ht / 4
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum