Re: Image Resize
- From: "Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdot...@xxxxxxxxxxxx>
- Date: Tue, 15 Jan 2008 09:55:20 -0400
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.
.
- References:
- Image Resize
- From: Dominic Vella
- Image Resize
- Prev by Date: Re: Help condensing query data
- Next by Date: Re: navigation pane
- Previous by thread: Re: Image Resize
- Next by thread: Size of box in report dependent of variable content
- Index(es):
Relevant Pages
|