Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

Variable image sizes (jpg, gif and bmp) in a Crystal Report

Using VB 6 and Crystal Reports 8.5, I'm trying to produce a report that includes photos relating to the file summary I am generating.  Each report can have any number of photos included, and the images can be either BMP, JPG or GIFs.  The filepath and filename for each photo is pulled from the database at runtime.

By creating the report with a dummy photo and then using LoadPicture to replace it with the correct photo, I've had no problems loading each image.  My problem is that each photo is compressed or expanded to fit the dimensions of the initial dummy photo.  I need to be able to resize each photo to its original dimensions.  I know how to handle the resizing, but can't figure out how to determine the images' real dimensions at runtime.  I've seen one function to determine bitmap dimensions using header information, but need something to handle JPG and GIF files as well.

Any suggestions?

Code so far (in the Report Designer):

Private Sub Photos_Format(ByVal pFormattingInfo As Object)
    Dim iPhotoWidth As Integer
    Dim iPhotoHeight As Integer
    ' sPhotoPath is a variable for the filepath that is set when initializing the report.  
    ' PhotoFileName is a suppressed field containing the filename of the photo (e.g. 137.jpg)
    Set Photo.FormattedPicture = LoadPicture(sPhotoPath & PhotoFileName.Value)

' Determine photo dimensions
    iPhotoWidth = ???                  ' need function
    iPhotoHeight = ???                 ' need function
' Resize photo
    Photo.Width = iPhotoWidth
    Photo.Height = iPhotoHeight
End Sub
  • 2
1 Solution
"Get Information about Image Files"
JGrahamAuthor Commented:
Thanks very much.  That's exactly what I needed.
Glad I could help  :-)

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now