-
Jul 27th, 2009, 10:43 AM
#1
Thread Starter
Member
[RESOLVED] Images
Hi,
I have some code that allows the user to browse for an image and then when that image is opened, it is copied to a new directory. This all works fine, but I would like to know if there is a way to create a thumbnail of this image and save it into a subdirectory inside the directory where the original image has already been copied?
Also, I can't register my version of visual basic, so any help there might be useful. The link doesn't do anything.
Last edited by michael1; Jul 28th, 2009 at 09:21 AM.
-
Jul 27th, 2009, 11:57 AM
#2
Re: Images
Here is a function that will help you resize an image:
Code:
Private Sub Resize75Percent(ByVal inputFile As String, ByVal outputFile As String)
Dim input As Bitmap = New Bitmap(inputFile)
Dim x As Integer = Convert.ToInt32(input.Width * 0.75)
Dim y As Integer = Convert.ToInt32(input.Height * 0.75)
Dim output As Bitmap = New Bitmap(x, y, Imaging.PixelFormat.Format24bppRgb)
Dim g As System.Drawing.Graphics = Graphics.FromImage(output)
g.DrawImage(input, 0, 0, x, y)
output.Save(outputfile)
g.Dispose()
End Sub
-
Jul 27th, 2009, 12:49 PM
#3
Re: Images
Make sure the account that runs your application has write permission to that thumbnail directory too.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jul 28th, 2009, 05:07 AM
#4
Thread Starter
Member
Re: Images
Hi,
everything works insofar as the code does successfully resize the image, however, When it tries to run the line "output.save(outputfile)" it presents this error, "A Generic error occured in GDI+". Please help, I've got no idea what it even means?
Last edited by michael1; Jul 28th, 2009 at 05:58 AM.
-
Jul 28th, 2009, 08:40 AM
#5
Re: Images
Do you have permission to write to the folder? You are not trying to overwrite the file that you have open as your input file, are you?
-
Jul 28th, 2009, 09:18 AM
#6
Thread Starter
Member
Re: Images
Hi,
thanks, It was just me being stupid. I had provied a directory for outputFile but no file! Thanks for your help.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|