Show/Hide spoilerAfficher/Masquer le spoiler
- Code: Select all
Public Class Form1
'Convertisseur ASM TI-83 / TI-83+
'Logiciel de Alexis Jehan
'espace-ti.e-monsite.com
'Version 2.2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
OpenFileDialog1.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
End Sub
Dim bmp0, bm As Bitmap
Dim gen As Boolean = False
Public imgChargee As Boolean = False
Private Sub Generer(ByVal bmp As Bitmap, Optional ByVal separer As Boolean = False)
Dim Str1 As String = "21369311298E010003EDB0CD6451C9"
Dim Str7 As String = "0123456789ABCDEF "
Dim Str8 As String = ""
Dim D As Integer = 0
Dim I As Integer = 0
Dim X As Integer = 0
Dim Z As Integer = 0
If TI83.Checked Then
Str1 = "21369311298E010003EDB0CD6451C9"
ElseIf TI83plus.Checked Then
Str1 = "21A49D114093010003EDB0CD6451C9"
End If
If Blanche.Checked Then
Z = 0
ElseIf Noire.Checked Then
Z = 1
End If
For A = 0 To 62
For B = 0 To 10
X = 0
For C = 7 To 0 Step -1
If bmp.GetPixel(8 * B + 7 - C, A).ToArgb = Color.Black.ToArgb Then
X += 2 ^ C
End If
Next C
If X = 0 Then
Str8 = "00"
End If
If X = 255 Then
Str8 = "FF"
End If
If X 0 And X 255 Then
I = X
Str8 = "."
While I 0
D = 16 * (I / 16 - Int(I / 16))
I = Int(I / 16)
Str8 = Mid(Str7, D + 1, 1) Str8
End While
Str8 = Mid(Str8, 1, Str8.Length() - 1)
If X = 15 Then
Str8 = "0" Str8
End If
End If
Str1 = Str8
Next B
X = 0
For B = 88 To 94
If bmp.GetPixel(B, A).ToArgb = Color.Black.ToArgb Then
X += 2 ^ (7 - (B - 88))
End If
Next B
X += Z
If X = 0 Then
Str8 = "00"
End If
If X = 255 Then
Str8 = "FF"
End If
If X 0 And X 255 Then
I = X
Str8 = "."
While I 0
D = 16 * (I / 16 - Int(I / 16))
I = Int(I / 16)
Str8 = Mid(Str7, D + 1, 1) Str8
End While
Str8 = Mid(Str8, 1, Str8.Length() - 1)
If X = 15 Then
Str8 = "0" Str8
End If
End If
Str1 = Str8
Next A
If Z = 1 Then
Str8 = "FF"
Else
Str8 = "00"
End If
For A = 0 To 11
Str1 = Str8
Next A
If TI83.Checked Then
TextBox1.Text = Str1 vbCrLf "End" vbCrLf "0000" vbCrLf "End"
ElseIf TI83plus.Checked Then
TextBox1.Text = "AsmPrgm" vbCrLf Str1
End If
End Sub
Public Sub genVerif()
If imgChargee AndAlso gen Then Generer(PictureBox1.Image, CheckBox1.Checked)
End Sub
Private Function version() As String
With System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly.Location)
If .FileBuildPart = 0 Then
If .FilePrivatePart = 0 Then
version = .FileMajorPart "." .FileMinorPart
Else
version = .FileMajorPart "." .FileMinorPart "." .FileBuildPart "." .FilePrivatePart
End If
Else
If .FilePrivatePart = 0 Then
version = .FileMajorPart "." .FileMinorPart "." .FileBuildPart
Else
version = .FileMajorPart "." .FileMinorPart "." .FileBuildPart "." .FilePrivatePart
End If
End If
End With
End Function
Private Sub b_Generer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b_Generer.Click
If Not imgChargee Then
MsgBox("Sélectionnez une image.", MsgBoxStyle.Critical, "Erreur")
Exit Sub
End If
Generer(PictureBox1.Image, CheckBox1.Checked)
gen = True
End Sub
Private Sub b_Copier1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b_Copier1.Click
If TextBox1.Text = "" Then
MsgBox("Générez d'abord le programme.", MsgBoxStyle.Critical, "Erreur")
Else
Clipboard.SetText(TextBox1.Text)
End If
End Sub
Private Sub b_Ouvrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b_Ouvrir.Click
If Not OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then Exit Sub
Try
bmp0 = New Bitmap(OpenFileDialog1.FileName)
Catch
MsgBox("Image non valide.", MsgBoxStyle.Critical, "Erreur")
Exit Sub
End Try
Dim z As Bitmap = New Bitmap(95, 63)
Dim g As Graphics = Graphics.FromImage(z)
g.DrawImage(bmp0, New Rectangle(0, 0, z.Width, z.Height))
bmp0 = z
TextBox1.Text = ""
CheckBox2.Checked = False
gen = False
PictureBox1.Image = New Bitmap(BMP2Mono(bmp0, TrackBar1.Value / TrackBar1.Maximum))
bmp0.Dispose()
imgChargee = True
b_Generer.Select()
End Sub
Private Sub TextBox_KeyDown(ByVal sender As TextBox, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.Control AndAlso e.KeyCode = Keys.A Then
sender.SelectAll()
e.SuppressKeyPress = True
End If
End Sub
Private Function BMP2Mono(ByVal img As Bitmap, Optional ByVal sens As Double = 0.5) As Bitmap
Using bm As New Bitmap(img.Width, img.Height)
For y = 0 To img.Height - 1
For x = 0 To img.Width - 1
If img.GetPixel(x, y).GetBrightness = sens Then
bm.SetPixel(x, y, Color.White)
Else
bm.SetPixel(x, y, Color.Black)
End If
Next x, y
img.Dispose()
BMP2Mono = New Bitmap(bm)
bm.Dispose()
End Using
End Function
Private Sub TrackBar1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged
Label1.Text = "Sensibilité: " CDbl(TrackBar1.Value / TrackBar1.Maximum).ToString
If imgChargee Then
bmp0 = New Bitmap(OpenFileDialog1.FileName)
Dim z As Bitmap = New Bitmap(95, 63)
Dim l As Graphics = Graphics.FromImage(z)
l.DrawImage(bmp0, New Rectangle(0, 0, z.Width, z.Height))
bmp0 = z
PictureBox1.Image = bmp0
PictureBox1.Image = New Bitmap(BMP2Mono(bmp0, TrackBar1.Value / TrackBar1.Maximum))
If CheckBox2.Checked Then
Try
Dim img As Bitmap = New Bitmap(PictureBox1.Image)
Dim c As Color
Dim i As Integer = 0
Do While (i img.Width)
Dim j As Integer = 0
Do While (j img.Height)
c = img.GetPixel(i, j)
Dim r As Integer = 0
r = Convert.ToInt16(c.R)
Dim g As Integer = 0
g = Convert.ToInt16(c.G)
Dim b As Integer = 0
b = Convert.ToInt16(c.B)
Dim newr As Integer = 0
newr = (255 - r)
Dim newg As Integer = 0
newg = (255 - g)
Dim newb As Integer = 0
newb = (255 - b)
c = Color.FromArgb(newr, newg, newb)
img.SetPixel(i, j, c)
j = (j + 1)
Loop
i = (i + 1)
Loop
PictureBox1.Image = img
Catch ex As Exception
MsgBox("Sélectionnez une image.", MsgBoxStyle.Critical, "Erreur")
End Try
End If
PictureBox1.Refresh()
Label1.Refresh()
bmp0.Dispose()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Convertisseur Image ASM TI-83 / TI-83+" vbCrLf "Logiciel de Alexis Jehan." vbCrLf "Merci à M@T pour le script." vbCrLf "" vbCrLf "espace-ti.e-monsite.com" vbCrLf "" vbCrLf "Version 2.2", MsgBoxStyle.Information, "A propos")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox("Pour exécuter le programme:" vbCrLf vbCrLf "- Sur TI-82 Stats / TI-83:" vbCrLf "Envoi(9prgmNOM) / Send(9prgmNOM)" vbCrLf vbCrLf "- Sur TI-83+ / TI-84+:" vbCrLf "AsmComp(prgmNOM,prgmNOM2)" vbCrLf "Asm(prgmNOM2)", MsgBoxStyle.Information, "Infos")
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
System.Diagnostics.Process.Start("http://espace-ti.e-monsite.com/")
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
Try
Dim img As Bitmap = New Bitmap(PictureBox1.Image)
Dim c As Color
Dim i As Integer = 0
Do While (i img.Width)
Dim j As Integer = 0
Do While (j img.Height)
c = img.GetPixel(i, j)
Dim r As Integer = 0
r = Convert.ToInt16(c.R)
Dim g As Integer = 0
g = Convert.ToInt16(c.G)
Dim b As Integer = 0
b = Convert.ToInt16(c.B)
Dim newr As Integer = 0
newr = (255 - r)
Dim newg As Integer = 0
newg = (255 - g)
Dim newb As Integer = 0
newb = (255 - b)
c = Color.FromArgb(newr, newg, newb)
img.SetPixel(i, j, c)
j = (j + 1)
Loop
i = (i + 1)
Loop
PictureBox1.Image = img
Catch ex As Exception
If CheckBox2.Checked = True Then
MsgBox("Sélectionnez une image.", MsgBoxStyle.Critical, "Erreur")
CheckBox2.Checked = False
End If
End Try
End Sub
End Class
EDIT : Je n'y comprend rien au VB .net, mais il faudrait voir si tu peut mettre une variable (multiple de 4) au lieu d'une constante pour 94 pixels