Help Please

Discussion in 'ASP .Net Web Controls' started by eamon, Aug 4, 2005.

  1. eamon

    eamon Guest

    Can anyone convert this code into VB for me please my project isn't compling
    the one below because im using VB.

    "Steve C. Orr [MVP, MCSD]" wrote:

    > You can resize the image using the GetThumbnailImage method.
    > Here's more info:
    > http://msdn.microsoft.com/library/d...emDrawingImageClassGetThumbnailImageTopic.asp
    >
    > Or maybe you'll find these custom functions I wrote to be useful:
    >
    > public Image DisplaySize(Bitmap bmp)
    > {
    > Response.Write(bmp.Width.ToString());
    > Response.Write(bmp.Height.ToString());
    > }
    >
    > //shrink the image proportionately so that neither height nor width is
    > //more than [NewSize] pixels
    >
    > public System.Drawing.Image ShrinkImage(System.Drawing.Bitmap bmp, int
    > NewSize)
    >
    > {
    >
    > double NewWidth;
    >
    > double NewHeight;
    >
    > double ShrinkPercent;
    >
    > System.Drawing.Image.GetThumbnailImageAbort myCallback =
    >
    > new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
    >
    > if (bmp.Width>bmp.Height)
    >
    > {
    >
    > NewWidth=NewSize;
    >
    > ShrinkPercent=(NewWidth/bmp.Width)*100;
    >
    > NewHeight=(ShrinkPercent/100)*bmp.Height;
    >
    > }
    >
    > else
    >
    > {
    >
    > NewHeight=NewSize;
    >
    > ShrinkPercent=(NewHeight/bmp.Height)*100;
    >
    > NewWidth=(ShrinkPercent/100)*bmp.Width;
    >
    > }
    >
    > System.Drawing.Image myShrunkenImage =
    > bmp.GetThumbnailImage((int)NewWidth,(int)NewHeight,myCallback,IntPtr.Zero);
    >
    > return myShrunkenImage;
    >
    > }
    >
    > public bool ThumbnailCallback(){return false;}
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
     
    eamon, Aug 4, 2005
    #1
    1. Advertising

  2. eamon

    kwkahler Guest

    'Here you go..
    'Put these on top:

    Imports System.Drawing.Image
    Imports System.Drawing

    'And here is the code:



    Public Sub DisplaySize(ByVal bmp As Bitmap)
    response.write (bmp.Width.ToString())
    response.write (bmp.Height.ToString())
    End Sub

    'shrink the image proportionately so that neither height nor width is
    'more than [NewSize] pixels

    Public Function ShrinkImage(ByVal bmp As Bitmap, ByVal NewSize As
    Integer) As Image
    Dim NewWidth As Double
    Dim NewHeight As Double
    Dim ShrinkPercent As Double

    Dim myCallback As GetThumbnailImageAbort
    myCallback = New GetThumbnailImageAbort(AddressOf ThumbnailCallback)

    If bmp.Width > bmp.Height Then
    NewWidth = NewSize
    ShrinkPercent = (NewWidth / bmp.Width) * 100
    NewHeight = (ShrinkPercent / 100) * bmp.Height
    Else
    NewHeight = NewSize
    ShrinkPercent = (NewHeight / bmp.Height) * 100
    NewWidth = (ShrinkPercent / 100) * bmp.Width
    End If
    Dim myShrunkenImage As Image = bmp.GetThumbnailImage(NewWidth,
    NewHeight, myCallback, IntPtr.Zero)
    Return myShrunkenImage

    End Function

    Public Function ThumbnailCallback() As Boolean
    Return False
    End Function



    '--
    'William Kahler
    '.NET Developer, MCSD
     
    kwkahler, Aug 5, 2005
    #2
    1. Advertising

  3. eamon

    eamon Guest

    Thank you its working fine

    "kwkahler" wrote:

    > 'Here you go..
    > 'Put these on top:
    >
    > Imports System.Drawing.Image
    > Imports System.Drawing
    >
    > 'And here is the code:
    >
    >
    >
    > Public Sub DisplaySize(ByVal bmp As Bitmap)
    > response.write (bmp.Width.ToString())
    > response.write (bmp.Height.ToString())
    > End Sub
    >
    > 'shrink the image proportionately so that neither height nor width is
    > 'more than [NewSize] pixels
    >
    > Public Function ShrinkImage(ByVal bmp As Bitmap, ByVal NewSize As
    > Integer) As Image
    > Dim NewWidth As Double
    > Dim NewHeight As Double
    > Dim ShrinkPercent As Double
    >
    > Dim myCallback As GetThumbnailImageAbort
    > myCallback = New GetThumbnailImageAbort(AddressOf ThumbnailCallback)
    >
    > If bmp.Width > bmp.Height Then
    > NewWidth = NewSize
    > ShrinkPercent = (NewWidth / bmp.Width) * 100
    > NewHeight = (ShrinkPercent / 100) * bmp.Height
    > Else
    > NewHeight = NewSize
    > ShrinkPercent = (NewHeight / bmp.Height) * 100
    > NewWidth = (ShrinkPercent / 100) * bmp.Width
    > End If
    > Dim myShrunkenImage As Image = bmp.GetThumbnailImage(NewWidth,
    > NewHeight, myCallback, IntPtr.Zero)
    > Return myShrunkenImage
    >
    > End Function
    >
    > Public Function ThumbnailCallback() As Boolean
    > Return False
    > End Function
    >
    >
    >
    > '--
    > 'William Kahler
    > '.NET Developer, MCSD
    >
    >
     
    eamon, Aug 5, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JC
    Replies:
    4
    Views:
    8,029
    Jeff C
    Jul 8, 2004
  2. Replies:
    4
    Views:
    565
    Chris Uppal
    May 5, 2005
  3. KK
    Replies:
    2
    Views:
    706
    Big Brian
    Oct 14, 2003
  4. MuZZy
    Replies:
    7
    Views:
    1,822
    Mike Hewson
    Jan 7, 2005
  5. mera
    Replies:
    7
    Views:
    1,154
Loading...

Share This Page