Sub 解密(Filename As String,Outfilename As String) 开头覆写00 00 00 00。 Dim InStream As New StreamReader(Filename) Dim OutStream As New StreamWriter(Outfilename) OutStream.WriteByte(new Byte(){0,0,0,0}) ,把04 05比特倒过来,转为十进制,记a。 Dim a =InStream.ReadByte(4)+InStream.ReadByte(5)*100 记下文件大小,单位是比特,记b。 ,b-a*12-10=c Dim b=InStream.Length Dim c=b-a*12-10 Dim cRev() As Byte=Hex(c).ToArray.Reverse OutStream.Position=6 OutStream.WriteByte(cRev) ,把c转换为十六进制,倒过来。 填进06 07 08 09比特。 InStream.Position=10 OutStream.Write(InStream.ReadToEnd) 保存并退出 InStream.Close OutStream.Close End Sub
每日一睡啊!水), ave, minave(2, 2) As Integer For i As Integer = 0 To 2 For j As Integer = 0 To 2 minave(i, j) = 255 Next Next Dim 补齐了 As Boolean = False If PixelValue.Count <> wid * hei * 3 Then 补齐了 = True Dim skp As Integer = 1 Randomize() If ge Then skp = 2 End If For x As Integer = 0 To wid - 1 Step skp If randskip AndAlso Rnd() > accu Then Continue For Dim bx, by As Integer Select Case x Case Is < wid \ 3 bx = 0 Case Is > wid \ 3 * 2 bx = 2 Case Else bx = 1 End Select For y As Integer = 0 To hei - 1 Step skp If 补齐了 Then ave = CByte((CInt(PixelValue(y * wid * 3 + x * 3)) + CInt(PixelValue(y * wid * 3 + x * 3 + 1)) + CInt(PixelValue(y * wid * 3 + x * 3 + 2))) \ 3) Else ave = CByte((CInt(PixelValue(y * wid * 3 + x * 3 + y)) + CInt(PixelValue(y * wid * 3 + x * 3 + 1 + y)) + CInt(PixelValue(y * wid * 3 + x * 3 + 2 + y))) \ 3) End If Select Case y Case Is < hei \ 3 by = 0 Case Is > hei \ 3 * 2 by = 2 Case Else by = 1 End Select If ave > maxave(bx, by) Then maxave(bx, by) = ave If ave < minave(bx, by) Then minave(bx, by) = ave If x Mod 15 = 0 Then progress(0.7 * (x + 1) / wid) Next Next '写图 For x As Integer = 0 To wid - 1 If x Mod 75 = 0 Then progress(0.7 + 0.3 * (x + 1) / wid) End If Dim bx, by As Integer Select Case x Case Is < wid \ 3 bx = 0 Case Is > wid \ 3 * 2 bx = 2 Case Else bx = 1 End Select For y As Integer = 0 To hei - 1 Select Case y Case Is < hei \ 3 by = 0 Case Is > hei \ 3 * 2 by = 2 Case Else by = 1 End Select Dim BlockThreadhold As Double = minave(bx, by) + (maxave(bx, by) - minave(bx, by)) * darkness Dim average As Byte If 补齐了 Then average = CByte((CInt(PixelValue(y * wid * 3 + x * 3)) + CInt(PixelValue(y * wid * 3 + x * 3 + 1)) + CInt(PixelValue(y * wid * 3 + x * 3 + 2))) \ 3) Else average = CByte((CInt(PixelValue(y * wid * 3 + x * 3 + y)) + CInt(PixelValue(y * wid * 3 + x * 3 + 1 + y)) + CInt(PixelValue(y * wid * 3 + x * 3 + 2 + y))) \ 3) End If If average < BlockThreadhold Then average = 0 Else average = 255 End If If 补齐了 Then PixelValue(y * wid * 3 + x * 3) = average PixelValue(y * wid * 3 + x * 3 + 1) = average PixelValue(y * wid * 3 + x * 3 + 2) = average Else PixelValue(y * wid * 3 + x * 3 + y) = average PixelValue(y * wid * 3 + x * 3 + 1 + y) = average PixelValue(y * wid * 3 + x * 3 + 2 + y) = average End If 'bmpnew.SetPixel(x, y, pxColor) '慢! Next Next filepath = System.IO.Path.GetDirectoryName(filename) Dim fn As String = filepath + "\Binarized_" + IO.Path.GetFileNameWithoutExtension(filename) + ".png" bm.UnlockBits(data) hImage.Free() progress(1) Try bm.Save(filepath + "\Binarized_" + IO.Path.GetFileNameWithoutExtension(filename) + ".png", Imaging.ImageFormat.Png) Catch ex As Exception Msgbox(ex.Message, vbExclamation, "错误", 3000) End Try End Sub