Click here to Skip to main content
15,909,193 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionsoftwares for agriculture irrigation with the help of visual basic Pin
Member 134513307-Oct-17 4:49
Member 134513307-Oct-17 4:49 
AnswerRe: softwares for agriculture irrigation with the help of visual basic Pin
OriginalGriff7-Oct-17 4:50
mveOriginalGriff7-Oct-17 4:50 
AnswerRe: softwares for agriculture irrigation with the help of visual basic Pin
Mycroft Holmes7-Oct-17 15:15
professionalMycroft Holmes7-Oct-17 15:15 
Questionsoftwares for agriculture irrigation with the help of visual basic Pin
Member 134513307-Oct-17 4:06
Member 134513307-Oct-17 4:06 
AnswerRe: softwares for agriculture irrigation with the help of visual basic Pin
OriginalGriff7-Oct-17 4:50
mveOriginalGriff7-Oct-17 4:50 
QuestionDataGridView with Two Datatables and Combobox Lookup Pin
billsut4-Oct-17 2:19
billsut4-Oct-17 2:19 
AnswerRe: DataGridView with Two Datatables and Combobox Lookup Pin
Mycroft Holmes4-Oct-17 13:30
professionalMycroft Holmes4-Oct-17 13:30 
QuestionResizing images Pin
A_Griffin3-Oct-17 2:03
A_Griffin3-Oct-17 2:03 
I am creating a some PDF and Word docs on the fly, using itextsharp and an Aspose component for each respectively, importing some images. The raw images are 1000x1000 px, which is way too large - I need to fit two per page, above each other (and some text). I find they have to be no bigger than 300x300 for my requirements.

I can take two approaches:

1) import the images as are, and display them at 300x300 using appropriate object properties

2) re-size the images first to 300x300 then import these and display them at that size.

Approach 1) works beautifully. But with 14 such images the final product is over about 14MB - somewhat large for emailing.

Approach 2) works... but the image quality is lousy. Below is my code for re-sizing the images - my questions is:

Can this code be improved - and how come the docs can re-size them on the fly and retain such high quality, but this code is so bad?

The images are PNG's.

Private Function ResizePlayoutImage(ByVal sFile As String) As Boolean
    Try
       Dim FullSizeImage As System.Drawing.Image
       FullSizeImage = System.Drawing.Image.FromFile(xmlPath & "Playout_images\\" & sFile)

       If FullSizeImage.Width = 300 Then
          FullSizeImage.Dispose()
          If File.Exists(xmlPath & "Edited_images\\" & sFile) Then File.Delete(xmlPath & "Edited_images\\" & sFile)
          File.Copy(xmlPath & "Playout_images\\" & sFile, xmlPath & "Edited_images\\" & sFile)

       Else
          Dim tmp As Bitmap
          Dim gX As System.Drawing.Graphics

          tmp = New Bitmap(300, 300)
          gX = System.Drawing.Graphics.FromImage(tmp)
          gX.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
          gX.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
          gX.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
          gX.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
          gX.DrawImage(FullSizeImage, 0, 0, 300, 300)

          If File.Exists(xmlPath & "Edited_images\\" & sFile) Then File.Delete(xmlPath & "Edited_images\\" & sFile)
          tmp.Save(xmlPath & "Edited_images\\" & sFile, System.Drawing.Imaging.ImageFormat.Png)
          tmp.Dispose()
          gX.Dispose()

          FullSizeImage.Dispose()

       End If

       Return True
    Catch ex As Exception
       adp.WriteLog("ResizePlayoutImage", ex.Message & vbCrLf & sFile)
       Return False
    End Try
 End Function


(PS there's something not quite right in the editor here, CP - NB I have to add a \ before any quotes or it messes up the display - but of course the code doesn't need that.)

modified 3-Oct-17 8:58am.

AnswerRe: Resizing images Pin
Richard MacCutchan3-Oct-17 6:31
mveRichard MacCutchan3-Oct-17 6:31 
GeneralRe: Resizing images Pin
A_Griffin3-Oct-17 8:14
A_Griffin3-Oct-17 8:14 
Questiondatabase design for financial accounting Pin
Mohammad Kamil1-Oct-17 8:47
Mohammad Kamil1-Oct-17 8:47 
AnswerRe: database design for financial accounting Pin
Mycroft Holmes1-Oct-17 13:28
professionalMycroft Holmes1-Oct-17 13:28 
QuestionRetrieve data from Acess database after login form Pin
Charles9730-Sep-17 4:48
Charles9730-Sep-17 4:48 
AnswerRe: Retrieve data from Acess database after login form Pin
Richard Andrew x6430-Sep-17 5:15
professionalRichard Andrew x6430-Sep-17 5:15 
QuestionI am changing code from vb6 windows application to vb.net windows application..getting error on EOF. sAn unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test.exe Additional information: Operation is not allowed Pin
Member 1075459525-Sep-17 6:27
Member 1075459525-Sep-17 6:27 
SuggestionRe: I am changing code from vb6 windows application to vb.net windows application..getting error on EOF. sAn unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test.exe Additional information: Operation is not allo Pin
Richard Deeming25-Sep-17 6:39
mveRichard Deeming25-Sep-17 6:39 
GeneralRe: I am changing code from vb6 windows application to vb.net windows application..getting error on EOF. sAn unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test.exe Additional information: Operation is not allo Pin
Member 1075459525-Sep-17 7:07
Member 1075459525-Sep-17 7:07 
AnswerRe: I am changing code from vb6 windows application to vb.net windows application..getting error on EOF. sAn unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test.exe Additional information: Operation is not allo Pin
Wendelius25-Sep-17 10:16
mentorWendelius25-Sep-17 10:16 
QuestionUse a variable or text box in Sql WHERE clause Pin
Member 1300905323-Sep-17 9:31
Member 1300905323-Sep-17 9:31 
AnswerRe: Use a variable or text box in Sql WHERE clause Pin
Afzaal Ahmad Zeeshan23-Sep-17 10:28
professionalAfzaal Ahmad Zeeshan23-Sep-17 10:28 
QuestionVLC Player User-Agent for vb6 Pin
Member 1341240517-Sep-17 17:01
Member 1341240517-Sep-17 17:01 
QuestionVB Form Search XLSX Pin
Member 24539047-Sep-17 10:41
Member 24539047-Sep-17 10:41 
AnswerRe: VB Form Search XLSX Pin
Richard MacCutchan7-Sep-17 19:21
mveRichard MacCutchan7-Sep-17 19:21 
AnswerRe: VB Form Search XLSX Pin
Chris Quinn7-Sep-17 20:39
Chris Quinn7-Sep-17 20:39 
GeneralRe: VB Form Search XLSX Pin
Member 24539048-Sep-17 5:54
Member 24539048-Sep-17 5: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.