Advertisement
Advertisement
| 04.23.2008 at 03:41AM PDT, ID: 23345965 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: |
Private Sub cmdViewImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdViewImage.Click
Dim v_StockID As Integer
'Dim v_strUploadDir As String
'Dim v_ImageLocations() As String
Dim v_Path As String
Dim v_ImageResizer As New clsImageResizer
Dim v_Image As Image
Dim v_Counter As Integer
Dim v_Connection As New SqlClient.SqlConnection
Dim v_Command As New SqlClient.SqlCommand
Dim v_RecordSet As SqlClient.SqlDataReader
Try
Cursor = Cursors.WaitCursor
g_ImageList.Clear()
dilLoader.Controls.Clear()
If txtImgStockID.Text <> "" Then
v_Counter = 0
v_StockID = txtImgStockID.Text
v_Path = My.Settings.ProductImgUploadDir & v_StockID & "\"
v_Connection.ConnectionString = My.Settings.ConnString
v_Command.Connection = v_Connection
v_Command.CommandType = CommandType.StoredProcedure
v_Command.CommandText = "proc_MFM_Get_Stock_Image_Directories"
v_Command.Parameters.Add("@StockID", SqlDbType.Int)
v_Command.Parameters.Item("@StockID").Value = v_StockID
OpenConnection(v_Connection)
v_RecordSet = v_Command.ExecuteReader
While v_RecordSet.Read
If IO.File.Exists(v_Path & v_RecordSet("PictureLarge")) Then
v_Image = Image.FromFile(v_Path & v_RecordSet("PictureLarge"))
v_Image.Tag = v_Path & v_RecordSet("PictureLarge")
g_ImageList.Add(v_Image.Clone)
g_ImageList.Item(v_Counter).Tag = v_Path & v_RecordSet("PictureLarge")
v_Image.Dispose()
v_Counter = v_Counter + 1
End If
End While
If g_ImageList.Count > 0 Then
AddImages(g_ImageList, g_ThumbnailImgSize)
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "cmdViewImage_Click")
Finally
v_Image = Nothing
v_ImageResizer = Nothing
CloseConnection(v_Connection)
Cursor = Cursors.Default
GC.Collect()
End Try
End Sub
' AddImages Sub
Sub AddImages(ByRef g_ImageList As List(Of Image), ByVal v_ImageDisplaySize As Size)
Dim v_PanelWidth As Double, v_SpacerWidth As Double
Dim v_ImageCountPerLine As Integer
Dim v_Comp As PictureBox
Dim v_Checkbox As CheckBox
Dim i As Integer, j As Integer
Dim v_Xpos, v_Ypos As Integer
Dim img As New clsImageResizer()
Try
i = 0
j = 1
v_Xpos = 0
v_Ypos = 5
dilLoader.Controls.Clear()
If g_ImageList.Count > 0 Then
' Get the full "workable" width of the component (-scrollbar width)
v_PanelWidth = dilLoader.Width - 17
v_ImageCountPerLine = Math.Floor((v_PanelWidth) / (v_ImageDisplaySize.Width)) ' 3
v_SpacerWidth = (v_PanelWidth) - (v_ImageCountPerLine * v_ImageDisplaySize.Width) '69
v_SpacerWidth = Math.Floor(v_SpacerWidth / (v_ImageCountPerLine + 1))
While i < g_ImageList.Count
img.LoadImage(g_ImageList.Item(i))
v_Comp = New PictureBox
v_Comp.Name = "pbImage"
v_Comp.Tag = i
v_Comp.BorderStyle = BorderStyle.FixedSingle
v_Comp.SizeMode = PictureBoxSizeMode.CenterImage
v_Comp.Parent = dilLoader
v_Comp.MaximumSize = v_ImageDisplaySize 'New Size(v_ImageDisplaySize, v_ImageDisplaySize)
v_Comp.Size = v_ImageDisplaySize 'New Size(v_ImageDisplaySize, v_ImageDisplaySize)
v_Comp.Image = img.GetImage(v_ImageDisplaySize).Clone
AddHandler v_Comp.MouseUp, AddressOf v_Comp_MouseUp
v_Xpos = v_Xpos + v_SpacerWidth
v_Comp.Location = New Drawing.Point((v_Xpos), v_Ypos)
v_Checkbox = New CheckBox
v_Checkbox.Parent = dilLoader
v_Checkbox.Name = "cbImage"
v_Checkbox.Tag = i
v_Checkbox.FlatStyle = FlatStyle.Flat
v_Checkbox.Text = ""
v_Checkbox.Visible = True
v_Checkbox.Size = New Size(11, 11)
v_Checkbox.MaximumSize = New Size(11, 11)
v_Checkbox.Location = New Drawing.Point(v_Comp.Left, v_Comp.Top)
v_Checkbox.BringToFront()
' Update the locations here:
If j = v_ImageCountPerLine Then
j = 0
v_Xpos = 0
v_Ypos = v_Ypos + v_ImageDisplaySize.Height + 25
Else
v_Xpos = v_Xpos + v_ImageDisplaySize.Width
End If
v_Comp = Nothing
v_Checkbox = Nothing
i = i + 1
j = j + 1
End While
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "AddImages")
End Try
End Sub
' To move the images:
Private Sub MoveImageFiles(ByVal v_StockID As Integer)
Dim v_tempStrDir As String
Dim v_tempDir As DirectoryInfo
Dim v_tempOriginalDir As DirectoryInfo
Dim v_File As FileInfo
Try
' old_22_apr_2008_09_37_22
v_tempStrDir = "old_" & Format(Now.Day, "00") & "_" & MonthName(Now.Month, True) & "_" & Now.Year & "_" & Format(Now.Hour, "00") & "_" & Format(Now.Minute, "00") & "_" & Format(Now.Second, "00")
v_tempStrDir = My.Settings.ProductImgUploadDir & v_StockID & "\" & v_tempStrDir
IO.Directory.CreateDirectory(v_tempStrDir)
v_tempDir = New DirectoryInfo(v_tempStrDir)
v_tempOriginalDir = New DirectoryInfo(My.Settings.ProductImgUploadDir & v_StockID)
For Each v_File In (v_tempOriginalDir.GetFiles())
v_File.MoveTo(Path.Combine(v_tempDir.FullName, v_File.Name))
Next
v_tempDir = Nothing
v_tempOriginalDir = Nothing
v_File = Nothing
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "MoveImageFiles")
Finally
GC.Collect()
End Try
End Sub
|
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 04.23.2008 at 05:09AM PDT, ID: 21419688 |
1: 2: 3: 4: 5: |
Dim img As Bitmap
Dim fs As IO.FileStream
fs = New IO.FileStream("PATH", IO.FileMode.Open, IO.FileAccess.Read)
img = New Bitmap(fs)
fs.Close()
|
| 04.23.2008 at 05:44AM PDT, ID: 21419980 |
| 04.23.2008 at 08:40AM PDT, ID: 21421908 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: |
While v_RecordSet.Read
If IO.File.Exists(v_Path & v_RecordSet("PictureLarge")) Then
Dim img As Image = Image.FromFile(v_Path & v_RecordSet("PictureLarge"))
v_Image = New Bitmap(img)
img.Dispose()
v_Image.Tag = v_Path & v_RecordSet("PictureLarge")
g_ImageList.Add(v_Image)
g_ImageList.Item(v_Counter).Tag = v_Path & v_RecordSet("PictureLarge")
v_Counter = v_Counter + 1
End If
End While
|
| 04.23.2008 at 12:15PM PDT, ID: 21424253 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: |
Function ImagesSimilar(ByRef image1 As Image, ByRef image2 As Image) As Boolean Try ImagesSimilar = True If image1.Size <> image2.Size Then ' difference ImagesSimilar = False 'ElseIf (My.Computer.FileSystem.GetFileInfo(image1.Tag).Length <> My.Computer.FileSystem.GetFileInfo(image2.Tag).Length) Then ' ImagesSimilar = False Else Dim v_Converter As New System.Drawing.ImageConverter Dim v_SHA256Managed As New System.Security.Cryptography.SHA256Managed Dim btImage1(1) As Byte Dim btImage2(1) As Byte Dim i As Integer i = 0 btImage1 = v_Converter.ConvertTo(image1, btImage1.GetType()) btImage2 = v_Converter.ConvertTo(image2, btImage2.GetType()) Dim hash1() As Byte Dim hash2() As Byte hash1 = v_SHA256Managed.ComputeHash(btImage1) hash2 = v_SHA256Managed.ComputeHash(btImage2) While ((i < (hash1.Length / 2)) And (i < (hash2.Length / 2))) If hash1(i) <> hash2(i) Then ImagesSimilar = False Exit While End If i = i + 1 End While v_Converter = Nothing v_SHA256Managed = Nothing btImage1 = Nothing btImage2 = Nothing hash1 = Nothing hash2 = Nothing End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "ImagesSimilar") Finally GC.Collect() End Try End Function |
| 05.08.2008 at 04:10AM PDT, ID: 21523718 |
| 05.15.2008 at 05:11PM PDT, ID: 21578918 |
1: 2: 3: 4: 5: 6: |
Function ImagesSimilar(ByVal image1 As Image, ByVal image2 As Image) As Boolean
image1 = New Bitmap(image1)
image2 = New Bitmap(image2)
Try
ImagesSimilar = True
...
|
| 05.15.2008 at 11:07PM PDT, ID: 21580338 |