Gambas France BETA


Pas de compte ? Incription

[GB3]ImageConverter

À propos de ce code

Redimensionner/Convertir des Images.

_Cliquer Ouvrir un Fichier,
ou avec Click Droit sur un Fichier également( Ouvrir avec, et chercher ImageConverter.gambas )
_Redimensionner si nécessaire.
_Choisir la compression (.png, .gif, .jpg).
_Enfin Valider, pour appliquer les conversions.

Reivillo.

Code source

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
' Gambas class file

' PREREQUIS:
' Verifier la présence de < convert >, < imagemagick > et < mpg321 >
PUBLIC $asCMD AS NEW STRING[16]
PUBLIC $asINF AS NEW STRING[16]

PUBLIC FUNCTION CONCATCMD() AS STRING

DIM $iWHL AS INTEGER
DIM $sRET AS STRING

WHILE $iWHL < 16
$sRET = $sRET & $asCMD[$iWHL]
INC $iWHL
WEND
RETURN $sRET

END

PUBLIC FUNCTION BIP(OPTIONAL $iBIP AS INTEGER = 1)

WHILE $iBIP > 0
SHELL "mpg321 " & Application.path & "/250-440-250.mp3 2>/dev/null"
SLEEP 0.5
DEC $iBIP
WEND

END

PUBLIC SUB INFOSFILE()

SHELL "identify " & PathFile.Text TO InfoFile.Text
InfoFile.Text = Replace$(RTrim$(InfoFile.Text), PathFile.Text, "")
InfoFile.pos = 0
$asINF = Split(InfoFile.Text, " ")
$asINF = Split($asINF[2], "x")
SpinBox5.Value = Val($asINF[0])
SpinBox6.Value = Val($asINF[1])
PathFile.Text = " " & PathFile.Text
PathFile.Pos = 0

END

PUBLIC SUB Form_Open()

ME.Center
ME.Y = 0
BIP
Dialog.Path = User.Home
Dialog.Title = "Selectionner un Fichier"
Dialog.Filter = ["*.png;*.gif;*.jpg;*.jpeg;*.bmp", " Picture files "]
IF Application.Args.Count = 2 THEN
PathFile.Text = Application.Args[1]
INFOSFILE
ENDIF

END

PUBLIC SUB Fichier_Click()

IF Dialog.OpenFile(TRUE) THEN RETURN
PathFile.Text = Dialog.Paths[0]
INFOSFILE
CATCH
Message.Info(Error.Text)

END

PUBLIC SUB Selection_Leave()

IF CheckBox1.Value = FALSE THEN
CheckBox1.Tag = ""
RETURN
ELSE
$asCMD[1] = " -crop " & SpinBox1.Value & "x" & SpinBox2.Value & "+" & SpinBox3.Value & "+" & SpinBox4.Value
ENDIF

END

PUBLIC SUB Redimension_Change()

Label1.Text = Redimension.Value & "%"

END

PUBLIC SUB Symetrie_MouseDown()

$asCMD[3] = LAST.tag

END

PUBLIC SUB Rotation_MouseDown()

$asCMD[4] = LAST.tag

END

PUBLIC SUB Compression_MouseDown()

$asCMD[15] = LAST.tag

END

PUBLIC SUB Valider_Click()

IF NoChange.Value = TRUE THEN
$asCMD[2] = ""
ELSE IF Pixels.Value = TRUE THEN
$asCMD[2] = " -resize " & SpinBox5.Value & "x" & SpinBox6.Value
ELSE IF Pourcent.Value = TRUE THEN
$asCMD[2] = " -resize " & Label1.Text
ENDIF
$asCMD[0] = PathFile.Text
$asCMD[14] = $asCMD[0]
CheckBox1.Value = FALSE
InfoFile.Text = CONCATCMD()
SHELL "convert " & InfoFile.Text

END

PUBLIC SUB PictureBox2_MouseDown()

ME.Close

END

Commentaires