Ce logiciel est destiné à recadrer et redimensionner des photos au format JPeg.
Particulièrement utile avant transfert des photos vers un cadre photo-numérique, en redimensionnant les photos au nombre exact de pixels du cadre, vous gagnerez en place sur la carte de stockage, en temps d'exécution au passage d'une photo à la suivante.
Utilisation ultra-simplifiée: Bouton droit de la souris pour Zoomer, bouton gauche pour déplacer, double-clis pour sauvegarder et passer à l'image suivante.
Mode d'emploi détaillé du logiciel :
1 / Avant de lancer le logiciel, créez tout d'abord un dossier dans lequel vous placerez toutes les photos à recadrer/redimensionner. Pour un classement plus facile des photos, il est possible de créer des sous-dossiers.
2/ Lancez le logiciel, puis placez-vous dans l'onglet Données pour sélectionner le dossier qui contient les photos à recadrer/redimensionner. Attention, toutes les photos du dossier et de ses sous-dossiers seront passées en revue.
Choisissez la largeur et la hauteur des images que vous voulez obtenir. Ces dimensions doivent être comprises entre 32 et 32767 pixels. La taille de l'image souhaitée doit être inférieure à 64 méga-pixels.
3/ Allez dans l'onglet Photos. Par défaut, la première photo non redimensionnée aux dimensions choisies est affichée.
Pour Zoomer, maintenir le bouton droit de la souris enfoncé, puis monter ou descendre la souris pour grossir ou réduire l'image.
Pour déplacer l'image dans la fenêtre, maintenir le bouton gauche de la souris enfoncé, puis déplacer l'image avec la souris.
4/ Pour passer à l'image suivante, utilisez les flèches du clavier (flèche vers le bas, ou page suivante). L?appui sur la touche entrée ou un double-clic dans l'image permet également de passer à l'image suivante.
Pour passer à l'image précédente, utilisez les flèches du clavier (flèche vers le haut, ou page précédente).
A chaque changement d'image, l'image courante est sauvegardée avec son recadrage.
5/ Les images recadrées sont mémorisées dans un dossier "Recadrées" placé dans le dossier d'origine. Si le dossier d'origine contient des sous-dossiers, la même arborescence est recrée dans le dossier "Recadrées".
6/ Pendant les fonctions de zoom, une jauge sur le coté droit de l'image donne le niveau de qualité. En vert tout va bien, le nombre de pixels de la zone sélectionnée de l'image est supérieur au nombre de pixels de l'image recadrée. En rouge c'est l'inverse. La partie sombre (rouge ou verte) donne la marge restante.
7/ Vous n'avez pas eu le temps de traiter tout votre dossier photos. Pas de problème, fermez le logiciel. Tout votre travail reste mémorisé, et à la prochaine utilisation la reprise se fera automatiquement à la dernière photo recadrée.
Source / Exemple :
Imports System.Drawing.Imaging
Imports System.IO
Public Class Form1
Public Structure photo
Dim Nom As String
Dim Folder As String
Dim Top As Integer
Dim Bottom As Integer
Dim Left As Integer
Dim right As Integer
Dim Zoom As Single
Dim ZoomMini As Single
Dim recadreW As Integer
Dim recadreH As Integer
End Structure
Dim photoWidth, photoHeight As Integer
Dim lastPhotoWidth, lastPhotoHeight As Integer
Dim selectedFolder As String
Dim onePhotoIsLoaded As Boolean = False
Dim NbPhotosATraiter As Integer = 0
Dim Photos() As photo
Dim NewFolder As String = ""
Dim photoHeightIsOk, photoWidthIsOk, dossierIsOk, allIsOk As Boolean
Dim resisedPhoto As Bitmap
Dim photoLoaded As New PictureBox
Dim CurrentPhoto As Integer = -1
Dim LastPhotoLoaded As Integer = -1
Dim btnGaucheIsdown As Boolean = False
Dim btnDroiteIsdown As Boolean = False
Public memoMouseX As Integer = -1
Public memoMouseY As Integer = -1
Public MouseIsMoving As Boolean = False
Private Sub control()
allIsOk = True
If photoHeight > 31 Then
If photoHeight < 32768 Then
photoHeightIsOk = True
Else
photoHeightIsOk = False
End If
Else
photoHeightIsOk = False
End If
If photoWidth > 31 Then
If photoWidth < 32768 Then
photoWidthIsOk = True
Else
photoWidthIsOk = False
End If
Else
photoWidthIsOk = False
End If
If photoHeightIsOk And photoWidthIsOk Then
If photoHeight * photoWidth > 64 * 1024 * 1024 Then
photoHeightIsOk = False
photoWidthIsOk = False
End If
End If
If photoHeightIsOk Then
TextBoxHauteur.BackColor = Color.FromArgb(128, 255, 128)
Else
TextBoxHauteur.BackColor = Color.FromArgb(255, 128, 128)
allIsOk = False
End If
If photoWidthIsOk Then
TextBoxLargeur.BackColor = Color.FromArgb(128, 255, 128)
Else
TextBoxLargeur.BackColor = Color.FromArgb(255, 128, 128)
allIsOk = False
End If
If selectedFolder = "" Or NbPhotosATraiter = 0 Then
ButtonChoixPhotos.BackColor = Color.FromArgb(255, 128, 128)
ButtonChoixPhotos.Text = "Choix du dossier de photos"
allIsOk = False
dossierIsOk = False
Else
ButtonChoixPhotos.BackColor = Color.FromArgb(128, 255, 128)
ButtonChoixPhotos.Text = "Choix du dossier de photos (" + NbPhotosATraiter.ToString + ")"
dossierIsOk = True
End If
If allIsOk Then
NewFolder = selectedFolder + "\Recadrées"
Try
My.Computer.FileSystem.CreateDirectory(NewFolder)
Catch ex As Exception
End Try
Dim NomFichier As String = String.Concat(My.Application.Info.DirectoryPath, "\RedimJPegData.txt")
Dim Texte(0) As String
Texte(0) = selectedFolder + "|" + photoHeight.ToString + "|" + photoWidth.ToString
System.IO.File.WriteAllLines(NomFichier, Texte)
End If
End Sub
Private Sub TextBoxLargeur_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxLargeur.TextChanged
Try
photoWidth = System.Convert.ToInt32(TextBoxLargeur.Text)
Catch ex As Exception
photoWidth = 0
If TextBoxLargeur.Text.Length > 1 Then
TextBoxLargeur.Text = TextBoxLargeur.Text.Substring(0, TextBoxLargeur.Text.Length - 1)
TextBoxLargeur.SelectionStart = TextBoxLargeur.Text.Length
ElseIf TextBoxLargeur.Text.Length = 1 Then
TextBoxLargeur.Text = ""
Else
TextBoxLargeur.Text = ""
End If
End Try
control()
End Sub
Private Sub TextBoxHauteur_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxHauteur.TextChanged
Try
photoHeight = System.Convert.ToInt32(TextBoxHauteur.Text)
Catch ex As Exception
photoHeight = 0
If TextBoxHauteur.Text.Length > 1 Then
TextBoxHauteur.Text = TextBoxHauteur.Text.Substring(0, TextBoxHauteur.Text.Length - 1)
TextBoxHauteur.SelectionStart = TextBoxHauteur.Text.Length
ElseIf TextBoxHauteur.Text.Length = 1 Then
TextBoxHauteur.Text = ""
Else
TextBoxHauteur.Text = ""
End If
End Try
control()
End Sub
Private Sub EtablirListePhotos()
NewFolder = selectedFolder + "\Recadrées"
Me.Text = "Recadrage de photos : " + selectedFolder
Try
For Each folder As String In _
My.Computer.FileSystem.GetDirectories(selectedFolder, FileIO.SearchOption.SearchAllSubDirectories)
If folder.Substring(0, Math.Min(folder.Length, NewFolder.Length)) <> NewFolder Then
For Each foundFile As String In _
My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg")
NbPhotosATraiter += 1
Next
End If
Next
For Each foundFile As String In _
My.Computer.FileSystem.GetFiles(selectedFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg")
NbPhotosATraiter += 1
Next
ReDim Photos(NbPhotosATraiter - 1)
NbPhotosATraiter = 0
Dim LengthSelectedFolder As Integer = selectedFolder.Length
For Each folder As String In _
My.Computer.FileSystem.GetDirectories(selectedFolder, FileIO.SearchOption.SearchAllSubDirectories)
If folder.Substring(0, Math.Min(folder.Length, NewFolder.Length)) <> NewFolder Then
For Each foundFile As String In _
My.Computer.FileSystem.GetFiles(folder, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg")
Photos(NbPhotosATraiter).Nom = Strings.Right(foundFile, foundFile.Length - LengthSelectedFolder)
Photos(NbPhotosATraiter).Zoom = 0.0
Photos(NbPhotosATraiter).Folder = folder.Substring(selectedFolder.Length)
NbPhotosATraiter += 1
Next
End If
Next
For Each foundFile As String In _
My.Computer.FileSystem.GetFiles(selectedFolder, FileIO.SearchOption.SearchTopLevelOnly, "*.jpg")
Photos(NbPhotosATraiter).Nom = Strings.Right(foundFile, foundFile.Length - LengthSelectedFolder)
NbPhotosATraiter += 1
Next
CurrentPhoto = 0
Dim Nomfichier As String = selectedFolder + "\MemoRecadrages.txt"
Dim TempResultats() As String
Dim FileOfResultats As System.IO.FileStream
If File.Exists(Nomfichier) Then
FileOfResultats = File.OpenRead(Nomfichier)
TempResultats = File.ReadAllLines(Nomfichier)
Dim i As Integer = 0
While i < TempResultats.Length - 1
Dim Array() As String = Split(TempResultats(i), "|")
For num = 0 To NbPhotosATraiter - 1
If Photos(num).Nom = Array(1) Then
Photos(num).Top = Array(2)
Photos(num).Bottom = Array(3)
Photos(num).Left = Array(4)
Photos(num).right = Array(5)
Photos(num).Zoom = Array(6)
Photos(num).ZoomMini = Array(7)
Photos(num).recadreH = Array(8)
Photos(num).recadreW = Array(9)
End If
Next
i = i + 1
End While
FileOfResultats.Close()
End If
Catch ex As Exception
End Try
End Sub
Private Sub ButtonChoixPhotos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonChoixPhotos.Click
FolderBrowserDialog.Description = "Sélectionner le dossier de photos"
NbPhotosATraiter = 0
If FolderBrowserDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
selectedFolder = FolderBrowserDialog.SelectedPath
EtablirListePhotos()
Else
selectedFolder = ""
CurrentPhoto = -1
End If
control()
End Sub
Private Sub AjustePictureBox()
If TabControl.SelectedIndex <> 1 Then Exit Sub
Dim newH, newW As Integer
Dim coef As Single
PictureBox.Height = TabPagePhotos.Height
PictureBox.Width = TabPagePhotos.Width - PictureBoxZoom.Width - 6
newH = PictureBox.Height
newW = PictureBox.Width
coef = 1.0 * newW / newH * photoHeight / photoWidth
If coef > 1 Then
PictureBox.Width = Math.Round(PictureBox.Width / coef)
Else
PictureBox.Height = Math.Round(PictureBox.Height * coef)
End If
PictureBox.Top = (TabPagePhotos.Height - PictureBox.Height) \ 2
PictureBox.Left = ((TabPagePhotos.Width - PictureBoxZoom.Width - 6) - PictureBox.Width) \ 2
If CurrentPhoto >= 0 Then
LoadPhoto(CurrentPhoto)
End If
End Sub
Private Sub TabPagePhotos_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPagePhotos.Enter
If allIsOk Then
Me.KeyPreview = True
CurrentPhoto = 0
For num = 0 To NbPhotosATraiter - 1
If (Photos(num).Zoom = 0.0) Or (Photos(num).recadreH <> photoHeight) Or (Photos(num).recadreW <> photoWidth) Then Exit For
CurrentPhoto = num
Next
AjustePictureBox()
Else
Me.KeyPreview = False
TabControl.SelectedIndex = 0
End If
End Sub
Private Sub LoadPhoto(ByVal num As Integer)
If num = LastPhotoLoaded Then Exit Sub
Try
photoLoaded.Dispose()
Catch ex As Exception
End Try
Try
resisedPhoto.Dispose()
Catch ex As Exception
End Try
resisedPhoto = New Bitmap(photoWidth, photoHeight)
photoLoaded.Load(selectedFolder + Photos(CurrentPhoto).Nom)
Me.Text = "Recadrage de photos : " + selectedFolder + Photos(CurrentPhoto).Nom
Dim GRP As Graphics = Graphics.FromImage(resisedPhoto)
GRP.InterpolationMode = Drawing2D.InterpolationMode.Low
If (Photos(num).Zoom = 0.0) Or (Photos(num).recadreH <> photoHeight) Or (Photos(num).recadreW <> photoWidth) Then
Dim Z0 As Single = photoLoaded.Image.Width * 1.0 / photoLoaded.Image.Height
Dim Zn As Single = photoWidth * 1.0 / photoHeight
If Zn > Z0 Then
Photos(num).Zoom = photoWidth * 1.0 / photoLoaded.Image.Width
Else
Photos(num).Zoom = photoHeight * 1.0 / photoLoaded.Image.Height
End If
Photos(num).Top = -Math.Round((photoHeight / Photos(num).Zoom - photoLoaded.Image.Height) / 2.0)
Photos(num).Left = -Math.Round((photoWidth / Photos(num).Zoom - photoLoaded.Image.Width) / 2.0)
Photos(num).Bottom = Photos(num).Top + Math.Round(photoHeight / Photos(num).Zoom)
Photos(num).right = Photos(num).Left + Math.Round(photoWidth / Photos(num).Zoom)
Photos(num).ZoomMini = Photos(num).Zoom
Photos(num).recadreH = photoHeight
Photos(num).recadreW = photoWidth
End If
BuildZoom()
Dim Zone As Rectangle
Zone = Rectangle.FromLTRB(0, 0, photoWidth, photoHeight)
GRP.DrawImage(photoLoaded.Image, Zone, Photos(num).Left, Photos(num).Top, _
Photos(num).right - Photos(num).Left, Photos(num).Bottom - Photos(num).Top, GraphicsUnit.Pixel)
PictureBox.Image = resisedPhoto.Clone
GRP.Dispose()
LastPhotoLoaded = num
End Sub
Private Sub TabPagePhotos_SizeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPagePhotos.SizeChanged
AjustePictureBox()
BuildZoom()
End Sub
Private Sub PictureBox_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
btnGaucheIsdown = True
End If
If e.Button = Windows.Forms.MouseButtons.Right Then
btnDroiteIsdown = True
End If
memoMouseX = e.X
memoMouseY = e.Y
End Sub
Private Sub PictureBox_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox.MouseUp
btnDroiteIsdown = False
btnGaucheIsdown = False
End Sub
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Dim key As Integer
key = e.KeyValue
If (key = 33) Or (key = 38) Then ' touche Page Up
SavePhoto()
If CurrentPhoto > 0 Then
CurrentPhoto -= 1
LoadPhoto(CurrentPhoto)
End If
End If
If (key = 34) Or (key = 40) Or (key = 13) Then ' touche Page Down
SavePhoto()
If CurrentPhoto < NbPhotosATraiter - 1 Then
CurrentPhoto += 1
LoadPhoto(CurrentPhoto)
End If
End If
End Sub
Private Function GetEncoder(ByVal format As ImageFormat) As ImageCodecInfo
Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageDecoders()
Dim codec As ImageCodecInfo
For Each codec In codecs
If codec.FormatID = format.Guid Then
Return codec
End If
Next codec
Return Nothing
End Function
Private Sub SavePhoto()
Dim photoName, PhotoFolder As String
Dim myEncoder As Drawing.Imaging.Encoder
Dim myEncoderParameter As Drawing.Imaging.EncoderParameter
Dim myEncoderParameters As Drawing.Imaging.EncoderParameters
Dim jgpEncoder As ImageCodecInfo = GetEncoder(ImageFormat.Jpeg)
myEncoder = Drawing.Imaging.Encoder.Quality
myEncoderParameters = New Drawing.Imaging.EncoderParameters(1)
myEncoderParameter = New Drawing.Imaging.EncoderParameter(myEncoder, CType(99L, Int32))
myEncoderParameters.Param(0) = myEncoderParameter
photoName = selectedFolder + "\Recadrées" + Photos(CurrentPhoto).Nom
PhotoFolder = selectedFolder + "\Recadrées" + Photos(CurrentPhoto).Folder
Try
System.IO.Directory.CreateDirectory(PhotoFolder)
Catch ex As Exception
End Try
Dim Zone As Rectangle
Zone = Rectangle.FromLTRB(0, 0, photoWidth, photoHeight)
Dim GRP As Graphics = Graphics.FromImage(resisedPhoto)
GRP.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
GRP.DrawImage(photoLoaded.Image, Zone, Photos(CurrentPhoto).Left, Photos(CurrentPhoto).Top, _
Photos(CurrentPhoto).right - Photos(CurrentPhoto).Left, Photos(CurrentPhoto).Bottom - Photos(CurrentPhoto).Top, GraphicsUnit.Pixel)
GRP.Dispose()
resisedPhoto.Save(selectedFolder + "\Recadrées" + Photos(CurrentPhoto).Nom, jgpEncoder, myEncoderParameters)
Photos(CurrentPhoto).recadreW = photoWidth
Photos(CurrentPhoto).recadreH = photoHeight
End Sub
Private Sub PictureBox_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox.MouseMove
If MouseIsMoving Then Exit Sub
Dim memX As Integer = e.X
Dim memY As Integer = e.Y
MouseIsMoving = True
If btnGaucheIsdown Then 'Déplacement de la photo dans le cadre
Dim dX, dY As Integer
dX = Math.Round((memoMouseX - memX) * 1.0 / PictureBox.Width * resisedPhoto.Width / Photos(CurrentPhoto).Zoom)
dY = Math.Round((memoMouseY - memY) * 1.0 / PictureBox.Width * resisedPhoto.Width / Photos(CurrentPhoto).Zoom)
Photos(CurrentPhoto).Left += dX
Photos(CurrentPhoto).right += dX
Photos(CurrentPhoto).Top += dY
Photos(CurrentPhoto).Bottom += dY
If Photos(CurrentPhoto).Left < 0 Then
Photos(CurrentPhoto).right -= Photos(CurrentPhoto).Left
Photos(CurrentPhoto).Left = 0
ElseIf Photos(CurrentPhoto).right > photoLoaded.Image.Width Then
Photos(CurrentPhoto).Left -= (Photos(CurrentPhoto).right - photoLoaded.Image.Width)
Photos(CurrentPhoto).right = photoLoaded.Image.Width
End If
If Photos(CurrentPhoto).Top < 0 Then
Photos(CurrentPhoto).Bottom -= Photos(CurrentPhoto).Top
Photos(CurrentPhoto).Top = 0
ElseIf Photos(CurrentPhoto).Bottom > photoLoaded.Image.Height Then
Photos(CurrentPhoto).Top -= (Photos(CurrentPhoto).Bottom - photoLoaded.Image.Height)
Photos(CurrentPhoto).Bottom = photoLoaded.Image.Height
End If
Dim Zone As Rectangle
Zone = Rectangle.FromLTRB(0, 0, photoWidth, photoHeight)
Dim GRP As Graphics = Graphics.FromImage(resisedPhoto)
GRP.InterpolationMode = Drawing2D.InterpolationMode.Low
GRP.DrawImage(photoLoaded.Image, Zone, Photos(CurrentPhoto).Left, Photos(CurrentPhoto).Top, _
Photos(CurrentPhoto).right - Photos(CurrentPhoto).Left, Photos(CurrentPhoto).Bottom - Photos(CurrentPhoto).Top, GraphicsUnit.Pixel)
GRP.Dispose()
PictureBox.Image = resisedPhoto.Clone
memoMouseX = memX
memoMouseY = memY
End If
If btnDroiteIsdown Then 'Zoom
Dim coef As Single = (memoMouseY - memY) * 0.004 + 1.0
Dim photoZoom As Single = Photos(CurrentPhoto).Zoom
photoZoom *= coef
If photoZoom < Photos(CurrentPhoto).ZoomMini Then
coef *= (Photos(CurrentPhoto).ZoomMini / photoZoom)
photoZoom = Photos(CurrentPhoto).ZoomMini
End If
Dim centerX As Integer = (Photos(CurrentPhoto).Left + Photos(CurrentPhoto).right) \ 2
Dim centerY As Integer = (Photos(CurrentPhoto).Top + Photos(CurrentPhoto).Bottom) \ 2
Dim deltaX As Integer = Math.Round((centerX - Photos(CurrentPhoto).Left) / coef)
Dim deltaY As Integer = Math.Round((centerY - Photos(CurrentPhoto).Top) / coef)
If deltaX > photoLoaded.Image.Width \ 2 Then deltaX = photoLoaded.Image.Width \ 2
If deltaY > photoLoaded.Image.Height \ 2 Then deltaY = photoLoaded.Image.Height \ 2
Dim test As Boolean = True
Dim rtest As Single
rtest = Math.Abs(1.0 * deltaX / deltaY / photoWidth * photoHeight - 1.0)
If rtest > 0.002 Then test = False
If test Then
Photos(CurrentPhoto).Zoom = photoZoom
BuildZoom()
Photos(CurrentPhoto).Left = centerX - deltaX
Photos(CurrentPhoto).right = centerX + deltaX
Photos(CurrentPhoto).Top = centerY - deltaY
Photos(CurrentPhoto).Bottom = centerY + deltaY
If Photos(CurrentPhoto).Left < 0 Then
Photos(CurrentPhoto).right -= Photos(CurrentPhoto).Left
Photos(CurrentPhoto).Left = 0
ElseIf Photos(CurrentPhoto).right > photoLoaded.Image.Width Then
Photos(CurrentPhoto).Left -= (Photos(CurrentPhoto).right - photoLoaded.Image.Width)
Photos(CurrentPhoto).right = photoLoaded.Image.Width
End If
If Photos(CurrentPhoto).Top < 0 Then
Photos(CurrentPhoto).Bottom -= Photos(CurrentPhoto).Top
Photos(CurrentPhoto).Top = 0
ElseIf Photos(CurrentPhoto).Bottom > photoLoaded.Image.Height Then
Photos(CurrentPhoto).Top -= (Photos(CurrentPhoto).Bottom - photoLoaded.Image.Height)
Photos(CurrentPhoto).Bottom = photoLoaded.Image.Height
End If
Dim Zone As Rectangle
Zone = Rectangle.FromLTRB(0, 0, photoWidth, photoHeight)
Dim GRP As Graphics = Graphics.FromImage(resisedPhoto)
GRP.InterpolationMode = Drawing2D.InterpolationMode.Low
GRP.DrawImage(photoLoaded.Image, Zone, Photos(CurrentPhoto).Left, Photos(CurrentPhoto).Top, _
Photos(CurrentPhoto).right - Photos(CurrentPhoto).Left, Photos(CurrentPhoto).Bottom - Photos(CurrentPhoto).Top, GraphicsUnit.Pixel)
GRP.Dispose()
PictureBox.Image = resisedPhoto.Clone
memoMouseX = memX
memoMouseY = memY
End If
End If
MouseIsMoving = False
End Sub
Private Sub BuildZoom()
Dim Hzone, Wzone As Integer
Dim theBrush As SolidBrush
If CurrentPhoto < 0 Then Exit Sub
PictureBoxZoom.Height = PictureBox.Height
PictureBoxZoom.Top = PictureBox.Top
Wzone = PictureBoxZoom.Width
Dim Img As New Bitmap(PictureBoxZoom.Width, PictureBoxZoom.Height)
Dim GRP As Graphics = Graphics.FromImage(Img)
If Photos(CurrentPhoto).Zoom < 1 Then
Hzone = PictureBoxZoom.Height * (1.0 - Photos(CurrentPhoto).Zoom)
theBrush = New SolidBrush(Color.FromArgb(128, 255, 128))
GRP.FillRectangle(theBrush, 0, 0, Wzone, PictureBoxZoom.Height)
theBrush = New SolidBrush(Color.FromArgb(0, 192, 0))
GRP.FillRectangle(theBrush, 0, PictureBoxZoom.Height - Hzone, Wzone, Hzone)
Else
Hzone = PictureBoxZoom.Height * (1.0 - 1.0 / Photos(CurrentPhoto).Zoom)
theBrush = New SolidBrush(Color.FromArgb(255, 128, 128))
GRP.FillRectangle(theBrush, 0, 0, Wzone, PictureBoxZoom.Height)
theBrush = New SolidBrush(Color.FromArgb(224, 0, 0))
GRP.FillRectangle(theBrush, 0, PictureBoxZoom.Height - Hzone, Wzone, Hzone)
End If
GRP.Dispose()
PictureBoxZoom.Image = Img.Clone
End Sub
Private Sub SaveData()
Dim Nomfichier As String = selectedFolder + "\MemoRecadrages.txt"
Dim Res(NbPhotosATraiter) As String
For num = 0 To NbPhotosATraiter - 1
Res(num) = Photos(num).Folder
Res(num) += "|"
Res(num) += Photos(num).Nom
Res(num) += "|"
Res(num) += Photos(num).Top.ToString
Res(num) += "|"
Res(num) += Photos(num).Bottom.ToString
Res(num) += "|"
Res(num) += Photos(num).Left.ToString
Res(num) += "|"
Res(num) += Photos(num).right.ToString
Res(num) += "|"
Res(num) += Photos(num).Zoom.ToString
Res(num) += "|"
Res(num) += Photos(num).ZoomMini.ToString
Res(num) += "|"
Res(num) += Photos(num).recadreH.ToString
Res(num) += "|"
Res(num) += Photos(num).recadreW.ToString
Next
System.IO.File.WriteAllLines(NomFichier, Res)
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
SaveData()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim NomFichier As String = String.Concat(My.Application.Info.DirectoryPath, "\RedimJPegData.txt")
Dim TempResultats() As String
Dim FileOfResultats As System.IO.FileStream
If File.Exists(NomFichier) Then
FileOfResultats = File.OpenRead(NomFichier)
TempResultats = File.ReadAllLines(NomFichier)
FileOfResultats.Close()
Dim Array() As String = Split(TempResultats(0), "|")
selectedFolder = Array(0)
photoHeight = Array(1)
photoWidth = Array(2)
EtablirListePhotos()
control()
If photoHeightIsOk Then TextBoxHauteur.Text = Array(1)
If photoWidthIsOk Then TextBoxLargeur.Text = Array(2)
End If
End Sub
Private Sub PictureBox_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox.DoubleClick
SavePhoto()
If CurrentPhoto < NbPhotosATraiter - 1 Then
CurrentPhoto += 1
LoadPhoto(CurrentPhoto)
End If
End Sub
End Class
Conclusion :
Simple et efficase
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.