Click here to Skip to main content
15,896,513 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Add-in problem opening word file with write permission Pin
John Kuhn14-Apr-04 15:55
John Kuhn14-Apr-04 15:55 
GeneralRe: Add-in problem opening word file with write permission Pin
skoizumi2911015-Apr-04 10:18
sussskoizumi2911015-Apr-04 10:18 
GeneralVB6 Pin
vikasg197713-Apr-04 14:04
vikasg197713-Apr-04 14:04 
GeneralRe: VB6 Pin
John Kuhn13-Apr-04 16:03
John Kuhn13-Apr-04 16:03 
GeneralRe: VB6 Pin
T Manjaly15-Apr-04 12:54
T Manjaly15-Apr-04 12:54 
GeneralImage Processing using VB.NET Pin
Funkytroll0113-Apr-04 11:58
Funkytroll0113-Apr-04 11:58 
GeneralRe: Image Processing using VB.NET Pin
Dave Kreskowiak13-Apr-04 12:52
mveDave Kreskowiak13-Apr-04 12:52 
GeneralRe: Image Processing using VB.NET Pin
roopeshsheth15-Apr-04 7:36
roopeshsheth15-Apr-04 7:36 
There are some built-in classes in the .NET Framework to help manipulate images. Below is some code I wrote to resize an image on my machine and serve it back to the user. Keep in mind that this page (.aspx) would be in the <img> tag indicating where to find the file.

<br />
Public Class SizeImage<br />
    Inherits System.Web.UI.Page<br />
<br />
#Region " Web Form Designer Generated Code "<br />
<br />
    'This call is required by the Web Form Designer.<br />
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
<br />
    End Sub<br />
<br />
    'NOTE: The following placeholder declaration is required by the Web Form Designer.<br />
    'Do not delete or move it.<br />
    Private designerPlaceholderDeclaration As System.Object<br />
<br />
    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<br />
        'CODEGEN: This method call is required by the Web Form Designer<br />
        'Do not modify it using the code editor.<br />
        InitializeComponent()<br />
    End Sub<br />
<br />
#End Region<br />
<br />
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
        'Put user code to initialize the page here<br />
        Dim ImageURL As String<br />
        Dim Width, Height, imageWidth, imageHeight As Integer<br />
        Dim ScaleFactor As Double<br />
<br />
        Dim FullImage As System.Drawing.Image<br />
        Dim ThumbImage As System.Drawing.Image<br />
        Dim dummyCallBack As System.Drawing.Image.GetThumbnailImageAbort<br />
<br />
        'Get the stuff off the Querystring<br />
        ImageURL = Request.QueryString.Item("ImageURL").ToString<br />
        ImageURL = Server.UrlDecode(ImageURL)<br />
        ImageURL = Server.MapPath(ImageURL)<br />
        Try<br />
            Width = Request.QueryString.Item("Width")<br />
            Height = Request.QueryString.Item("Height")<br />
        Catch ex As Exception<br />
            Width = 120<br />
            Height = 120<br />
        End Try<br />
<br />
        'Setup to be able to return the thumbnail<br />
        dummyCallBack = New _<br />
           System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)<br />
<br />
        'Let's go get this image<br />
        FullImage = System.Drawing.Image.FromFile(ImageURL)<br />
<br />
        'Let's get the image's dimensions<br />
        imageWidth = FullImage.Width<br />
        imageHeight = FullImage.Height<br />
<br />
        'see if we need to size this image<br />
        If imageWidth > Width OrElse imageHeight > Height Then<br />
            'Figure out which dimension is the bigger of the two<br />
            If (imageWidth - Width) >= (imageHeight - Height) Then<br />
                'The width will be the dimension scale, or it's a square<br />
                'in which case, this will work just fine.<br />
                ScaleFactor = Width / imageWidth<br />
            Else<br />
                'The height is the limiting dimension, so scale based on that<br />
                ScaleFactor = Height / imageHeight<br />
            End If<br />
            'Use the determined scalefactor to get the dimension size we need for each dimension<br />
            Width = ScaleFactor * imageWidth<br />
            Height = ScaleFactor * imageHeight<br />
            'Rotate/Flip twice (end up with original image, still)<br />
            'This is done so the EXIF thumbnail is not used<br />
            FullImage.RotateFlip(RotateFlipType.Rotate180FlipNone)<br />
            FullImage.RotateFlip(RotateFlipType.Rotate180FlipNone)<br />
            ThumbImage = FullImage.GetThumbnailImage(Width, Height, dummyCallBack, IntPtr.Zero)<br />
        Else<br />
            ThumbImage = FullImage<br />
        End If<br />
        ThumbImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)<br />
<br />
        'Cleanup area<br />
        ThumbImage.Dispose()<br />
        FullImage.Dispose()<br />
    End Sub<br />
<br />
    Function ThumbnailCallback() As Boolean<br />
        Return False<br />
    End Function<br />
<br />
End Class<br />

GeneralRe: Image Processing using VB.NET Pin
Dave Kreskowiak15-Apr-04 16:16
mveDave Kreskowiak15-Apr-04 16:16 
GeneralFinding network computers Pin
Member 57424713-Apr-04 10:30
Member 57424713-Apr-04 10:30 
GeneralRe: Finding network computers Pin
Dave Kreskowiak13-Apr-04 13:01
mveDave Kreskowiak13-Apr-04 13:01 
Generaldeveloping a custom metadata editor for ArcCatalog using VB.NET and COM Pin
abhishk2001@yahoo.com13-Apr-04 10:14
abhishk2001@yahoo.com13-Apr-04 10:14 
GeneralLinks in a RTF Document Pin
mcd242413-Apr-04 3:09
mcd242413-Apr-04 3:09 
GeneralPrint Preview Control problem. Pin
emmshazi13-Apr-04 3:08
emmshazi13-Apr-04 3:08 
GeneralGenerating Keys Pin
rajenderkaur13-Apr-04 2:21
rajenderkaur13-Apr-04 2:21 
GeneralCopyFile to Remote Location Pin
Diverse Computing12-Apr-04 22:54
Diverse Computing12-Apr-04 22:54 
GeneralRe: CopyFile to Remote Location Pin
Dave Kreskowiak13-Apr-04 1:50
mveDave Kreskowiak13-Apr-04 1:50 
GeneralRe: CopyFile to Remote Location Pin
Diverse Computing13-Apr-04 15:14
Diverse Computing13-Apr-04 15:14 
GeneralRe: CopyFile to Remote Location Pin
Dave Kreskowiak13-Apr-04 16:58
mveDave Kreskowiak13-Apr-04 16:58 
GeneralDatabase! Pin
Ilamparithi12-Apr-04 22:37
Ilamparithi12-Apr-04 22:37 
GeneralRe: Database! Pin
Steven Campbell15-Apr-04 3:47
Steven Campbell15-Apr-04 3:47 
GeneralAdding Events To Pin
Toola12-Apr-04 21:50
Toola12-Apr-04 21:50 
GeneralRe: Adding Events To Pin
Hesham Amin13-Apr-04 0:30
Hesham Amin13-Apr-04 0:30 
GeneralTimeSpan from txt File Pin
ineedhelp12-Apr-04 21:46
ineedhelp12-Apr-04 21:46 
GeneralRe: TimeSpan from txt File Pin
Dave Kreskowiak13-Apr-04 1:54
mveDave Kreskowiak13-Apr-04 1:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.