Function MakeThumbnail(Image As Picture, iWid As
Integer = WIDTH, iHi As Integer = HEIGHT) As Picture
Dim thumb As Picture
Dim ratio As Double
// Return nil if image is Nil
If image = Nil Then
Return Nil
End If
If iWid = 0 Or Not isNumeric( iWid ) Then
iWid = WIDTH
End If
If iHi = 0 Or Not isNumeric( iHi ) Then
iHi = HEIGHT
End If
// Create Image Thumbnail
If image.Width > image.Height Then
ratio = image.Height / image.Width
thumb = NewPicture( iWid, iHi * ratio, 32)
Else
ratio = image.Width / image.Height
thumb = NewPicture(iWid * ratio, iHi, 32)
End If
// Draw Thumbnail
thumb.Graphics.DrawPicture image, 0, 0, thumb.Width,
thumb.Height, 0, 0, image.Width, image.Height
// Return Thumbnail
return thumb
End Function
Sub Action()
Dim f As Folderitem
Dim dlg As OpenDialog
Dim p As Picture
//create new openDialog
dlg = New OpenDialog
//specify the types of files to look for
// saveStyledEditField stores a file of type "TEXT"
// which is also the same as a plain text file
dlg.Filter ="Image Files (*jpg;*.jnp;*.gif;*.jpeg;)"
//run the openDialog
f = dlg.ShowModal
//check for user cancelling
If f <> Nil Then
folderImage = f
// display in the ImageWell Object
p = f.OpenAsPicture
IWImage.Image = App.MakeThumbnail(p)
newPicture = True
end if
End Sub
--- [EMAIL PROTECTED] wrote:
> On Oct 10, 2006, at 14:57 UTC, Long Huynh wrote:
>
> > I recompile my code in RB r4, I've got an error.
> > It expects an Int32 instead of Picture object.
> >
> > Dim thumb As Picture
> > :
> > :
> > thumb = New Picture( w, h, 32)
> >
> > :
> > :
> >
> > return thumb
>
> Show us the definitions of w and h. Show us a bit
> of the surrounding
> code, too, in case the error isn't actually on the
> New Picture line.
> Finally, try changing the names of thumb, w, and h,
> in case one of
> these is actually defined somewhere else that you're
> just not thinking
> about at the moment.
>
> In short, the code above is correct as shown, so
> something else is
> going on that you haven't yet realized, and you'll
> probably go "doh!"
> when you find it.
>
> HTH,
> - Joe
>
> --
> Joe Strout -- [EMAIL PROTECTED]
> Verified Express, LLC "Making the Internet a
> Better Place"
> http://www.verex.com/
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
>
<http://support.realsoftware.com/listarchives/lists.html>
>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>