Link to home
Start Free TrialLog in
Avatar of dlavar
dlavar

asked on

Resize image before loading to sqlserver

On my application, I have programmed to where the user can load images and display them using crystal reports 10. Well I have no problem loading images.  but if they happen to be too big, crystal reports will not display them.  So I need help writing code to resize the image before loading it to the server.  Here is the code I have thus far.
Dim fileName As String
        Dim fileType As String
        Dim namePosition As Int16
        Dim stream As IO.Stream
 
        stream = file1.PostedFile.InputStream
        Dim uploadedFile(stream.Length) As Byte
        stream.Read(uploadedFile, 0, stream.Length)
 
        namePosition = file1.PostedFile.FileName.LastIndexOf("\") + 1
        fileName = file1.PostedFile.FileName.Substring(namePosition)
        fileType = file1.PostedFile.ContentType
 
 
                Try
            Session("Casenumber") = strcasenumber
            dtreportdate = Now.Date
            strdescription = txtdescription.Text
            strDSFM = ddldsfm2.SelectedItem.Value
 
            connFF.Open()
            With cmdImages.Parameters
                .Add("@casenumber", strcasenumber)
                .Add("@reportdate", dtreportdate)
                .Add("@description", strdescription)
                .Add("@DSFM", strDSFM)
                .Add("@pic", uploadedFile)
            End With
 
            cmdImages.ExecuteNonQuery()
            connFF.Close()
            Response.Write("<script language= javascript>alert(""Image have been saved for casenumber " + strcasenumber + "!"");</script>")
            btnPrintImage.Visible = True
            SetInitialFocus(btnPrintImage)
 
        Catch er As Exception
            LogError(er.ToString, "Submit-ReportNotes.aspx")
            Exit Try
        Finally
            connFF.Close()
        End Try
    End Sub

Open in new window

SOLUTION
Avatar of ladarling
ladarling
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dlavar
dlavar

ASKER

jsblindside, I couldn't access that image data source.  It kept displaying .....
Internet Explorer cannot display the webpage
Avatar of dlavar

ASKER

ladarling I'm sorry but I'm still at a lost because I'm having a problem declaring the stream as bitmap.  I keep getting all types of blue line errors.