Foto’s (of andere beelden) vergroten of verkleinen

Om later eens te gebruiken …

Ik vond in een voorbeeld app in Gambas volgend stukje code:

Public Sub Add(ImagePath As String)
Dim img As Image
Dim newPicture As Result
'Dim pictureData As String
Dim scale As Float
Dim eTime As Float
newPicture = databaseConnection.Create("pictures")
' Save temp image as png file
img = Image.Load(ImagePath)
newPicture["image"] = File.Load(tempFile)
' Create image thumb
If img.Width > thumbSize Or img.Height > thumbSize Then
' Calc factor to scale isotropic
scale = Min(ThumbSize / img.Width, ThumbSize / img.Height)
img = img.Stretch(img.Width * scale, img.Height * scale)
End If
newPicture["thumb"] = File.Load(tempFile)
' Add description and update
newPicture["description"] = "Image " & File.BaseName(ImagePath) & " added: " & Format(Now, "dddd, dd mmmm yyyy hh:nn:ss")
eTime = Timer
Print "Done in "; Format(Timer - eTime, "#.###"); " s"
If Exist(tempFile) Then Kill tempFile
Error.Raise("Add database record error

" & DConv(Error.Text))

This entry was posted in Gambas3, Hoe - in Gambas. Bookmark the permalink.