Re: Image Resize



Dominic I am just heading out the door but I can get you pointed in the
right direction. There is a vbPictureBox class on my site. It is written in
native VBA and contains a resize method.
http://www.lebans.com/imageclass.htm
ImageClass has been replaced by the PictureBoxA97 project. A standard Image
control is wrapped within a class to allow the control to resemble the
standard Visual Basic PictureBox control. Simple drawing methods are
directly supported as is Text output with rotation. A handle to a Device
Context is exposed to allow the developer to use the full range of Graphic
API's. Also supports Screen Grabs, Copy to Clipboard and Save Image control
to a disk Bitmap file. Here is the Access 2000 version, PictureBoxA2K.zip
--

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


"Dominic Vella" <dominic.vella@xxxxxxxxxxxxxxx> wrote in message
news:478c671a$0$13919$afc38c87@xxxxxxxxxxxxxxxxxxxxxxx
Hi, I know I seem to have the really complicated questions, but I guess
that's why I'm here. This is a little verbose, only because I've been
trying to crack this for a week now.

Your help would be appreciated.

I've been trying numerous ways to resize images, as I want to make store
thumbnails, not full images in my database.

-----------------------------------------------------------------------------
Method 1: So I tried the VB way -
that is to use LoadPicture to a picture box, resize the box, then copy to
another box and then 'SavePicture Picture2.Picture,strFilename'

That doesn't work as the controls in Access are somewhat different. So I
tried

----------------------------------------------------------------------------
Method 2: Access Image and OLEBoxes. -
image1.picture = strFilename

That doesn't work because the picture property is only a filename, I've
tried 'SavePicture image1.PictureData', but it won't work.

-------------------------------------------------------------------------------
Method 3: The IPicture Object
Dim imgPicture as Object
Set imgPicture = LoadPicture(filename)

But then I can't resize the image. Once upon a time I think LoadPicture
allowed you to use incoming dimensions stdole.StdFunctions.LoadPicture,
but when I did the SavePicture, the dimensions never changed, and in fact
the file size grew bigger due to loss of compression.

------------------------------------------------------------------------------
All Up: this is what I have so far:
Sub ResizeImageWithAspect(strFilename As String, strOutputFilename As
String, intNewWidth As Integer, intNewHeight As Integer)
On Error GoTo Err_Sub
Dim imgOriginal As Object
Dim ctl As Control ' I can't get image data back if I save image to
control
Dim sglAspect As Single
Dim intTempHeight As Integer

Set imgOriginal = LoadPicture(strFilename)
sglAspect = imgOriginal.Height / imgOriginal.Width
intTempHeight = intNewWidth * sglAspect

If intTempHeight > intNewHeight Then
sglAspect = imgOriginal.Width / imgOriginal.Height
intNewWidth = intNewHeight * sglAspect
Else
intNewHeight = intTempHeight
End If
Set imgOriginal = LoadPicture(strFilename)

''''''''''''''
'Image Resize needed here
''''''''''''''''

SavePicture imgOriginal, strOutputFilename
Exit_Sub:
DoCmd.Close acForm, "frmWebPictureResize"
Set imgOriginal = Nothing
Exit Sub
Err_Sub:
MsgBox Err.Number & ": " & Err.Description
' Resume Exit_Sub
Resume Next
End Sub

-----------------------------------------------------------------------------------
Can anyone tell me how to resize an image in MS-Access? Thanks in
advance.





.



Relevant Pages

  • Image Resize
    ... I've been trying numerous ways to resize images, as I want to make store ... String, intNewWidth As Integer, intNewHeight As Integer) ... Dim imgOriginal As Object ... Dim sglAspect As Single ...
    (comp.databases.ms-access)
  • Re: WMP control resizing
    ... > getting the WMP9 activex control in a window and playing movies etc. ... when you want to resize the control in MFC, ...
    (microsoft.public.windowsmedia.sdk)
  • Re: SDI/CFormView/TabCtrl resize problem.
    ... // Get the Tab Control and resize it accordingly. ... Only thing I don't like is that I'm resizing both the TabCtrl and the pages ...
    (microsoft.public.vc.mfc)
  • Re: Outlook Custom form - resize event handling
    ... Is Inspector represents the message window itself? ... hook on the form and will resize... ... I used standard Message template and added custom control on ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: Setwindowpos()-problem.Moving control is not happening.
    ... For this i need to resize and reposition the ... I am calling GetWindowRect to get the control ... >dimensions and after changing them i am trying to call SetWindowPos() ... if onlyresize means the window is ...
    (microsoft.public.vc.mfc)