[EXAMPLES]
* NEW: Fix and enhance PhotoTouch example. git-svn-id: svn://localhost/gambas/trunk@4667 867c0c6c-44f3-4631-809d-bfa615b0a4ec
|
@ -9,6 +9,14 @@ Image
|
||||||
p
|
p
|
||||||
Image
|
Image
|
||||||
|
|
||||||
|
Opacity
|
||||||
|
p
|
||||||
|
f
|
||||||
|
|
||||||
|
Highlight
|
||||||
|
p
|
||||||
|
b
|
||||||
|
|
||||||
_new
|
_new
|
||||||
m
|
m
|
||||||
|
|
||||||
|
@ -29,10 +37,6 @@ DrawingArea_DblClick
|
||||||
m
|
m
|
||||||
|
|
||||||
|
|
||||||
Timer_Timer
|
|
||||||
m
|
|
||||||
|
|
||||||
|
|
||||||
DrawingArea_Draw
|
DrawingArea_Draw
|
||||||
m
|
m
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,108 @@ msgstr ""
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"Language: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: FBrightness.form:55
|
#: FMain.class:107
|
||||||
|
msgid "Automatic correction"
|
||||||
|
msgstr "Correction automatique"
|
||||||
|
|
||||||
|
#: FBrightness.form:56 FMain.class:107
|
||||||
msgid "Balance"
|
msgid "Balance"
|
||||||
msgstr "Balance"
|
msgstr "Balance"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Blur"
|
||||||
|
msgstr "Flou"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Crop image"
|
||||||
|
msgstr "Découper l'image"
|
||||||
|
|
||||||
#: FScissors.form:19
|
#: FScissors.form:19
|
||||||
msgid "Cut"
|
msgid "Cut"
|
||||||
msgstr "Découper"
|
msgstr "Découper"
|
||||||
|
|
||||||
#: .project:1
|
#: FMain.class:107
|
||||||
msgid "Retouche Photo"
|
msgid "Fit to window"
|
||||||
msgstr ""
|
msgstr "Zoom à la taille de l'écran"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Flip horizontally"
|
||||||
|
msgstr "Retourner horizontalement"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Flip vertically"
|
||||||
|
msgstr "Retourner verticalement"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Invert"
|
||||||
|
msgstr "Inverser"
|
||||||
|
|
||||||
|
#: FMain.class:55
|
||||||
|
msgid "No image in directory"
|
||||||
|
msgstr "Aucune image dans ce répertoire"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Normalize"
|
||||||
|
msgstr "Normaliser"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Oil painting effect"
|
||||||
|
msgstr "Effet de peinture à l'huile"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Quit"
|
||||||
|
msgstr "Quitter"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Remove speckles"
|
||||||
|
msgstr "Enlever les tâches"
|
||||||
|
|
||||||
|
#: FMain.class:107 FResize.form:40
|
||||||
|
msgid "Resize"
|
||||||
|
msgstr "Redimensionner"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Rotate left"
|
||||||
|
msgstr "Rotation vers la gauche"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Rotate right"
|
||||||
|
msgstr "Rotation vers la droite"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Select photo directory"
|
||||||
|
msgstr "Choisir le répertoire des photographies"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Sharpen"
|
||||||
|
msgstr "Netteté"
|
||||||
|
|
||||||
|
#: .project:1
|
||||||
|
msgid "Simple Photo Editor"
|
||||||
|
msgstr "Editeur de photographie simplifié"
|
||||||
|
|
||||||
|
#: FMain.class:58
|
||||||
|
msgid "Unable to load image"
|
||||||
|
msgstr "Impossible de charger l'image"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Undo all changes"
|
||||||
|
msgstr "Annuler tous les changements"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Zoom 100%"
|
||||||
|
msgstr "Zoom 100%"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Zoom in"
|
||||||
|
msgstr "Zoom avant"
|
||||||
|
|
||||||
|
#: FMain.class:107
|
||||||
|
msgid "Zoom out"
|
||||||
|
msgstr "Zoom arrière"
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ Component=gb.image
|
||||||
Component=gb.qt4
|
Component=gb.qt4
|
||||||
Component=gb.form
|
Component=gb.form
|
||||||
Component=gb.desktop
|
Component=gb.desktop
|
||||||
|
Component=gb.settings
|
||||||
Component=gb.image.effect
|
Component=gb.image.effect
|
||||||
Authors="Benoît Minisini"
|
Authors="Benoît Minisini"
|
||||||
TabSize=2
|
TabSize=2
|
||||||
|
|
48
examples/examples/Image/PhotoTouch/.src/CAnimation.class
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
' Gambas class file
|
||||||
|
|
||||||
|
Private $hObject As Object
|
||||||
|
Private $sProperty As String
|
||||||
|
Private $fTarget As Float
|
||||||
|
Private $fTime As Float
|
||||||
|
Private $hTimer As Timer
|
||||||
|
|
||||||
|
Public Sub _new(hObject As Control, sProperty As String, fTarget As Float, iTime As Integer)
|
||||||
|
|
||||||
|
$hObject = hObject
|
||||||
|
$sProperty = sProperty
|
||||||
|
$fTarget = fTarget
|
||||||
|
$fTime = Timer + iTime / 1000
|
||||||
|
|
||||||
|
$hTimer = New Timer As "Timer"
|
||||||
|
$hTimer.Delay = 50
|
||||||
|
$hTimer.Start
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Public Sub Timer_Timer()
|
||||||
|
|
||||||
|
Dim fValue As Float
|
||||||
|
Dim iSign As Integer
|
||||||
|
|
||||||
|
fValue = Object.GetProperty($hObject, $sProperty)
|
||||||
|
|
||||||
|
iSign = Sgn($fTarget - fValue)
|
||||||
|
fValue += ($fTarget - fValue) / (1000 * ($fTime - Timer) / $hTimer.Delay)
|
||||||
|
If Sgn($fTarget - fValue) <> iSign Then
|
||||||
|
Object.SetProperty($hObject, $sProperty, $fTarget)
|
||||||
|
{Stop}
|
||||||
|
Else
|
||||||
|
Object.SetProperty($hObject, $sProperty, fValue)
|
||||||
|
Endif
|
||||||
|
|
||||||
|
Catch
|
||||||
|
|
||||||
|
{Stop}
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Public Sub Stop()
|
||||||
|
|
||||||
|
$hTimer = Null
|
||||||
|
|
||||||
|
End
|
|
@ -7,22 +7,26 @@ Inherits DrawingArea
|
||||||
Event Click
|
Event Click
|
||||||
|
|
||||||
Property Image As Image
|
Property Image As Image
|
||||||
|
Property Opacity As Float
|
||||||
|
Property Highlight As Boolean
|
||||||
|
|
||||||
Private Const MIN_OPACITY As Float = 0.3
|
Private MIN_OPACITY As Float = 0.2
|
||||||
Private Const MAX_OPACITY As Float = 0.8
|
Private MAX_OPACITY As Float = 0.8
|
||||||
|
|
||||||
Private $hObs As Observer
|
Private $hObs As Observer
|
||||||
Private $hImage As Image
|
Private $hImage As Image
|
||||||
Private $hDraw As Image
|
Private $hDraw As Image
|
||||||
Private $bInside As Boolean
|
Private $bInside As Boolean
|
||||||
Private $hTimer As Timer
|
'Private $hTimer As Timer
|
||||||
|
Private $hAnim As CAnimation
|
||||||
Private $fOpacity As Float = MIN_OPACITY
|
Private $fOpacity As Float = MIN_OPACITY
|
||||||
|
Private $bHighlight As Boolean
|
||||||
|
|
||||||
Public Sub _new()
|
Public Sub _new()
|
||||||
|
|
||||||
$hObs = New Observer(Me) As "DrawingArea"
|
$hObs = New Observer(Me) As "DrawingArea"
|
||||||
$hTimer = New Timer As "Timer"
|
'$hTimer = New Timer As "Timer"
|
||||||
$hTimer.Delay = 50
|
'$hTimer.Delay = 50
|
||||||
Me.Mouse = Mouse.Pointing
|
Me.Mouse = Mouse.Pointing
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -30,14 +34,16 @@ End
|
||||||
Public Sub DrawingArea_Enter()
|
Public Sub DrawingArea_Enter()
|
||||||
|
|
||||||
$bInside = True
|
$bInside = True
|
||||||
$hTimer.Start
|
Try $hAnim.Stop
|
||||||
|
$hAnim = New CAnimation(Me, "Opacity", MAX_OPACITY, 250)
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
Public Sub DrawingArea_Leave()
|
Public Sub DrawingArea_Leave()
|
||||||
|
|
||||||
$bInside = False
|
$bInside = False
|
||||||
$hTimer.Start
|
Try $hAnim.Stop
|
||||||
|
$hAnim = New CAnimation(Me, "Opacity", MIN_OPACITY, 250)
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -54,30 +60,37 @@ Public Sub DrawingArea_DblClick()
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
Public Sub Timer_Timer()
|
' Public Sub Timer_Timer()
|
||||||
|
'
|
||||||
If $bInside Then
|
' If $bInside Then
|
||||||
$fOpacity = Min(MAX_OPACITY, $fOpacity + 0.1)
|
' $fOpacity = Min(MAX_OPACITY, $fOpacity + 0.1)
|
||||||
If $fOpacity >= MAX_OPACITY Then
|
' If $fOpacity >= MAX_OPACITY Then
|
||||||
$hTimer.Stop
|
' $hTimer.Stop
|
||||||
Endif
|
' Endif
|
||||||
Else
|
' Else
|
||||||
$fOpacity = Max(MIN_OPACITY, $fOpacity - 0.1)
|
' $fOpacity = Max(MIN_OPACITY, $fOpacity - 0.1)
|
||||||
If $fOpacity <= MIN_OPACITY Then
|
' If $fOpacity <= MIN_OPACITY Then
|
||||||
$hTimer.Stop
|
' $hTimer.Stop
|
||||||
Endif
|
' Endif
|
||||||
Endif
|
' Endif
|
||||||
|
'
|
||||||
SetOpacity
|
' SetOpacity
|
||||||
|
'
|
||||||
End
|
' End
|
||||||
|
|
||||||
|
|
||||||
Public Sub DrawingArea_Draw()
|
Public Sub DrawingArea_Draw()
|
||||||
|
|
||||||
If Not $hImage Then Return
|
If Not $hImage Then Return
|
||||||
|
|
||||||
Draw.Image($hDraw, 0, 0, Me.W, Me.H)
|
Draw.Image($hDraw, 4, 4)
|
||||||
|
If $bHighlight Then
|
||||||
|
Paint.Begin(Me)
|
||||||
|
Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 192))
|
||||||
|
Paint.Rectangle(0, 0, Me.W, Me.H)
|
||||||
|
Paint.Fill
|
||||||
|
Paint.End
|
||||||
|
Endif
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -89,7 +102,7 @@ End
|
||||||
|
|
||||||
Private Sub Image_Write(Value As Image)
|
Private Sub Image_Write(Value As Image)
|
||||||
|
|
||||||
$hImage = Value
|
$hImage = Value.Stretch(Me.W - 8, Me.H - 8)
|
||||||
SetOpacity
|
SetOpacity
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -101,3 +114,34 @@ Private Sub SetOpacity()
|
||||||
Me.Refresh
|
Me.Refresh
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Private Function Opacity_Read() As Float
|
||||||
|
|
||||||
|
Return $fOpacity
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Private Sub Opacity_Write(Value As Float)
|
||||||
|
|
||||||
|
$fOpacity = Max(0, Min(1, Value))
|
||||||
|
SetOpacity
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Private Function Highlight_Read() As Boolean
|
||||||
|
|
||||||
|
Return $bHighlight
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Private Sub Highlight_Write(Value As Boolean)
|
||||||
|
|
||||||
|
$bHighlight = Value
|
||||||
|
'MIN_OPACITY = If($bHighlight, 0.6, 0.2)
|
||||||
|
'If Not $bInside Then
|
||||||
|
' Try $hAnim.Stop
|
||||||
|
' $hAnim = New CAnimation(Me, "Opacity", MIN_OPACITY, 250)
|
||||||
|
'Endif
|
||||||
|
Me.Refresh
|
||||||
|
|
||||||
|
End
|
||||||
|
|
|
@ -12,11 +12,11 @@ Private btnApply As CButton
|
||||||
Public Sub _new()
|
Public Sub _new()
|
||||||
|
|
||||||
btnUndo = New CButton(Me) As "btnUndo"
|
btnUndo = New CButton(Me) As "btnUndo"
|
||||||
btnUndo.Move(Me.W - 128 - Desktop.Scale * 3, Desktop.Scale * 3, 64, 64)
|
btnUndo.Move(Me.W - 96 - Desktop.Scale * 4, Desktop.Scale * 3, 48, 48)
|
||||||
btnUndo.Image = Image.Load("undo.png")
|
btnUndo.Image = Image.Load("undo.png")
|
||||||
|
|
||||||
btnApply = New CButton(Me) As "btnApply"
|
btnApply = New CButton(Me) As "btnApply"
|
||||||
btnApply.Move(btnUndo.X + btnUndo.W + Desktop.Scale, btnUndo.Y, 64, 64)
|
btnApply.Move(btnUndo.X + btnUndo.W + Desktop.Scale, btnUndo.Y, 48, 48)
|
||||||
btnApply.Image = Image.Load("ok.png")
|
btnApply.Image = Image.Load("ok.png")
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -29,12 +29,6 @@ Public Sub Form_Open()
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
Public Sub Form_Close()
|
|
||||||
|
|
||||||
FMain.End
|
|
||||||
|
|
||||||
End
|
|
||||||
|
|
||||||
Public Sub btnUndo_Click()
|
Public Sub btnUndo_Click()
|
||||||
|
|
||||||
$bNoChange = True
|
$bNoChange = True
|
||||||
|
@ -49,7 +43,6 @@ End
|
||||||
Public Sub btnApply_Click()
|
Public Sub btnApply_Click()
|
||||||
|
|
||||||
FMain.Apply
|
FMain.Apply
|
||||||
Me.Close
|
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
|
@ -11,25 +11,25 @@
|
||||||
MoveScaled(1,1,72,46)
|
MoveScaled(1,1,72,46)
|
||||||
Background = &H000000&
|
Background = &H000000&
|
||||||
{ PictureBox1 PictureBox
|
{ PictureBox1 PictureBox
|
||||||
MoveScaled(2,10,10,10)
|
MoveScaled(2,11,8,8)
|
||||||
Picture = Picture["luminosity.png"]
|
Picture = Picture["luminosity.png"]
|
||||||
Stretch = True
|
Stretch = True
|
||||||
Alignment = Align.Center
|
Alignment = Align.Center
|
||||||
}
|
}
|
||||||
{ PictureBox2 PictureBox
|
{ PictureBox2 PictureBox
|
||||||
MoveScaled(2,22,10,10)
|
MoveScaled(2,23,8,8)
|
||||||
Picture = Picture["contrast.png"]
|
Picture = Picture["contrast.png"]
|
||||||
Stretch = True
|
Stretch = True
|
||||||
Alignment = Align.Center
|
Alignment = Align.Center
|
||||||
}
|
}
|
||||||
{ sldBrightness Slider Balance
|
{ sldBrightness Slider Balance
|
||||||
Name = "sldBrightness"
|
Name = "sldBrightness"
|
||||||
MoveScaled(15,13,53,3)
|
MoveScaled(13,13,55,3)
|
||||||
Value = 50
|
Value = 50
|
||||||
}
|
}
|
||||||
{ sldContrast Slider Balance
|
{ sldContrast Slider Balance
|
||||||
Name = "sldContrast"
|
Name = "sldContrast"
|
||||||
MoveScaled(15,25,53,3)
|
MoveScaled(13,25,55,3)
|
||||||
Value = 50
|
Value = 50
|
||||||
}
|
}
|
||||||
{ Label1 Label
|
{ Label1 Label
|
||||||
|
@ -40,14 +40,14 @@
|
||||||
Text = ("Balance")
|
Text = ("Balance")
|
||||||
}
|
}
|
||||||
{ PictureBox3 PictureBox
|
{ PictureBox3 PictureBox
|
||||||
MoveScaled(2,34,10,10)
|
MoveScaled(2,35,8,8)
|
||||||
Picture = Picture["gamma.png"]
|
Picture = Picture["gamma.png"]
|
||||||
Stretch = True
|
Stretch = True
|
||||||
Alignment = Align.Center
|
Alignment = Align.Center
|
||||||
}
|
}
|
||||||
{ sldGamma Slider Balance
|
{ sldGamma Slider Balance
|
||||||
Name = "sldGamma"
|
Name = "sldGamma"
|
||||||
MoveScaled(15,37,53,3)
|
MoveScaled(13,37,55,3)
|
||||||
Value = 50
|
Value = 50
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
' Gambas class file
|
' Gambas class file
|
||||||
|
|
||||||
Private CACHE_DIR As String = "~/.cache/gambas/PhotoTouch"
|
Private CACHE_ROOT As String = "~/.cache/gambas/PhotoTouch"
|
||||||
|
Private CACHE_DIR As String
|
||||||
|
|
||||||
Private $aPath As String[]
|
Private $aPath As String[]
|
||||||
Private $sPath As String
|
Private $sPath As String
|
||||||
|
@ -13,6 +14,7 @@ Private $fZoom As Float = 1
|
||||||
Private $sInfo As String
|
Private $sInfo As String
|
||||||
Private $sMode As String
|
Private $sMode As String
|
||||||
Private $bModify As Boolean
|
Private $bModify As Boolean
|
||||||
|
Private $cButton As New Collection
|
||||||
|
|
||||||
Private $MX As Integer
|
Private $MX As Integer
|
||||||
Private $MY As Integer
|
Private $MY As Integer
|
||||||
|
@ -73,26 +75,52 @@ Public Sub _new()
|
||||||
Dim sImg As String
|
Dim sImg As String
|
||||||
Dim hButton As CButton
|
Dim hButton As CButton
|
||||||
Dim hPanel As Panel
|
Dim hPanel As Panel
|
||||||
|
Dim cTooltip As Collection
|
||||||
|
|
||||||
Application.MainWindow = Me
|
Application.MainWindow = Me
|
||||||
|
|
||||||
Try Mkdir File.Dir(File.Dir(cache_dir))
|
Try Mkdir File.Dir(File.Dir(CACHE_ROOT))
|
||||||
Try Mkdir File.Dir(cache_dir)
|
Try Mkdir File.Dir(CACHE_ROOT)
|
||||||
Try Mkdir CACHE_DIR
|
Try Mkdir CACHE_ROOT
|
||||||
|
|
||||||
For Each sImg In ["usb", "-", "zoom-in", "zoom-out", "zoom-original", "zoom-fit", "-", "rotate-left", "rotate-right", "-", "scissors", "luminosity", "<->", "undo", "quit"]
|
cTooltip = [
|
||||||
|
"usb": ("Select photo directory"),
|
||||||
|
"zoom-in": ("Zoom in"),
|
||||||
|
"zoom-out": ("Zoom out"),
|
||||||
|
"zoom-original": ("Zoom 100%"),
|
||||||
|
"zoom-fit": ("Fit to window"),
|
||||||
|
"hflip": ("Flip horizontally"),
|
||||||
|
"vflip": ("Flip vertically"),
|
||||||
|
"rotate-left": ("Rotate left"),
|
||||||
|
"rotate-right": ("Rotate right"),
|
||||||
|
"magic": ("Automatic correction"),
|
||||||
|
"invert": ("Invert"),
|
||||||
|
"blur": ("Blur"),
|
||||||
|
"sharpen": ("Sharpen"),
|
||||||
|
"normalize": ("Normalize"),
|
||||||
|
"despeckle": ("Remove speckles"),
|
||||||
|
"oil": ("Oil painting effect"),
|
||||||
|
"scissors": ("Crop image"),
|
||||||
|
"balance": ("Balance"),
|
||||||
|
"resize": ("Resize"),
|
||||||
|
"undo": ("Undo all changes"),
|
||||||
|
"quit": ("Quit")]
|
||||||
|
|
||||||
|
For Each sImg In ["usb", "-", "zoom-in", "zoom-out", "zoom-original", "zoom-fit", "-", "hflip", "vflip", "rotate-left", "rotate-right", "-", "magic", "invert", "blur", "sharpen", "normalize", "despeckle", "oil", "-", "scissors", "resize", "balance", "<->", "undo", "quit"]
|
||||||
If sImg = "<->" Then
|
If sImg = "<->" Then
|
||||||
hPanel = New Panel(panToolbar)
|
hPanel = New Panel(panToolbar)
|
||||||
hPanel.Expand = True
|
hPanel.Expand = True
|
||||||
hPanel.Resize(8, 64)
|
hPanel.Resize(8, 48)
|
||||||
Else If sImg = "-" Then
|
Else If sImg = "-" Then
|
||||||
hPanel = New Panel(panToolbar)
|
hPanel = New Panel(panToolbar)
|
||||||
hPanel.Resize(16, 64)
|
hPanel.Resize(8, 48)
|
||||||
Else
|
Else
|
||||||
hButton = New CButton(panToolbar) As "Button"
|
hButton = New CButton(panToolbar) As "Button"
|
||||||
hButton.Resize(64, 64)
|
hButton.Resize(48, 48)
|
||||||
hButton.Image = Image.Load(sImg & ".png")
|
hButton.Image = Image.Load(sImg & ".png")
|
||||||
hButton.Tag = sImg
|
hButton.Tag = sImg
|
||||||
|
hButton.Tooltip = cTooltip[sImg]
|
||||||
|
$cButton[hButton.Tag] = hButton
|
||||||
Endif
|
Endif
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
@ -111,12 +139,6 @@ Public Sub _new()
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
Public Sub Form_Open()
|
|
||||||
|
|
||||||
SetDir(User.Home)
|
|
||||||
|
|
||||||
End
|
|
||||||
|
|
||||||
Public Sub svwImage_Draw()
|
Public Sub svwImage_Draw()
|
||||||
|
|
||||||
Dim X As Integer
|
Dim X As Integer
|
||||||
|
@ -204,7 +226,7 @@ End
|
||||||
|
|
||||||
Public Sub Form_Resize()
|
Public Sub Form_Resize()
|
||||||
|
|
||||||
panToolbar.Move(0, 0, Me.W, 64 + Desktop.Scale * 2)
|
panToolbar.Move(0, 0, Me.W, 48 + Desktop.Scale * 2)
|
||||||
dwgInfo.Move(8, Me.H - dwgInfo.H, Me.W, dwgInfo.H)
|
dwgInfo.Move(8, Me.H - dwgInfo.H, Me.W, dwgInfo.H)
|
||||||
btnPrev.Move(8, (Me.H - btnPrev.H) / 2)
|
btnPrev.Move(8, (Me.H - btnPrev.H) / 2)
|
||||||
btnNext.Move(Me.W - 8 - btnNext.W, (Me.H - btnNext.H) / 2)
|
btnNext.Move(Me.W - 8 - btnNext.W, (Me.H - btnNext.H) / 2)
|
||||||
|
@ -235,6 +257,7 @@ Private Sub UpdateZoom()
|
||||||
svwImage.ResizeContents($hImage.W * $fZoom, $hImage.H * $fZoom)
|
svwImage.ResizeContents($hImage.W * $fZoom, $hImage.H * $fZoom)
|
||||||
svwImage.Scroll(X * svwImage.ScrollW - svwImage.ClientW / 2, Y * svwImage.ScrollH - svwImage.ClientH / 2)
|
svwImage.Scroll(X * svwImage.ScrollW - svwImage.ClientW / 2, Y * svwImage.ScrollH - svwImage.ClientH / 2)
|
||||||
|
|
||||||
|
dwgInfo.Refresh
|
||||||
Me.Refresh
|
Me.Refresh
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -263,9 +286,16 @@ End
|
||||||
Public Sub SetMode(sMode As String)
|
Public Sub SetMode(sMode As String)
|
||||||
|
|
||||||
If $sMode Then
|
If $sMode Then
|
||||||
|
$cButton[$sMode].Highlight = False
|
||||||
Cancel
|
Cancel
|
||||||
|
Select Case $sMode
|
||||||
|
Case "balance"
|
||||||
FBrightness.Close
|
FBrightness.Close
|
||||||
|
Case "scissors"
|
||||||
FScissors.Close
|
FScissors.Close
|
||||||
|
Case "resize"
|
||||||
|
FResize.Close
|
||||||
|
End Select
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
If sMode = $sMode Then
|
If sMode = $sMode Then
|
||||||
|
@ -273,13 +303,21 @@ Public Sub SetMode(sMode As String)
|
||||||
Return
|
Return
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
|
If sMode Then
|
||||||
|
|
||||||
|
$cButton[sMode].Highlight = True
|
||||||
|
|
||||||
Select Case sMode
|
Select Case sMode
|
||||||
Case "luminosity"
|
Case "balance"
|
||||||
FBrightness.Show
|
FBrightness.Show
|
||||||
Case "scissors"
|
Case "scissors"
|
||||||
FScissors.Show
|
FScissors.Show
|
||||||
|
Case "resize"
|
||||||
|
FResize.Show
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
|
Endif
|
||||||
|
|
||||||
$sMode = sMode
|
$sMode = sMode
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -311,27 +349,13 @@ Private Sub Action(sAction As String)
|
||||||
Case "zoom-fit"
|
Case "zoom-fit"
|
||||||
SetZoom(0)
|
SetZoom(0)
|
||||||
|
|
||||||
Case "rotate-left"
|
|
||||||
If Not $hImage Then Return
|
|
||||||
$hImage = $hImage.Rotate(Pi(0.5))
|
|
||||||
$bModify = True
|
|
||||||
'SaveImage
|
|
||||||
UpdateZoom
|
|
||||||
|
|
||||||
Case "rotate-right"
|
|
||||||
If Not $hImage Then Return
|
|
||||||
$hImage = $hImage.Rotate(Pi(-0.5))
|
|
||||||
$bModify = True
|
|
||||||
'SaveImage
|
|
||||||
UpdateZoom
|
|
||||||
|
|
||||||
Case "quit"
|
Case "quit"
|
||||||
SetMode("")
|
SetMode("")
|
||||||
SaveImage
|
SaveImage
|
||||||
If Dir(CACHE_DIR).Count Then Desktop.Open(CACHE_DIR)
|
If Exist(CACHE_DIR) Then Desktop.Open(CACHE_DIR)
|
||||||
Me.Close
|
Me.Close
|
||||||
|
|
||||||
Case "luminosity", "scissors"
|
Case "balance", "scissors", "resize"
|
||||||
If Not $hImage Then Return
|
If Not $hImage Then Return
|
||||||
SetMode(sAction)
|
SetMode(sAction)
|
||||||
|
|
||||||
|
@ -345,6 +369,43 @@ Private Sub Action(sAction As String)
|
||||||
LoadImage(True)
|
LoadImage(True)
|
||||||
RemoveImage
|
RemoveImage
|
||||||
|
|
||||||
|
Case Else
|
||||||
|
|
||||||
|
If Not $hImage Then Return
|
||||||
|
|
||||||
|
SetMode("")
|
||||||
|
|
||||||
|
Select Case sAction
|
||||||
|
Case "hflip"
|
||||||
|
$hImage.Mirror(True, False)
|
||||||
|
Case "vflip"
|
||||||
|
$hImage.Mirror(False, True)
|
||||||
|
Case "rotate-left"
|
||||||
|
$hImage = $hImage.Rotate(Pi(0.5))
|
||||||
|
Case "rotate-right"
|
||||||
|
$hImage = $hImage.Rotate(Pi(-0.5))
|
||||||
|
Case "oil"
|
||||||
|
$hImage = ImageMagick("-paint 4") '$hImage.OilPaint()
|
||||||
|
Case "magic"
|
||||||
|
$hImage = ImageMagick("-auto-gamma -auto-level")
|
||||||
|
Case "invert"
|
||||||
|
$hImage.Invert()
|
||||||
|
'Case "equalize"
|
||||||
|
' $hImage = ImageMagick("-equalize")
|
||||||
|
Case "despeckle"
|
||||||
|
$hImage = ImageMagick("-despeckle")
|
||||||
|
Case "normalize"
|
||||||
|
$hImage = ImageMagick("-normalize")
|
||||||
|
Case "blur"
|
||||||
|
$hImage = ImageMagick("-blur 8") '$hImage.OilPaint()
|
||||||
|
Case "sharpen"
|
||||||
|
$hImage = ImageMagick("-sharpen 8") '$hImage.OilPaint()
|
||||||
|
|
||||||
|
End Select
|
||||||
|
|
||||||
|
$bModify = True
|
||||||
|
UpdateZoom
|
||||||
|
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
End
|
End
|
||||||
|
@ -381,7 +442,7 @@ Public Sub dwgInfo_Draw()
|
||||||
' Paint.Fill
|
' Paint.Fill
|
||||||
Paint.LineWidth = 1
|
Paint.LineWidth = 1
|
||||||
Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 192))
|
Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 192))
|
||||||
Paint.DrawText($sInfo, 0, 0, dwgInfo.W, dwgInfo.H, Align.Left)
|
Paint.DrawText($sInfo & " - " & Format($fZoom, "0%"), 0, 0, dwgInfo.W, dwgInfo.H, Align.Left)
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -415,6 +476,7 @@ End
|
||||||
Public Sub Apply()
|
Public Sub Apply()
|
||||||
|
|
||||||
$hTemp = $hImage
|
$hTemp = $hImage
|
||||||
|
{End}
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -469,13 +531,34 @@ Public Sub Cut()
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Public Sub Stretch(W As Integer, H As Integer)
|
||||||
|
|
||||||
|
$hImage = $hImage.Stretch(W, H)
|
||||||
|
$bModify = True
|
||||||
|
$hTemp = $hImage
|
||||||
|
Me.End
|
||||||
|
SetZoom(0)
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
|
Public Sub Form_Activate()
|
||||||
|
|
||||||
|
If $sDir = "" Then SetDir(Settings["Directory", User.Home])
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
Private Sub SetDir(sDir As String)
|
Private Sub SetDir(sDir As String)
|
||||||
|
|
||||||
Inc Application.Busy
|
Inc Application.Busy
|
||||||
|
|
||||||
Shell "cd " & Shell(CACHE_DIR) & "; rm -f *" Wait
|
'Shell "cd " & Shell(CACHE_DIR) & "; rm -f *" Wait
|
||||||
|
|
||||||
|
CACHE_DIR = CACHE_ROOT &/ Replace(sDir, "/", ":")
|
||||||
|
|
||||||
$sDir = sDir
|
$sDir = sDir
|
||||||
|
Settings["Directory"] = $sDir
|
||||||
$aPath = New String[]
|
$aPath = New String[]
|
||||||
Try $aPath = Dir(sDir, "*.{jpg,JPG,jpeg,JPEG,png,PNG,bmp,BMP,gig,GIF}").Sort()
|
Try $aPath = Dir(sDir, "*.{jpg,JPG,jpeg,JPEG,png,PNG,bmp,BMP,gig,GIF}").Sort()
|
||||||
$iIndex = 0
|
$iIndex = 0
|
||||||
|
@ -485,13 +568,15 @@ Private Sub SetDir(sDir As String)
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
Private Sub SaveImage()
|
Private Sub SaveImage() As String
|
||||||
|
|
||||||
If Not $hImage Then Return
|
If Not $hImage Then Return
|
||||||
If Not $bModify Then Return
|
If Not $bModify Then Return
|
||||||
|
|
||||||
$hImage.Save(CACHE_DIR &/ File.Name($sPath))
|
Try Mkdir CACHE_DIR
|
||||||
|
$hImage.Save(CACHE_DIR &/ File.Name($sPath), 80)
|
||||||
$bModify = False
|
$bModify = False
|
||||||
|
Return CACHE_DIR &/ File.Name($sPath)
|
||||||
|
|
||||||
Catch
|
Catch
|
||||||
|
|
||||||
|
@ -501,6 +586,32 @@ End
|
||||||
|
|
||||||
Private Sub RemoveImage()
|
Private Sub RemoveImage()
|
||||||
|
|
||||||
Try Kill CACHE_DIR &/ File.Name($sPath)
|
Kill CACHE_DIR &/ File.Name($sPath)
|
||||||
|
If Dir(CACHE_DIR).Count = 0 Then Rmdir CACHE_DIR
|
||||||
|
|
||||||
|
Catch
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Private Sub ImageMagick(sCommand As String) As Image
|
||||||
|
|
||||||
|
Dim sPath, sPath2 As String
|
||||||
|
Dim hImage As Image
|
||||||
|
|
||||||
|
Inc Application.Busy
|
||||||
|
|
||||||
|
sPath = File.SetExt(Temp$("image"), File.Ext($sPath))
|
||||||
|
sPath2 = File.SetExt(Temp$("image2"), File.Ext($sPath))
|
||||||
|
|
||||||
|
$hImage.Save(sPath, 100)
|
||||||
|
|
||||||
|
Shell "convert " & Shell(sPath) & " " & sCommand & " " & Shell(sPath2) Wait
|
||||||
|
hImage = Image.Load(sPath2)
|
||||||
|
Kill sPath
|
||||||
|
Kill sPath2
|
||||||
|
|
||||||
|
Dec Application.Busy
|
||||||
|
|
||||||
|
Return hImage
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
{ Form Form
|
{ Form Form
|
||||||
MoveScaled(0,0,82,72)
|
MoveScaled(0,0,82,72)
|
||||||
|
Icon = Picture["icon.png"]
|
||||||
Border = False
|
Border = False
|
||||||
Maximized = True
|
Maximized = True
|
||||||
Arrangement = Arrange.Fill
|
Arrangement = Arrange.Fill
|
||||||
|
|
44
examples/examples/Image/PhotoTouch/.src/FResize.class
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
' Gambas class file
|
||||||
|
|
||||||
|
Private $aSize As Float[] = [1 / 4, 1 / 3, 1 / 2, 2 / 3, 3 / 4, 1]
|
||||||
|
Private btnApply As CButton
|
||||||
|
|
||||||
|
Public Sub sldResize_Change()
|
||||||
|
|
||||||
|
Dim W, H As Integer
|
||||||
|
|
||||||
|
With FMain.GetImage()
|
||||||
|
W = .W * $aSize[sldResize.Value]
|
||||||
|
H = .H * $aSize[sldResize.Value]
|
||||||
|
End With
|
||||||
|
lblSize.Text = Format($aSize[sldResize.Value], "0%") & " - " & W & " x " & H
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Public Sub _new()
|
||||||
|
|
||||||
|
btnApply = New CButton(Me) As "btnApply"
|
||||||
|
btnApply.Move(Me.W - 48 - Desktop.Scale * 2, Desktop.Scale * 2, 48, 48)
|
||||||
|
btnApply.Image = Image.Load("ok.png")
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Public Sub Form_Open()
|
||||||
|
|
||||||
|
Me.Center
|
||||||
|
sldResize_Change
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Public Sub btnApply_Click()
|
||||||
|
|
||||||
|
Dim W, H As Integer
|
||||||
|
|
||||||
|
With FMain.GetImage()
|
||||||
|
W = .W * $aSize[sldResize.Value]
|
||||||
|
H = .H * $aSize[sldResize.Value]
|
||||||
|
End With
|
||||||
|
|
||||||
|
FMain.Stretch(W, H)
|
||||||
|
|
||||||
|
End
|
38
examples/examples/Image/PhotoTouch/.src/FResize.form
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# Gambas Form File 3.0
|
||||||
|
|
||||||
|
{ Form Form
|
||||||
|
MoveScaled(0,0,55,24)
|
||||||
|
Background = &HFFFFFF&
|
||||||
|
Border = False
|
||||||
|
Stacking = Window.Above
|
||||||
|
SkipTaskbar = True
|
||||||
|
Opacity = 50
|
||||||
|
{ panBrightness Panel
|
||||||
|
MoveScaled(1,1,53,22)
|
||||||
|
Background = &H000000&
|
||||||
|
{ PictureBox1 PictureBox
|
||||||
|
MoveScaled(2,11,8,8)
|
||||||
|
Picture = Picture["resize.png"]
|
||||||
|
Stretch = True
|
||||||
|
Alignment = Align.Center
|
||||||
|
}
|
||||||
|
{ sldResize Slider
|
||||||
|
MoveScaled(13,11,36,3)
|
||||||
|
MaxValue = 5
|
||||||
|
Value = 5
|
||||||
|
}
|
||||||
|
{ lblTitle Label
|
||||||
|
MoveScaled(2,2,52,6)
|
||||||
|
Font = Font["Bold,+5"]
|
||||||
|
Foreground = Color.TextBackground
|
||||||
|
AutoResize = True
|
||||||
|
Text = ("Resize")
|
||||||
|
}
|
||||||
|
{ lblSize Label
|
||||||
|
MoveScaled(14,14,34,5)
|
||||||
|
Font = Font["Bold,+5"]
|
||||||
|
Foreground = Color.TextBackground
|
||||||
|
AutoResize = True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ Private $hRect As Rect
|
||||||
|
|
||||||
Private btnCut As CButton
|
Private btnCut As CButton
|
||||||
|
|
||||||
Private Sub Form_Resize()
|
Public Sub Form_Resize()
|
||||||
|
|
||||||
$aScissors[S_NW].Move(0, 0, HANDLE_SIZE, HANDLE_SIZE)
|
$aScissors[S_NW].Move(0, 0, HANDLE_SIZE, HANDLE_SIZE)
|
||||||
$aScissors[S_NE].Move(Me.W - HANDLE_SIZE, 0, HANDLE_SIZE, HANDLE_SIZE)
|
$aScissors[S_NE].Move(Me.W - HANDLE_SIZE, 0, HANDLE_SIZE, HANDLE_SIZE)
|
||||||
|
@ -25,7 +25,7 @@ Private Sub Form_Resize()
|
||||||
$aScissors[S_W].Move(0, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2)
|
$aScissors[S_W].Move(0, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2)
|
||||||
$aScissors[S_E].Move(Me.W - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2)
|
$aScissors[S_E].Move(Me.W - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2)
|
||||||
|
|
||||||
btnCut.Move(Me.W - 64 - Desktop.Scale * 3, Desktop.Scale * 3)
|
btnCut.Move(Me.W - btnCut.W - Desktop.Scale * 3, Desktop.Scale * 3)
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ Public Sub Form_Open()
|
||||||
Next
|
Next
|
||||||
|
|
||||||
btnCut = New CButton(Me) As "btnCut"
|
btnCut = New CButton(Me) As "btnCut"
|
||||||
btnCut.Resize(64, 64)
|
btnCut.Resize(48, 48)
|
||||||
btnCut.Image = Image.Load("scissors.png")
|
btnCut.Image = Image.Load("scissors.png")
|
||||||
|
|
||||||
Me.Move(FMain.ClientW \ 4, FMain.ClientH \ 4, FMain.ClientW \ 2, FMain.ClientH \ 2)
|
Me.Move(FMain.ClientW \ 4, FMain.ClientH \ 4, FMain.ClientW \ 2, FMain.ClientH \ 2)
|
||||||
Form_Resize
|
'Form_Resize
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ Public Sub Panel_MouseMove()
|
||||||
|
|
||||||
Dim X, Y As Integer
|
Dim X, Y As Integer
|
||||||
Dim iTag As Integer = Last.Tag
|
Dim iTag As Integer = Last.Tag
|
||||||
Dim MIN_HEIGHT As Integer = 64 + Desktop.Scale * 6
|
Dim MIN_HEIGHT As Integer = btnCut.W + Desktop.Scale * 6
|
||||||
Dim MIN_WIDTH As Integer = 64 + Desktop.Scale * 6
|
Dim MIN_WIDTH As Integer = btnCut.H + Desktop.Scale * 6
|
||||||
|
|
||||||
Select Case Last.Tag
|
Select Case Last.Tag
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ Public Sub Panel_MouseMove()
|
||||||
|
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
Form_Resize
|
'Form_Resize
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,6 @@ gb.image
|
||||||
gb.qt4
|
gb.qt4
|
||||||
gb.form
|
gb.form
|
||||||
gb.desktop
|
gb.desktop
|
||||||
|
gb.settings
|
||||||
gb.image.effect
|
gb.image.effect
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
examples/examples/Image/PhotoTouch/blur.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
examples/examples/Image/PhotoTouch/despeckle.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
examples/examples/Image/PhotoTouch/hflip.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
examples/examples/Image/PhotoTouch/invert.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
examples/examples/Image/PhotoTouch/magic.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
examples/examples/Image/PhotoTouch/normalize.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
examples/examples/Image/PhotoTouch/oil.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
examples/examples/Image/PhotoTouch/resize.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
examples/examples/Image/PhotoTouch/sharpen.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
examples/examples/Image/PhotoTouch/vflip.png
Normal file
After Width: | Height: | Size: 1.4 KiB |