converting vb to c#

M

Mike P

I have a piece of code in VB that I want to use to resize images. I
think I have successfully converted most of it to C#, but I am not sure
about this bit :

Function ThumbnailCallback() as Boolean
Return False
End Function


Here is the bit of the code that is calling it :

Response.ContentType = "image/gif"
If imageHeight > 0 and imageWidth > 0 then
Dim dummyCallBack as System.Drawing.Image.GetThumbNailImageAbort
dummyCallBack = New _
System.Drawing.Image.GetThumbnailImageAbort(AddressOf
ThumbnailCallback)

Dim thumbNailImg as System.Drawing.Image
thumbNailImg = fullSizeImg.GetThumbnailImage(imageWidth,
imageHeight, _
dummyCallBack,
IntPtr.Zero)

thumbNailImg.Save(Response.OutputStream, ImageFormat.Gif)


Can anybody help?
 
M

Mike P

Found the answer to this...I had another part of the code converted
wrong and that was what was causing problems with the part that I
couldn't get to work.
 
P

Peter Duniho

Found the answer to this...I had another part of the code converted
wrong and that was what was causing problems with the part that I
couldn't get to work.

Just goes to show how very important a concise-but-complete code example
is when asking a question. There are lots of problem with just posting a
little bit of your code, not the least of which is that the problem may or
may not actually be in that code.

As far as the code you posted goes, unless what you want is specifically a
thumbnail, using GetThumbnailImage() is a very bad way to scale your
image. You've been offered good suggestions elsewhere for addressing
scaling more generally, and you should follow those suggestions unless
it's sufficient for your needs to start with the Windows-generated
thumbnail and possibly scale the already-scaled image to produce a new
scaled image.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top