Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing and Saving Images 2

Status
Not open for further replies.

jl280328

Programmer
Jun 15, 2006
97
US
How would I go about resizing an image and then saving it?
 
The easy version:

Code:
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(originalImage, newWidth, newHeight);
bmp.Save("file path");
 
Thank you that's all I need. I'm glad it's so easy
 
So I tried the above code and got the following error:

'Bitmap' is a type in 'Drawing' and cannot be used as an expression.

here is the code I tried:
Code:
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Image, imgWidth, imgHeight)
bmp.Save("1Images/Small/6.jpg")

I am writing this in VB not C would that make a difference?
 
I am writing this in VB not C would that make a difference?
Yes it will - you will have to declare your "bmp" object as you would normally declare an object in VB.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
so I did that now I am getting an error on this line:
Code:
bmp.Save("1Images/Small/6.jpg")

here is what I changed it to to declare it:
Code:
Dim bmp as System.Drawing.Image
bmp = new System.Drawing.Bitmap(Image, imgWidth, imgHeight)

The error I get is:
"A generic error ocurred in GDI+"

I have Page Debug=True also but it still gives this generic error.
 
You'll discover GDI+ is one of the worst designed APIs in history and as such, the error message isn't very informative (it could mean one of about 10,000 things).

Does saving with an absolute path help the problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top