Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    resize photo (access 2003)

    I have an image on a form, thank links to a .bmp image.
    The standard size for these images is a 200x274 bmp.

    UPDATE: (have to set the image control to stretch or zoom, NOT clip)
    I found some code on the net, which works.. but,, the image is very grainy, (they are photographs), it comes out like a
    sepia sort of look.

    So the picture looks rubbish.



    The image is set to a file on the drive thus:-

    <font color=red>Me![Image52].Picture = DLookup("[PicturePath]", "[Options]") & Me.ID & ".bmp"</font color=red>

    So i lookup the path etc. according to the member number. so the bitmap is called 0.bmp etc

    this is the call...

    <font color=red>Call fResizeImageFrame(Me.Image52)</font color=red>

    and this is the code in the module.:-

    <font color=red>'This function will resize and center an image frame based on the
    'dimensions of any image.
    Public Function fResizeImageFrame(ctl As Control)
    On Error GoTo Err_fResizeImageFrame



    Dim fraLeft As Integer
    Dim fraTop As Integer
    Dim fraHgt As Integer
    Dim fraWdt As Integer
    Dim picHgt As Integer
    Dim picWdt As Integer
    Dim pct As Double
    Dim fra As Double
    Dim pic As Double

    'get dimensions of the image frame
    fraLeft = ctl.Left
    fraTop = ctl.Top
    fraHgt = ctl.Height
    fraWdt = ctl.Width

    'get dimensions of the image in the frame
    picHgt = ctl.ImageHeight
    picWdt = ctl.ImageWidth

    'get a percent value for the frame and image
    'which is based on the dimensions of each
    fra = fraWdt / fraHgt
    pic = picWdt / picHgt

    'pics dimensions smaller than entire frame
    If fraHgt > picHgt And fraWdt > picWdt Then
    'resize frame to fit pic
    ctl.Height = picHgt
    ctl.Width = picWdt
    'center frame
    ctl.Left = fraLeft + ((fraWdt - picWdt) / 2)
    ctl.Top = fraTop + ((fraHgt - picHgt) / 2)
    'pics dimensions taller than frame dimensions
    ElseIf pic < fra Then
    'determine percentage the pic is being reduced
    pct = fraHgt / picHgt
    'calculate the new pic width
    picWdt = picWdt * pct
    'resize frame to fit pic
    ctl.Width = fraWdt - (fraWdt - picWdt)
    'center frame
    ctl.Left = fraLeft + ((fraWdt - picWdt) / 2)
    'pics dimensions wider than frame dimensions
    ElseIf pic > fra Then
    'determine percentage the pic is being reduced
    pct = fraWdt / picWdt
    'calculate the new pic height
    picHgt = picHgt * pct
    'resize frame to fit pic
    ctl.Height = fraHgt - (fraHgt - picHgt)
    'center frame
    ctl.Top = fraTop + ((fraHgt - picHgt) / 2)
    End If

    Exit_fResizeImageFrame:
    Exit Function
    Err_fResizeImageFrame:
    MsgBox Err.Description, vbCritical, "Error " & Err.Number
    Resume Exit_fResizeImageFrame
    End Function</font color=red>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: resize photo (access 2003)

    The code does not resize the picture, it resizes the image control.

    If the picture is smaller than the image control, the control will be shrunk (both width and height) to the size of the picture.
    If the picture is larger than the image control, the control will be shrunk in one direction to have the same aspect ratio as the picture. This works best if the SizeMode property of the image control is set to Stretch or Zoom.

    If you don't want to resize the image control but the picture (so that it fits in the image control), you don't need any code. Simply set the SizeMode property of the image control to Zoom.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: resize photo (access 2003)

    Ahh thanks hans... but the problem is still that the .BMP image, if its shrunk into a box
    gives an almost sepia look.

    like the thing is missing some layers or something

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: resize photo (access 2003)

    That's probably a problem with the graphic filter used by Access, I don't think there's much you can do about it (except trying to find an image that works better)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •